Stripes

ActionBeanContext getEventName() does not return the right event when using redirection and bean flash

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: Release 1.5
  • Fix Version/s: Release 1.5
  • Component/s: None
  • Labels:
    None
  • Environment:
    Affects Stripes revision 905

Description

If I return a RedirectResolution calling a method from current action bean and I flash the action bean, the event in action bean's context is not correct.

Let's say I have 2 handler.
public Resolution update() {
return new RedirectResolution(this.getClass(), "done").flash(this);
}
public Resolution done() {
System.out.println(context.getEventName());
return new ForwardResolution("/index.jsp");
}

The output will be "update" instead of "done".

The problem is described in this email I've sent to the list.

I narrowed down the problem to a combination of what AnnotatedClassActionResolver and DispathHelper do.

In AnnotatedClassActionResolver method ActionBean getActionBean(ActionBeanContext context, String path):
The bean returned is the bean from previous request and the ActionBeanContext is not updated except for request property.
Then DispatchHelper sets the bean as ActionBean in ExecutionContext, but does not update ExecutionContext's ActionBeanContext.

When DispatchHelper sets the event name, it sets in in ExecutionContext's ActionBeanContext, but not in ActionBean's ActionBeanContext.
So we have 2 different events. One in ExecutionContext and one in the ActionBean.

The Wizard throws an exception because it checks startEvents againts ActionBean's context which is not the event that will be called.

A possible patch is to update eventName in ActionBean's ActionBeanContext in DispatchHelper's resolveHandler method.
Path is included in email.

Christian

Activity

Hide
Christian Poitras added a comment - 14/May/08 2:53 PM

Included a possible patch for the problem. The difference is in resolveHandler method.

// Then lookup the event name and handler method etc.
String eventName = resolver.getEventName(bean.getClass(), context);
context.setEventName(eventName);
// Patch start.
bean.getContext().setEventName(eventName);
// Patch end.

Show
Christian Poitras added a comment - 14/May/08 2:53 PM Included a possible patch for the problem. The difference is in resolveHandler method. // Then lookup the event name and handler method etc. String eventName = resolver.getEventName(bean.getClass(), context); context.setEventName(eventName); // Patch start. bean.getContext().setEventName(eventName); // Patch end.
Hide
Ben Gunter added a comment - 15/May/08 3:13 PM

ActionBeans that were flashed and were intended to handle the ensuing request were not receiving the correct ActionBeanContext. That is fixed now.

Show
Ben Gunter added a comment - 15/May/08 3:13 PM ActionBeans that were flashed and were intended to handle the ensuing request were not receiving the correct ActionBeanContext. That is fixed now.

People

Vote (0)
Watch (1)

Dates

  • Created:
    14/May/08 11:39 AM
    Updated:
    04/Jan/11 2:49 PM
    Resolved:
    15/May/08 3:13 PM