Reply To: Spring JSF with Pretty Faces

Splash Forums Rewrite Users Spring JSF with Pretty Faces Reply To: Spring JSF with Pretty Faces

#25623

kmraun
Participant

Please provide simple example for VaildateBy method

public class UserValidator implements Validator<UserSessionJ> {

@Override
public boolean isValid(Rewrite rwrt, EvaluationContext ec, UserSessionJ t) {

boolean isValid = false;

if(StringUtils.isNotBlank(t.getSessionId())){
if (t.getSessionId().equals(t.getToken())) {
System.out.println(“userValidator – true”);
return true;
}
}else{
System.out.println(“userValidator – false”);
}

return isValid;
}

}

java.lang.ClassCastException: java.lang.String cannot be cast to com.oaots.tool.bean.jsf.employee.UserSessionJ
at com.oaots.tool.web.jsf.validator.UserValidator.isValid(UserValidator.java:18)
at org.ocpsoft.rewrite.util.ValueHolderUtil.validates(ValueHolderUtil.java:50)
at org.ocpsoft.rewrite.faces.config.PhaseBinding.performHttp(PhaseBinding.java:129)
at org.ocpsoft.rewrite.servlet.config.HttpOperation.perform(HttpOperation.java:42)
at org.ocpsoft.rewrite.faces.config.PhaseOperation$1.performOperation(PhaseOperation.java:82)
at org.ocpsoft.rewrite.faces.RewritePhaseListener$1.performInSubflow(RewritePhaseListener.java:132)
at org.ocpsoft.rewrite.servlet.event.SubflowTask.perform(SubflowTask.java:61)

———————–
Next
————

users do not enter direct url like /example1/{session}/home.xhtml instead of /example1/home.xhtml. How to validate?

if user go to /example1/home.xhtml this way automatically session logout and then redirect to login page.

How to show the error to user using ValidateBy or match cases