captcha - Using kaptcha with JSF -
I have a very easy way to'm trying to use that includes Captcha my demo app JSF and although For JSP, I do not know how to use them in JSF. I do not translate into how JSF
The management of operations presented in your code:
string kaptchaExpected = (string) request.getSession ( ) .getAttribute (com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY); String kaptchaReceived = request.getParameter ("kaptcha");
if (kaptchaReceived == null || kaptchaReceived.equalsIgnoreCase (kaptchaExpected)!) {SetError ( "kaptcha" "Invalid verification code."); }
I tried to put it in my:
public string button1_action () {// TODO: action process. Return "Success"; } but it does not understand the request object: (
this is equivalent JSF action should:
// bind & lt; b: inputText value = "# {thisbean.kaptchaReceived}" / & gt; private string kaptchaReceived; public string getKaptchaReceived ( ) {kaptchaReceived return;} public void setKaptchaReceived (string kaptcha) {kaptchaReceived = kaptcha;}! public string button1_action () {if (kaptchaReceived = nULL) {FacesContext reference = FacesContext .getCurrentInstance (); ExternalContext ext = context.getExternalContext () ; Map & lt; string, object & gt; ; Session = ext.getSessionMap (); string kaptchaExpected = season .Get (com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY); if (kaptchaReceived.equalsIgnoreCase (kaptchaExpected)) {return "success";}} return "problem" ;} It assumes that you use w ant and in your JSF view instead of HTML elements.
Comments
Post a Comment