I have a simple application in JSF2.0 . Where I have created a ManagedBean in Session scope .In this managed bean I have stored a property.But when I tried to access that property from a jsp it is not getting retrieved.I am storing the value of roleType. Here is the method inside the ManagedBean
public class LoginBean {
private String userID;
private List<String> roleNames;
private String roleType;
public String getUserID() {
return userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
public List<String> getRoleNames() {
return roleNames;
}
public void setRoleNames(List<String> roleNames) {
this.roleNames = roleNames;
}
public String getRoleType() {
return roleType;
}
public void setRoleType(String roleType) {
this.roleType = roleType;
}
public String createAuth() throws SQLException
{
Authorisation authCall=com.validation.client.authorization.concern.AuthorisationCall.createAuthorisation(userID);
if(authCall.getUserRoles()==null || authCall.getUserRoles().size()<=0){
return "login";
}
List<String> roleNameList=new ArrayList<String>();
Iterator itr =authCall.getUserRoles().iterator();
String roleType=null;
while (itr.hasNext()){
UserRole userRole=(UserRole)itr.next();
roleNameList.add(userRole.getRoleName());
roleType=userRole.getRoleDescription();
}
setRoleNames(roleNameList);
setRoleType(roleType);
}
}
The jsp page where I am retrieving the property is :
<c:if test="${loginBean.roleType=='APPROVER'}">
<h:outputText value="loginBean.roleType"/>
<c:if>
In faces-config.xml I have done this to register the bean
<managed-bean>
<description>temporary authentication</description>
<managed-bean-name>loginBean</managed-bean-name>
<managed-bean-class>com.validation.client.authorization.concern.LoginBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
This is my first attempt in JSF and am really stuck with this.