FAQ
Hi everyone

I have a small JSF application with two pages: menu.jsp and details.jsp

The menu.jsp contains something like this in a dataTable:

<h:form>
<h:commandLink action="#{MenuBackingBean.userClick}" >
<h:outputText value="#{menuTabItem.itemName}" />
<f:param name="itemID" value="#{menuTabItem.itemID}" />
</h:commandLink>
</h:form>

Depending on the itemID, the method userClick() returns "menu" or
"details" (if the return value is "menu", there is a sub-menu to be
displayed. if the return value is "display", there is no more sub-menu but
details of an actual item to be displayed) Those actions "menu" and
"details" are obviously associated with navigation rules of the
faces-config.

But here is my question:
If userClick() wants to return "details", I want it to pass the itemID to
the DetailsBackingBean first (before the statement return "details";)

How do I do that? The DetailsBackingBean is supposed to take this itemID
and look up the details data associated with this itemID before it
displays the details.jsp

How can that be done?
Is that even the right way to go?

Search Discussions

  • Matthias Wessendorf at May 22, 2006 at 3:15 pm
    Hi Matthias :-)

    You should read [1].

    I prefere the usage of updateActionListener

    -Matthias

    [1] http://wiki.apache.org/myfaces/ExecutingMethodsFromLinkButtonParameters
    On 5/22/06, Matthias Klein wrote:
    Hi everyone

    I have a small JSF application with two pages: menu.jsp and details.jsp

    The menu.jsp contains something like this in a dataTable:

    <h:form>
    <h:commandLink action="#{MenuBackingBean.userClick}" >
    <h:outputText value="#{menuTabItem.itemName}" />
    <f:param name="itemID" value="#{menuTabItem.itemID}" />
    </h:commandLink>
    </h:form>

    Depending on the itemID, the method userClick() returns "menu" or
    "details" (if the return value is "menu", there is a sub-menu to be
    displayed. if the return value is "display", there is no more sub-menu but
    details of an actual item to be displayed) Those actions "menu" and
    "details" are obviously associated with navigation rules of the
    faces-config.

    But here is my question:
    If userClick() wants to return "details", I want it to pass the itemID to
    the DetailsBackingBean first (before the statement return "details";)

    How do I do that? The DetailsBackingBean is supposed to take this itemID
    and look up the details data associated with this itemID before it
    displays the details.jsp

    How can that be done?
    Is that even the right way to go?



    --
    Matthias Wessendorf
    Aechterhoek 18
    48282 Emsdetten
    http://jroller.com/page/mwessendorf
    mwessendorf-at-gmail-dot-com
  • Matthias Klein at May 22, 2006 at 3:56 pm
    Thanks. I read that Wiki article. And in fact, when I wrote my question, I
    had the first approach implemented (the one with the FacesContext).
    I put this long statement "FacesContext...get("id");" into the constructor
    of my DetailsBackingBean - and was able to obtain the ID and perform the
    lookup. The same would happen with approach 2 outlined in your wiki
    article.

    However, this works only once: whenever the DetailsBackingBean is
    constructed. This scope of this bean is set to session because when i set
    it to request, the button "back to the menu" doesn't work anymore (no idea
    why). That button only calls a method in the DetailsBackingBean which
    return the action "menu". Works if the scope is session, throws an
    exception when scope is request.

    I figured that the "session" scope would make sense because if I am not
    mistaken that means that those classes are instantiated once for each user
    session, right?

    So either I debug my application so the scope can be set to "request" or I
    need to implement the "details lookup query" in the MenuBackingBean which
    then updates the attributes of the DetailsBackingBean. Are those really my
    only options? Especially the latter one sounds "ugly".

    Any idea?

    thanks

    Matt



    Am Mo, 22.05.2006, 17:15, schrieb Matthias Wessendorf:
    Hi Matthias :-)


    You should read [1].


    I prefere the usage of updateActionListener


    -Matthias


    [1]
    http://wiki.apache.org/myfaces/ExecutingMethodsFromLinkButtonParameters

    On 5/22/06, Matthias Klein wrote:

    Hi everyone


    I have a small JSF application with two pages: menu.jsp and details.jsp


    The menu.jsp contains something like this in a dataTable:


    <h:form>
    <h:commandLink action="#{MenuBackingBean.userClick}" >
    <h:outputText value="#{menuTabItem.itemName}" />
    <f:param name="itemID" value="#{menuTabItem.itemID}" />
    </h:commandLink>
    </h:form>


    Depending on the itemID, the method userClick() returns "menu" or
    "details" (if the return value is "menu", there is a sub-menu to be
    displayed. if the return value is "display", there is no more sub-menu
    but details of an actual item to be displayed) Those actions "menu" and
    "details" are obviously associated with navigation rules of the
    faces-config.

    But here is my question:
    If userClick() wants to return "details", I want it to pass the itemID
    to the DetailsBackingBean first (before the statement return "details";)


    How do I do that? The DetailsBackingBean is supposed to take this
    itemID and look up the details data associated with this itemID before
    it displays the details.jsp

    How can that be done?
    Is that even the right way to go?




    --
    Matthias Wessendorf
    Aechterhoek 18
    48282 Emsdetten
    http://jroller.com/page/mwessendorf
    mwessendorf-at-gmail-dot-com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriesmyfaces
postedMay 22, '06 at 3:12p
activeMay 22, '06 at 3:56p
posts3
users2
websitemyfaces.apache.org

People

Translate

site design / logo © 2018 Grokbase