[
http://jira.jboss.com/jira/browse/JBSEAM-2023?page=comments#action_12379797 ]
Dan Allen commented on JBSEAM-2023:
-----------------------------------
After writing a 250 line unit test, I definitely understand how these page actions
currently work and even a stronger feeling about why it should be changed.
Assume that you have a sequence of page actions configured for a view-id. If the first
page action results in a navigation event that changes the viewId, then the next action
that executes is going to look for navigation rules for this new view-id, rather than the
original. This means that while actions are executing, the navigation rule matches are
jumping all over the place.
Quick example:
<page view-id="/action-test99a.xhtml">
<action execute="#{testActions.nonNullActionA}" />
<action execute="#{testActions.nonNullActionB}" />
<navigation from-action="#{testActions.nonNullActionA}">
<rule if-outcome="outcomeA">
<render view-id="/action-test99b.xhtml" />
</rule>
</navigation>
<navigation from-action="#{testActions.nonNullActionB}">
<rule if-outcome="outcomeB">
<render view-id="/pageC.xhtml" />
</rule>
</navigation>
</page>
<page view-id="/action-test99b.xhtml">
<action execute="#{testActions.nonNullActionC}" />
<navigation from-action="#{testActions.nonNullActionB}">
<rule if-outcome="outcomeB">
<render view-id="/pageB.xhtml" />
</rule>
</navigation>
When you request /action-test99a.xhtml, here is what happens:
1. nonNullActionA() executes
2. viewId changes to /action-test99b.xhtml (a new UIViewRoot is created as well)
3. nonNullActionB() executes
4. viewId changes to /pageB.xhtml (a new UIViewRoot is created as well)
5. /pageB.xhtml is rendered
What you may find strange is that /pageC.xhtml is not rendered (even though it appears at
first glance like it would match the second action) and nonNullActionC() is never called,
even though navigation rules are being taken from that page node.
With my proposed changes, here is what would actually happen
1. nonNullActionA() executes
2. viewId changes to /action-test99b.xhtml (a new UIViewRoot is created as well)
3. /action-test99b.xhtml is rendered
short-circuit page actions on first navigation event
----------------------------------------------------
Key: JBSEAM-2023
URL:
http://jira.jboss.com/jira/browse/JBSEAM-2023
Project: JBoss Seam
Issue Type: Feature Request
Components: Core
Affects Versions: 2.0.0.CR1
Reporter: Dan Allen
Assigned To: Dan Allen
Priority: Minor
Fix For: 2.0.x
Attachments: JBSEAM-2023-v1.txt
Original Estimate: 2 hours
Remaining Estimate: 2 hours
Page actions currently have one severe quirk. If multiple page actions are configured for
a view-id pattern, they all execute without checking whether or not a navigation has
occurred (a navigation match was found). What is even more strange is that even when a
navigation match is found and the JSF NavigationHandler has processed the navigation, the
actions just keep on executing. I cannot imagine that invoking the navigation handler
multiple times was anticipated behavior. Even if it is, the developer is still going to be
massively confused which navigation event is going to actually stick.
Here is the current logic:
for ( Action action: getActions() )
{
if ( action.isExecutable() )
{
String outcome = action.getOutcome();
String fromAction = outcome;
if (outcome==null)
{
fromAction = action.getMethodExpression().getExpressionString();
result = true;
outcome = Pages.toString( action.getMethodExpression().invoke() );
Pages.handleOutcome(facesContext, outcome, fromAction);
}
else
{
Pages.handleOutcome(facesContext, outcome, fromAction);
}
}
}
I think that the short-circuit that needs to take place is that if the response is marked
as complete (which indicates a redirect navigation) or if the UIViewRoot changed (which
indicates a non-redirect navigation), then the actions should stop executing.
We should definitely include a test case if we make this change. Its too important to
screw up.
If there is a desire to maintain the previous behavior, then I believe a flag should be
added on the page element like so
<page short-circuit-actions="false">
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira