Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Trouble in calling a bean twice

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Bookmark Topic Watch Topic
  • New Topic