Stripes

ActionBeanContext has a bogus toString

Details

Description

If I use the built in toString and subclass ActionBeanContext, when I log the ActionBeanContext I get

DEBUG: 10:44:14,021: com.objecteffects.sample.web.action.TestStartActionBean.submitTest(TestStartActionBean.java:77): context: ActionBeanContext{eventName='submit', validationErrors={}}

But it's telling me that it's the wrong class. My ActionBeanContext subclasses my abstract BaseActionBeanContext;

class StartActionBeanContextFake extends BaseActionBeanContext {

When I add toString to my BaseActionBeanContext:

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
...
@Override
public String toString() { return (new ReflectionToStringBuilder(this).toString()); }

Then the log message shows the correct class:

DEBUG: 10:48:34,460: com.objecteffects.sample.web.action.TestStartActionBean.submitTest(TestStartActionBean.java:77): context: com.objecteffects.sample.web.action.StartActionBeanContextFake@4865ce[desiredDate=com.objecteffects.sample.domain.DesiredDate@d3c6a3[year=2009,month=2,day=3],request=net.sourceforge.stripes.controller.StripesRequestWrapper@1d95da8,response=net.sourceforge.stripes.mock.MockHttpServletResponse@193f6e2,servletContext=net.sourceforge.stripes.mock.MockServletContext@1385660,eventName=submit,validationErrors={}]

This is important when you're testing and you need to be sure that the correct ActionBeanContext class was used.

Activity

Hide
Frederic Daoud added a comment - 17/Sep/09 4:10 PM

Fixed in revision 1147. However I did not use commons-lang as to not introduce a dependency to it. But at least toString() will display your class name.

Show
Frederic Daoud added a comment - 17/Sep/09 4:10 PM Fixed in revision 1147. However I did not use commons-lang as to not introduce a dependency to it. But at least toString() will display your class name.

People

Vote (0)
Watch (0)

Dates

  • Created:
    17/Sep/09 12:53 PM
    Updated:
    04/Jan/11 1:32 PM
    Resolved:
    17/Sep/09 4:10 PM