FAQ
Hi All,



HtmlCommandLink and HtmlCommandButton extend UICommand component class.

UICommand creates 2 MethodBindings - action and actionListener.



I was looking at the code for UICommand class and I could locate where
the registered actionListeners were getting executed - broadcast method
but I was not able to figure out where the action method was getting
invoked and how does NavigationHandler takes control from there on.



In NavigationHandler javadoc the following is mentioned:

public abstract void handleNavigation(javax.faces.context.FacesContext
context,
java.lang.String fromAction,
java.lang.String outcome)



Parameters:

context - The FacesContext
<http://java.sun.com/javaee/javaserverfaces/1.1/docs/api/javax/faces/con
text/FacesContext.html> for the current request

fromAction - The action binding expression that was evaluated to
retrieve the specified outcome, or null if the outcome was acquired by
some other means

outcome - The logical outcome returned by a previous invoked application
action (which may be null)



Does it mean that if I create a MethodBinding out of an action EL
expression and then invoke the same, then will it execute the action
method and then automatically call the method specified above to
navigate to next view according to the navigation rules defined?



Any insight into this will be helpful.



Regards,

Madhav



**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Search Discussions

  • Madhav Bhargava at Mar 2, 2007 at 10:08 am
    One more thing:



    Can anyone explain the parameters that are required in the
    handleNavigation method. Why is fromAction and outcome both required?

    Also to properly identify <to-view-id> <from-view-id> also might be
    required?



    Does handleNavigation handle that implicitely and is therefore not
    required to be a parameter?



    ~madhav



    ________________________________

    From: Madhav Bhargava
    Sent: Friday, March 02, 2007 1:55 PM
    To: MyFaces Discussion
    Subject: how does UICommand execute the action binding?



    Hi All,



    HtmlCommandLink and HtmlCommandButton extend UICommand component class.

    UICommand creates 2 MethodBindings - action and actionListener.



    I was looking at the code for UICommand class and I could locate where
    the registered actionListeners were getting executed - broadcast method
    but I was not able to figure out where the action method was getting
    invoked and how does NavigationHandler takes control from there on.



    In NavigationHandler javadoc the following is mentioned:

    public abstract void handleNavigation(javax.faces.context.FacesContext
    context,
    java.lang.String fromAction,
    java.lang.String outcome)



    Parameters:

    context - The FacesContext
    <http://java.sun.com/javaee/javaserverfaces/1.1/docs/api/javax/faces/con
    text/FacesContext.html> for the current request

    fromAction - The action binding expression that was evaluated to
    retrieve the specified outcome, or null if the outcome was acquired by
    some other means

    outcome - The logical outcome returned by a previous invoked application
    action (which may be null)



    Does it mean that if I create a MethodBinding out of an action EL
    expression and then invoke the same, then will it execute the action
    method and then automatically call the method specified above to
    navigate to next view according to the navigation rules defined?



    Any insight into this will be helpful.



    Regards,

    Madhav

    **************** CAUTION - Disclaimer *****************
    This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
    solely for the use of the addressee(s). If you are not the intended
    recipient, please notify the sender by e-mail and delete the original
    message. Further, you are not to copy, disclose, or distribute this
    e-mail or its contents to any other person and any such actions are
    unlawful. This e-mail may contain viruses. Infosys has taken every
    reasonable precaution to minimize this risk, but is not liable for any
    damage you may sustain as a result of any virus in this e-mail. You
    should carry out your own virus checks before opening the e-mail or
    attachment. Infosys reserves the right to monitor and review the content
    of all messages sent to or from this e-mail address. Messages sent to or
    from this e-mail address may be stored on the Infosys e-mail system.
    ***INFOSYS******** End of Disclaimer ********INFOSYS***
  • Volker Weber at Mar 2, 2007 at 8:09 pm
    Hi Madhav,

    the action methodBinding is handled in the defaultActionListener, which is
    invoked also in
    broadcast() from UICommand.

    NavigationHandler.handleNavigation() is done in processAction of
    defaultActionListener:
    http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ActionListenerImpl.java?view=markup

    Regards,
    Volker





    2007/3/2, Madhav Bhargava <Madhav_Bhargava@infosys.com >:
    Hi All,



    HtmlCommandLink and HtmlCommandButton extend UICommand component class.

    UICommand creates 2 MethodBindings – action and actionListener.



    I was looking at the code for UICommand class and I could locate where the
    registered actionListeners were getting executed – *broadcast* method but
    I was not able to figure out where the action method was getting invoked and
    how does NavigationHandler takes control from there on.



    In NavigationHandler javadoc the following is mentioned:

    public abstract void *handleNavigation*(javax.faces.context.FacesContext context,

    java.lang.String fromAction,


    java.lang.String outcome)



    *Parameters:*

    context - The FacesContext<http://java.sun.com/javaee/javaserverfaces/1.1/docs/api/javax/faces/context/FacesContext.html>for the current request

    fromAction - The action binding expression that was evaluated to retrieve
    the specified outcome, or null if the outcome was acquired by some other
    means

    outcome - The logical outcome returned by a previous invoked application
    action (which may be null)



    Does it mean that if I create a MethodBinding out of an action EL
    expression and then invoke the same, then will it execute the action method
    and then automatically call the method specified above to navigate to next
    view according to the navigation rules defined?



    Any insight into this will be helpful.



    Regards,

    Madhav
    **************** CAUTION - Disclaimer *****************
    This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
    solely for the use of the addressee(s). If you are not the intended
    recipient, please notify the sender by e-mail and delete the original
    message. Further, you are not to copy, disclose, or distribute this e-mail
    or its contents to any other person and any such actions are unlawful. This
    e-mail may contain viruses. Infosys has taken every reasonable precaution to
    minimize this risk, but is not liable for any damage you may sustain as a
    result of any virus in this e-mail. You should carry out your own virus
    checks before opening the e-mail or attachment. Infosys reserves the right
    to monitor and review the content of all messages sent to or from this
    e-mail address. Messages sent to or from this e-mail address may be stored
    on the Infosys e-mail system.
    ***INFOSYS******** End of Disclaimer ********INFOSYS***
  • Madhav Bhargava at Mar 3, 2007 at 1:21 pm
    Thanks Volker,

    I figured that out, but still i cannot understand the usage of
    <from-action>.
    I needed the above information because i needed to call an action method and
    then transfer the control the navigation handler programmatically. I was
    able to achieve the same by first creating a MethodBinding, invoking it,
    getting the return value as an outcome and passing the same to the
    handleNavigation method of the NavigationHandler.

    It worked for me.
    ~madhav
    On 3/3/07, Volker Weber wrote:

    Hi Madhav,

    the action methodBinding is handled in the defaultActionListener, which is
    invoked also in
    broadcast() from UICommand.

    NavigationHandler.handleNavigation() is done in processAction of
    defaultActionListener:
    http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ActionListenerImpl.java?view=markup


    Regards,
    Volker





    2007/3/2, Madhav Bhargava < Madhav_Bhargava@infosys.com >:
    Hi All,



    HtmlCommandLink and HtmlCommandButton extend UICommand component class.

    UICommand creates 2 MethodBindings – action and actionListener.



    I was looking at the code for UICommand class and I could locate where
    the registered actionListeners were getting executed – *broadcast*method but I was not able to figure out where the action method was getting
    invoked and how does NavigationHandler takes control from there on.



    In NavigationHandler javadoc the following is mentioned:

    public abstract void *handleNavigation*(javax.faces.context.FacesContext context,

    java.lang.String fromAction,



    java.lang.String outcome)



    *Parameters:*

    context - The FacesContext<http://java.sun.com/javaee/javaserverfaces/1.1/docs/api/javax/faces/context/FacesContext.html>for the current request

    fromAction - The action binding expression that was evaluated to
    retrieve the specified outcome, or null if the outcome was acquired by
    some other means

    outcome - The logical outcome returned by a previous invoked application
    action (which may be null)



    Does it mean that if I create a MethodBinding out of an action EL
    expression and then invoke the same, then will it execute the action method
    and then automatically call the method specified above to navigate to next
    view according to the navigation rules defined?



    Any insight into this will be helpful.



    Regards,

    Madhav
    **************** CAUTION - Disclaimer *****************
    This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
    solely for the use of the addressee(s). If you are not the intended
    recipient, please notify the sender by e-mail and delete the original
    message. Further, you are not to copy, disclose, or distribute this e-mail
    or its contents to any other person and any such actions are unlawful. This
    e-mail may contain viruses. Infosys has taken every reasonable precaution to
    minimize this risk, but is not liable for any damage you may sustain as a
    result of any virus in this e-mail. You should carry out your own virus
    checks before opening the e-mail or attachment. Infosys reserves the right
    to monitor and review the content of all messages sent to or from this
    e-mail address. Messages sent to or from this e-mail address may be stored
    on the Infosys e-mail system.
    ***INFOSYS******** End of Disclaimer ********INFOSYS***

    --
    When I tell the truth, it is not for the sake of convincing those who do not
    know it, but for the sake of defending those that do
  • Mike Kienenberger at Mar 3, 2007 at 3:53 pm
    See this thread:

    http://www.mail-archive.com/users@myfaces.apache.org/msg34510.html

    and this document

    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSFConfigure7.html

    On 3/3/07, Madhav Bhargava wrote:

    Thanks Volker,

    I figured that out, but still i cannot understand the usage of
    <from-action>.
    I needed the above information because i needed to call an action method
    and then transfer the control the navigation handler programmatically. I was
    able to achieve the same by first creating a MethodBinding, invoking it,
    getting the return value as an outcome and passing the same to the
    handleNavigation method of the NavigationHandler.

    It worked for me.
    ~madhav
    On 3/3/07, Volker Weber wrote:

    Hi Madhav,

    the action methodBinding is handled in the defaultActionListener, which
    is invoked also in
    broadcast() from UICommand.

    NavigationHandler.handleNavigation() is done in processAction of
    defaultActionListener:
    http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ActionListenerImpl.java?view=markup


    Regards,
    Volker





    2007/3/2, Madhav Bhargava < Madhav_Bhargava@infosys.com >:
    Hi All,



    HtmlCommandLink and HtmlCommandButton extend UICommand component
    class.

    UICommand creates 2 MethodBindings – action and actionListener.



    I was looking at the code for UICommand class and I could locate where
    the registered actionListeners were getting executed – *broadcast*method but I was not able to figure out where the action method was getting
    invoked and how does NavigationHandler takes control from there on.



    In NavigationHandler javadoc the following is mentioned:

    public abstract void *handleNavigation*(javax.faces.context.FacesContext context,

    java.lang.String fromAction,




    java.lang.String outcome)



    *Parameters:*

    context - The FacesContext<http://java.sun.com/javaee/javaserverfaces/1.1/docs/api/javax/faces/context/FacesContext.html>for the current request

    fromAction - The action binding expression that was evaluated to
    retrieve the specified outcome, or null if the outcome was acquired by
    some other means

    outcome - The logical outcome returned by a previous invoked
    application action (which may be null)



    Does it mean that if I create a MethodBinding out of an action EL
    expression and then invoke the same, then will it execute the action method
    and then automatically call the method specified above to navigate to next
    view according to the navigation rules defined?



    Any insight into this will be helpful.



    Regards,

    Madhav
    **************** CAUTION - Disclaimer *****************
    This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
    solely for the use of the addressee(s). If you are not the intended
    recipient, please notify the sender by e-mail and delete the original
    message. Further, you are not to copy, disclose, or distribute this e-mail
    or its contents to any other person and any such actions are unlawful. This
    e-mail may contain viruses. Infosys has taken every reasonable precaution to
    minimize this risk, but is not liable for any damage you may sustain as a
    result of any virus in this e-mail. You should carry out your own virus
    checks before opening the e-mail or attachment. Infosys reserves the right
    to monitor and review the content of all messages sent to or from this
    e-mail address. Messages sent to or from this e-mail address may be stored
    on the Infosys e-mail system.
    ***INFOSYS******** End of Disclaimer ********INFOSYS***

    --
    When I tell the truth, it is not for the sake of convincing those who do
    not know it, but for the sake of defending those that do
  • Madhav Bhargava at Mar 4, 2007 at 8:23 am
    Thanks Mike,

    So what i understand is that if only <from-action> is given, then
    irrespective of the outcome the control will go to the view id specified.
    For instance the folllowing rule is define din the faces config file:
    <navigation-rule>
    <from-view-id>/bingo.jsp</from-view-id>
    <navigation-case>
    <from-action>#{sombean.someAction}</from-action>
    <to-view-id>/tringo.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>

    Does the above rule mean that if someAction method is executed then
    irrespective of the outcome the control will always go to tringo.jsp? If my
    interpretation is correct then can you think of any place where this might
    be used?

    Now consider a second example:

    <navigation-rule>
    <from-view-id>/bingo.jsp</from-view-id>
    <navigation-case>
    <from-action>#{sombean.someAction}</from-action>
    <from-outcome>success</from-outcome>
    <to-view-id>/tringo.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>

    Does it mean that only if the output after executing someAction is success
    only then the control will go to tringo.jsp?
    If that is the case then why not just give the <from-outcome>, why is the
    combination of both the tags is required?

    Consider a third case:
    <navigation-rule>
    <from-view-id>/bingo.jsp</from-view-id>
    <navigation-case>
    <from-action>#{sombean.someAction}</from-action>
    <to-view-id>/tringo.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
    <from-outcome>success</from-action>
    <to-view-id>/tringo123.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>

    Now if someAction method is executed and the outcome is success then where
    will the control go? Will it go to tringo.jsp as defined by the first
    navigation-case or will it go to tringo123.jsp as defined in the second
    navigation case as both the cases are satisfied?

    ~madhav
    On 3/3/07, Mike Kienenberger wrote:

    See this thread:

    http://www.mail-archive.com/users@myfaces.apache.org/msg34510.html

    and this document

    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSFConfigure7.html

    On 3/3/07, Madhav Bhargava wrote:

    Thanks Volker,

    I figured that out, but still i cannot understand the usage of
    <from-action>.
    I needed the above information because i needed to call an action method
    and then transfer the control the navigation handler programmatically. I was
    able to achieve the same by first creating a MethodBinding, invoking it,
    getting the return value as an outcome and passing the same to the
    handleNavigation method of the NavigationHandler.

    It worked for me.
    ~madhav
    On 3/3/07, Volker Weber wrote:

    Hi Madhav,

    the action methodBinding is handled in the defaultActionListener,
    which is invoked also in
    broadcast() from UICommand.

    NavigationHandler.handleNavigation() is done in processAction of
    defaultActionListener:
    http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/ActionListenerImpl.java?view=markup


    Regards,
    Volker





    2007/3/2, Madhav Bhargava < Madhav_Bhargava@infosys.com >:
    Hi All,



    HtmlCommandLink and HtmlCommandButton extend UICommand component
    class.

    UICommand creates 2 MethodBindings – action and actionListener.



    I was looking at the code for UICommand class and I could locate
    where the registered actionListeners were getting executed – *
    broadcast* method but I was not able to figure out where the action
    method was getting invoked and how does NavigationHandler takes control from
    there on.



    In NavigationHandler javadoc the following is mentioned:

    public abstract void *handleNavigation*(javax.faces.context.FacesContext context,

    java.lang.String fromAction,





    java.lang.String outcome)



    *Parameters:*

    context - The FacesContext<http://java.sun.com/javaee/javaserverfaces/1.1/docs/api/javax/faces/context/FacesContext.html>for the current request

    fromAction - The action binding expression that was evaluated to
    retrieve the specified outcome, or null if the outcome was acquired
    by some other means

    outcome - The logical outcome returned by a previous invoked
    application action (which may be null)



    Does it mean that if I create a MethodBinding out of an action EL
    expression and then invoke the same, then will it execute the action method
    and then automatically call the method specified above to navigate to next
    view according to the navigation rules defined?



    Any insight into this will be helpful.



    Regards,

    Madhav
    **************** CAUTION - Disclaimer *****************
    This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION
    intended solely for the use of the addressee(s). If you are not the intended
    recipient, please notify the sender by e-mail and delete the original
    message. Further, you are not to copy, disclose, or distribute this e-mail
    or its contents to any other person and any such actions are unlawful. This
    e-mail may contain viruses. Infosys has taken every reasonable precaution to
    minimize this risk, but is not liable for any damage you may sustain as a
    result of any virus in this e-mail. You should carry out your own virus
    checks before opening the e-mail or attachment. Infosys reserves the right
    to monitor and review the content of all messages sent to or from this
    e-mail address. Messages sent to or from this e-mail address may be stored
    on the Infosys e-mail system.
    ***INFOSYS******** End of Disclaimer ********INFOSYS***

    --
    When I tell the truth, it is not for the sake of convincing those who do
    not know it, but for the sake of defending those that do

    --
    When I tell the truth, it is not for the sake of convincing those who do not
    know it, but for the sake of defending those that do
  • Jörn Zaefferer at Mar 4, 2007 at 2:27 pm
    From what I undestand from the specification (page 169/170) it takes the
    first matching navigation rule. So for your third case, it checks the
    form-action, and if that doesn't match, it checks the from-outcome.

    I agree that from-action alone is very helpful, but the combination has its
    uses. Though I always try to keep thinkgs simple, so I can just map outcomes
    with views, indepentend of from-view-id or anything else.
  • Simon Kitching at Mar 4, 2007 at 8:13 pm

    Madhav Bhargava wrote:
    Thanks Mike,

    So what i understand is that if only <from-action> is given, then
    irrespective of the outcome the control will go to the view id
    specified. For instance the folllowing rule is define din the faces
    config file:
    <navigation-rule>
    <from-view-id>/bingo.jsp</from-view-id>
    <navigation-case>
    <from-action>#{sombean.someAction}</from-action>
    <to-view-id>/tringo.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>

    Does the above rule mean that if someAction method is executed then
    irrespective of the outcome the control will always go to tringo.jsp? If
    my interpretation is correct then can you think of any place where this
    might be used?
    Yes, I think your description is correct.

    And yes it does seem rather pointless. I don't think from-action is
    really expected to be used alone; instead (from-action, from-outcome)
    can be used as a pair (or from-view-id, from-action, from-outcome), as
    you describe below.
    Now consider a second example:

    <navigation-rule>
    <from-view-id>/bingo.jsp</from-view-id>
    <navigation-case>
    <from-action>#{sombean.someAction}</from-action>
    <from-outcome>success</from-outcome>
    <to-view-id>/tringo.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>

    Does it mean that only if the output after executing someAction is
    success only then the control will go to tringo.jsp?
    If that is the case then why not just give the <from-outcome>, why is
    the combination of both the tags is required?
    So that the same view can have a different button bound to
    "#{somebean.otherAction}" and the return strings from those methods can
    be configured independently.

    The methods someAction and otherAction therefore do not have to be
    written with knowledge of what navigation strings the other method
    returns. I guess this could be useful when there are potentially many
    different actions in a single view, or where the actions point to
    different managed beans.

    However it makes things fragile IMO. Changing the action expression (eg
    changing the name of the method) means changing the navigation config
    which doesn't seem nice to me. I think (from-view-id, from-outcome) is
    the best combination to use in most cases. Yes it requires a little more
    coordination between the action methods to ensure that their return
    values are consistent but as from-view-id is used the set of actions to
    coordinate is reasonably small.

    Consider a third case:
    <navigation-rule>
    <from-view-id>/bingo.jsp</from-view-id>
    <navigation-case>
    <from-action>#{sombean.someAction}</from-action>
    <to-view-id>/tringo.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
    <from-outcome>success</from-action>
    <to-view-id>/tringo123.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>

    Now if someAction method is executed and the outcome is success then
    where will the control go? Will it go to tringo.jsp as defined by the
    first navigation-case or will it go to tringo123.jsp as defined in the
    second navigation case as both the cases are satisfied?

    Don't know. I guess the spec will say.


    Cheers,

    Simon

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriesmyfaces
postedMar 2, '07 at 8:26a
activeMar 4, '07 at 8:13p
posts8
users6
websitemyfaces.apache.org

People

Translate

site design / logo © 2018 Grokbase