This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Software Teaming: A Mob Programming, Whole-Team Approach and have Woody Zuill and Kevin Meadows on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

relation between backing beans

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have form which takes user name and password and populates it into a backing 'LoginBean'


On press of button "Login" another class LoginHandler is supposed to do processing on the instance of LoginBean.
It has a property to accept the 'LoginBean' instance:

How do I populate userInfo in LoginHandler class. Is it via <f:parm> tag in <h:commandButton> in the form or some other way?

soory if it is a noob question, I am just starting out with JSF.

 
Ranch Hand
Posts: 101
Spring Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi - Is "loginBean" declared as managed bean in faces config? In that case, once you click login button, name and password values are populated in the bean.
 
Manu dv
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shasi Mitra wrote:Hi - Is "loginBean" declared as managed bean in faces config? In that case, once you click login button, name and password values are populated in the bean.


Yes, it is. And name & password were getting populated properly. I was not sure what was the standard way to retrive the instance of LoginBean from the session inside LoginHandler.doAuthentication().

I asked around and found that the way to do that is via FacesContext.getCurrentInstance().getExternalContext().
I tried this and it's working now.

 
Shasi Mitra
Ranch Hand
Posts: 101
Spring Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use this instead

<managed-bean>
<managed-bean-name>loginHandler </managed-bean-name>
<managed-bean-class>com.LoginHandler</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>loginBean</property-name>
<value>#{loginBean}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>LoginBean</managed-bean-name>
<managed-bean-class>com.LoginBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
Now you put setter for loginbean in your loginhandler and you can access it..When the instance of loginhanlder is created, login bean is injected to the loginhandler.
 
Manu dv
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Sashi. <managed-property> is the kind of thing I was looking for.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic