It doesn't need to.   The value is resolved during render time.

On 1/17/06, Garner, Shawn <[EMAIL PROTECTED]> wrote:
> Can you explain what this is actually doing?
> How does it know how to resolve ("#{param.linkPage}") after the page is
> rendered?
>
> Shawn
>
> -----Original Message-----
> From: Mike Kienenberger [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 17, 2006 10:57 AM
> To: MyFaces Discussion
> Subject: Re: Problem hardcoding commandLink action outcome
>
> Yes, you're trying to fight the technology.
>
> Just do this.
>
> public class YourBean
> {
>      public String getActionForLinkPage()
>      {
>          FacesContext facesContext = FacesContext.getCurrentInstance();
>          String action =
> (String)facesContext.getApplication().createValueBinding("#{param.linkPage}"
> ).getValue(facesContext);
>           return action;
>      }
> }
>
> <h:commandLink action="#{YourBean.actionForLinkPage}" value="#{linkText}"/>
>
>
> On 1/17/06, Garner, Shawn <[EMAIL PROTECTED]> wrote:
> > Damn, get an exception with f:attribute.  I thought that should work.
> >
> > To do <h:commandLink action="college"/> I would have to do a choose/when
> > condition checking the value of #{linkPage} which can have like 12
> different
> > values.  Seems like a messy solution to me.
> >
> > Shawn
> >
> > -----Original Message-----
> > From: Garner, Shawn
> > Sent: Tuesday, January 17, 2006 10:29 AM
> > To: 'MyFaces Discussion'
> > Subject: RE: Problem hardcoding commandLink action outcome
> >
> > How about using the f:attribute tag for name="action"?
> >
> > Shawn
> >
> > -----Original Message-----
> > From: Mike Kienenberger [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, January 17, 2006 10:21 AM
> > To: MyFaces Discussion
> > Subject: Re: Problem hardcoding commandLink action outcome
> >
> > You are correct.   It's trying to resolve it as a method binding.
> >
> > You need to either use
> >
> > <h:commandLink action="#{yourBean.yourMethodReturningCollegeAsAString}"/>
> >
> > or
> >
> > <h:commandLink action="college"/>
> >
> > The attribute "action" takes only a string literal or a method binding
> > that returns a String.  It does not take a value binding that
> > evaluates to a String.  So if you need the action target to be
> > variable, you need to write java code to perform this logic.
> > Possibly you could use some kind of JSP EL expression instead of a JSF
> > EL expression, but I wouldn't recommend this approach.
> >
> > On 1/17/06, Garner, Shawn <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > >
> > > I'm trying to hardcode the action to "college" which is in the linkPage
> > > request scope variable.
> > >
> > > I think it's trying to resolve it as a bean action or something instead
> of
> > > an outcome.
> > >
> > > Can somebody help me with how to do this.
> > >
> > >
> > >
> > > linkPage: <h:outputText value="#{linkPage}"/><br>
> > >
> > > <h:commandLink action="#{linkPage}" value="#{linkText}"/>
> > >
> > >
> > >
> > > This prints out:
> > >
> > >
> > >
> > > linkPage: college
> > >  Modify Your Answer
> > >
> > >
> > >
> > >
> > >
> > > I want it to resolve as if I put in <h:commandLink action="college"
> > > value="Modify Your Answer"/>
> > >
> > >
> > >
> > > However when I click on the link I get: javax.faces.FacesException:
> Error
> > > calling action method of component with id _id1:_id15
> > >         at
> > >
> >
> org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListen
> > erImpl.java:74)
> > >         at
> > > javax.faces.component.UICommand.broadcast(UICommand.java:106)
> > >         at
> > > javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
> > >         at
> > > javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
> > >         at
> > >
> >
> org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.j
> > ava:316)
> > >         at
> > >
> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
> > >         at
> > > javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
> > >         at
> > > jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
> > >         at
> > > jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
> > >         at
> > >
> jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:259)
> > >         at
> > >
> jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
> > >         at
> > > jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
> > >         at
> > >
> >
> jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428
> > )
> > >         at
> > > jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
> > > Caused by: javax.faces.el.ReferenceSyntaxException:
> > > Expression not a valid method binding: #{linkPage}
> > >         at
> > >
> >
> org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(MethodBindi
> > ngImpl.java:186)
> > >         at
> > >
> org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:114)
> > >         at
> > >
> >
> org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListen
> > erImpl.java:63)
> > >         ... 13 more
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Shawn D. Garner
> > >
> > > Software Developer
> > >
> > > CASD EAI I
> > >
> > > Internet Development
> > >
> > >
> > >
> > > Email:  [EMAIL PROTECTED]
> > >
> > > Work:  (319) 665-7796
> > >
> > > Cell:  (319) 480-4409
> > >
> > >
> > >
> > > Pearson Government Solutions
> > >
> > > 2450 Oakdale Blvd
> > >
> > > Coralville, IA 52241
> > >
> > >
> > >
> > >
> >
> ****************************************************************************
> > >
> > > This email may contain confidential
> > > material. If you were not an intended recipient,
> > > Please notify the sender and delete all copies.
> > > We may monitor email to and from our network.
> > >
> > >
> >
> ***************************************************************************
> > >
> >
> >
> ****************************************************************************
> >
> > This email may contain confidential material.
> > If you were not an intended recipient,
> > Please notify the sender and delete all copies.
> > We may monitor email to and from our network.
> >
> ****************************************************************************
> >
> >
> ****************************************************************************
> > This email may contain confidential material.
> > If you were not an intended recipient,
> > Please notify the sender and delete all copies.
> > We may monitor email to and from our network.
> >
> ****************************************************************************
> >
>
> ****************************************************************************
> This email may contain confidential material.
> If you were not an intended recipient,
> Please notify the sender and delete all copies.
> We may monitor email to and from our network.
> ****************************************************************************
>

Reply via email to