wood burning stoves 2.0*
The moose likes JSF and the fly likes Trouble in calling a bean twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Trouble in calling a bean twice" Watch "Trouble in calling a bean twice" New topic
Author

Trouble in calling a bean twice

Amit Nair
Greenhorn

Joined: May 23, 2006
Posts: 16
Hi Team

I am having trouble in creating a correct way to login in my application. The problem is, if the user gives correct authentication in the first attempt then he is forwarded to the next page, on failure the same login page is shown. Now second time if the user gives correct username/password, the login doesn�t happen. Even the bean method is not called after the user hits submit.


The Login page is a simple JSP with two text field for user name & password .

<h:inputText id="userNameInput" value="#{authenticateAction.user.userName}" size="30" rendered="true" />

<h:inputSecret value="#{authenticateAction.user.password}" size="30" rendered="true" required="true" redisplay="false" id="password"/>

<h:commandLink id="login" action="#{authenticateAction.authenticate}">
<h:graphicImage id="loginGif" url="/images/trns_login_btn.gif" styleClass="greenbt" style="border-color: transparent; border-width: 0" />
</h:commandLink>


Code of bean
public class AuthenticateAction
{
private User user;

public AuthenticateAction() {
user = new User();
}
public String authenticate() {
// Code for authentication is done which return a User object

if (user != null) {
Map<String, User> sessionMap = context.getExternalContext().getSessionMap();
sessionMap.put("userLoggedIn", user);

return �SUCCESS�;
}
else
{
return �FAILURE�;
}
}
public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

}
In the faces-config.xml the navigation for Login page is defined, �SUCCESS� takes the user to the next page & failure takes him back to the same page.

Please let me have your valuable input.

Thanks in advance

Amit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble in calling a bean twice
 
Similar Threads
Strutsnewbie
How to create a secure login system?
Spring Security 2.0.4 .... Redirect user to original page after authentication success or failure
bean in JSP cannot be resolved
Getting Exception creating bean of class JSP Exception