incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Winer" <awi...@gmail.com>
Subject Re: Action attribute of tr:commandNavigationItem ignored
Date Tue, 26 Dec 2006 17:43:05 GMT
You cannot use a getter for "action".  That isn't how it works.
The method *is* the action.  You cannot do:

  public MethodBinding getAction()

... you must do:

  public String action()

... which could be implemented along the lines of:

  public String action()
  {
    MethodBinding action = getAction();
    if (action == null) return null;

    FacesContext context = FacesContext.getCurrentInstance();
    Object retVal = action.invoke(context, null);
    if (retVal == null)
      return null;
    return retVal.toString();
  }

-- Adam


On 12/26/06, Chris Hansen <chansen@overstock.com> wrote:
> I should have specified, but the getter for menuItem.action returns a
> javax.faces.el.MethodBinding . Are you saying that no action can be bound to
> a getter that returns a MethodBinding?
>
> --
> Chris Hansen
> Overstock.com
> Internal Applications
> 6350 South 3000 East
> Salt Lake City, Utah 84121
> Toll Free: 800.The.Big.O (843-2446)
> www.overstock.com
>
>
> On 12/22/06 6:22 PM, "Adam Winer" <awiner@gmail.com> wrote:
>
> > Chris,
> >
> > "action" is not going to go to a bean getter.  It's going
> > to go to action method, e.g.:
> >
> >   action="#{item.action}"
> >
> > means you must have:
> >
> >   public String action()
> >
> > on your bean.  This is just like all other "action"
> > attributes in JSF.
> >
> > -- Adam
> >
> >
> > On 12/22/06, Chris Hansen <chansen@overstock.com> wrote:
> >> In the following code for a navigation menu, everything works except the
> >> action attribute of the tr:commandNavigationItem tag:
> >>
> >> <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
> >> xmlns:h="http://java.sun.com/jsf/html"
> >>
> >> xmlns:f="http://java.sun.com/jsf/core"
> >> xmlns:tr="http://myfaces.apache.org/trinidad">
> >>   <tr:form>
> >>     <tr:navigationPane var="menuItem" value="#{menuModel.model}"
> >> hint="list"
> >>       inlineStyle="margin-left:-20px;margin-top:-15px;">
> >>       <!-- For some reason text will not be displayed if there is not
> >> another element in the tr:navigationPane besides the nodeStamp facet-->
> >>       <tr:group></tr:group>
> >>       <f:facet name="nodeStamp">
> >>         <tr:commandNavigationItem action="#{menuItem.action}"
> >>
> >> disabled="#{menuItem.disabled}" text="#{menuItem.label}"
> >>
> >> destination="#{menuItem.destination}" rendered="#{menuItem.shown}"
> >>
> >> selected="#{menuItem.viewId == view.viewId}" immediate="true" />
> >>       </f:facet>
> >>     </tr:navigationPane>
> >>   </tr:form>
> >> </ui:composition>
> >>
> >>
> >>
> >> The getter for menuItem.action is never called, while all of the other
> >> getters are being called (menuItem.destination, menuItem.label, etc.). I
> >> tried removing the destination=... attribute with no success.
> >>
> >> What is the key to using an action on a commandNavigationItem, and what am I
> >> missing?
> >>
> >> Thanks.
> >> --
> >> Chris Hansen
> >> Overstock.com
> >> Internal Applications
> >> 6350 South 3000 East
> >> Salt Lake City, Utah 84121
> >> Toll Free: 800.The.Big.O (843-2446)
> >> www.overstock.com
> >>
> >>
>
>

Mime
View raw message