• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling a method during onload

 
Ganesh Rangan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i am new to JSF.

i have 2 JSP Pages and both of them share the same Managed bean.

For Eg.
EnterpriseLogin.jsp
UserLogin.jsp

Both share the same backing bean and managed bean. For enterprise login additional validations are required in the managed bean.
When the user navigates to UserLogin.jsp it should call userLogin(in managed bean) method during onload. Similarly onload of EnterpriseLogin.jsp it should call enterpriseLogin (in managed bean) method.

please suggest me how to achieve this functionality.

Currently i am using 2 different managed bean with common methods present in both of the classes.
For calling a method during onload, i am placing the method call in the constructor of the Managed bean.

thanks
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Ganesh Ra " welcome to Javaranch
please check your private messages.
 
Srini Mutpur
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create two methods for intialization for the each page in your backing bean like as mentioned below. And include your page specific validation code in these methods.

public String getInitEnterpriseLogin() and
public String getInitUserLogin()

And call these methods in your jsp at the begining of the page using hutputText.

<hutputText value="#{backingbean.initUserLogin}"/>
 
C Rakesh
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was also seeking the solution for similar issue.
It Works for me! Thanks!!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!