myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (JIRA)" <>
Subject [jira] [Resolved] (MYFACES-3976) f:viewAction phase attribute reverts to INVOKE_APPLICATION
Date Fri, 03 Apr 2015 19:44:54 GMT


Leonardo Uribe resolved MYFACES-3976.
       Resolution: Fixed
    Fix Version/s: 2.2.8

Ouch. It looks like the involved code was copied from UICommand on the very first version
of UIViewAction. I was about to do send a vote for a release for 2.2.8, but this one looks
important enough to rollback the release and include it (changed priority to mayor). I removed
the lines to fix the problem.

Thanks to Jay Sartoris for report the problem.

> f:viewAction phase attribute reverts to INVOKE_APPLICATION
> ----------------------------------------------------------
>                 Key: MYFACES-3976
>                 URL:
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-344
>    Affects Versions: 2.2.7
>            Reporter: Jay Sartoris
>            Assignee: Leonardo Uribe
>             Fix For: 2.2.8
> In JSF 2.2, the viewAction component has a phase attribute which a user can specify what
JSF lifecycle phase the action is executed in.  
> For example:
> ---------
> <f:metadata>
> <f:viewAction action="#{testBean.checkPhase}" phase="PROCESS_VALIDATIONS"/>
> </f:metadata>
> ---------
> In the backing bean, the checkPhase method simply gets the current phase we are in like
> PhaseId phase = FacesContext.getCurrentInstance().getCurrentPhaseId();
> The issue is that this is always called during the INVOKE_APPLICATION phase regardless
of what is specified in the phase attribute. 
> I tested this scenario with Mojarra 2.2.10 and it works as I expect it to...meaning it
gets called in the phase that is specified in the phase attribute. 
> In an initial investigation, I think the problem is in the javax.faces.component.UIViewAction
class in the queueEvent method.
> Before going in to the if/else block below, the event.getPhaseId will have the value
that was set on the phase attribute in the JSF page.  However, this block of code will change
it to INVOKE_APPLICATION, which is the default phase the viewAction is called in: 
> public void queueEvent(FacesEvent event)
>     {
>         if (event != null && event instanceof ActionEvent)
>         {
>             UIComponent component = event.getComponent();
>             if (component instanceof ActionSource)
>             {
>                 if (((ActionSource)component).isImmediate())
>                 {
>                     event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
>                 }
>                 else
>                 {
>                     event.setPhaseId(PhaseId.INVOKE_APPLICATION);
>                 }
>             }
>         }
>         super.queueEvent(event);
>     }
> I believe the fix should change the else block to leave the phaseId on the event object
as is if it one of the valid values:
> Note: RESTORE_VIEW and RENDER_RESPONSE are not valid values for the phase attribute of
> Note2: INVOKE_APPLICATION is the default phase a viewAction is called, so that needs
to be taken in to consideration as well (e.g. if some invalid value specified in the phase

This message was sent by Atlassian JIRA

View raw message