cancel
Showing results for 
Search instead for 
Did you mean: 

Custom action : how to intercept the validation phase of JSF

zomurn
Champ in-the-making
Champ in-the-making
Hello,

I have a custom action like this :

<!– Etat traiter –>
         <action id="traiter_action_id">
            <permissions>
               <permission allow="true">Write</permission>
            </permissions>
            <evaluator>
               org.alfresco.module.msc.action.evaluator.MscTraiterEvaluator
            </evaluator>
            <label-id>traiter_action_label_id
            </label-id>
            <image>/images/icons/approve.gif
            </image>
            <action>browse</action>
            <action-listener>#{MscAction.setupContentAction}
            </action-listener>
            <params>
               <param name="nodeRef">#{actionContext.nodeRef}
               </param>
               <param name="actionId">traiter_action_id</param>
            </params>
         </action>

The problem is that when I click on the action, the associated action-listener is situated in the "Invoke Application" phase of JSFrequest  life cycle.
The problem is that in this phase we can't add FacesMessage to the FacesContext because, just at the end of this action listener method, the response.sendRedirect() instruction is executed and so a new FacesContext is created resulting in that the FacesMessage is then lost !
How to intercept the previous phase (I need to be in validation phase so as to be able to throw error message in web client).

Thanks.
1 REPLY 1

zomurn
Champ in-the-making
Champ in-the-making
I bypass the problem putting a flag into the session scope in the backing bean (action listener).
Inside the JSP, a scriplet like this  :

[begin of JSP code, after f:view]
If the flag is present
    populate the faces context with the value of the flag (a FacesMessage)
    remove the flag from the session
end if
[the rest of JSP code]