Results 1 to 3 of 3
  1. #1
    tronied is offline Member
    Join Date
    Mar 2011
    Rep Power

    Default JSF reference to backing bean

    Firstly, this question is a bit specific and therefore I didn't know what to search on. Apologies if this exists somewhere else, but there are too many broad questions and answers to search through.

    I am very much a beginner at J2EE and JSF and am working my way through the (very long) J2ee tutorial. My question is, is it possible when using JSF to have a component linking to a backing bean that can be referenced in a link in the same page? For example:

    Java Code:
    <h:outputLabel value="Username:" /><h:inputText id="username" value="[B]#{user.username}[/B]" />
    <a href="/MessageBoard/resources/authorize/[B]#{user.username}[/B]">Say Hello</a>
    If I wanted to pass the username text fields value in a link (to a RESTful service) on the same page referencing the backing beans value, when I try it returns null. I am guessing this is because it is server side, and I need to post it first? I have tried immediate and deferred referencing e.g. ${ and #{ but neither seem to work. I am guessing the value doesn't get set against the backing bean, until the page has been submitted? If I point the link to another page, and reference the scoped bean then I can get the value.

    These are mostly learning questions, so apologies if they seem a bit stupid. I guess everyone had to start somewhere though :)

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Rep Power


    Submit to an action on the backing bean and call the service from there instead.
    That way you can take advantage of JSF's own parameter passing mechanism while keeping all action logic in the action methods.
    Java Code:
    <h:commandLink id="someId" action="#{myHandler.serviceCaller}">  
          <f:param id="someParamId" name="username" value="#{user.username}"/>  
          <h:outputText value="Say Hello" />  

  3. #3
    tronied is offline Member
    Join Date
    Mar 2011
    Rep Power

Similar Threads

  1. Call an url from a backing using post
    By kaamos in forum JavaServer Faces (JSF)
    Replies: 6
    Last Post: 04-27-2010, 05:19 PM
  2. Backing Up Mysql
    By Robert_85 in forum JDBC
    Replies: 3
    Last Post: 04-04-2009, 05:34 PM
  3. UREGENT-accessing session bean ok but entity bean
    By parimal in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 08-28-2008, 02:34 PM
  4. Replies: 0
    Last Post: 03-30-2008, 11:03 AM
  5. Replies: 0
    Last Post: 09-26-2007, 09:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts