• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
We're all out of roofs. But we still have tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic