java - Error handling of a Custom Form Handler in ATG -



java - Error handling of a Custom Form Handler in ATG -

i new atg. , trying utilize repositoryformhandler of own. not able validations on form.

here .java file:

public class myloginbean extends repositoryformhandler { private string logname; private string logpwd; private string message; public string getlogname() { homecoming logname; } public void setlogname(string logname) { this.logname = logname; } public string getlogpwd() { homecoming logpwd; } public void setlogpwd(string logpwd) { this.logpwd = logpwd; } public string getmessage() { homecoming message; } public void setmessage(string message) { this.message = message; } public boolean handlelogname(dynamohttpservletrequest prequest, dynamohttpservletresponse presponse) throws servletexception, ioexception { boolean tf=true; if(logname.isempty() || logname==null) { tf=false; setmessage("user name can't empty"); } system.out.println("inside logname"); homecoming tf; } public void handleformexception(dropletformexception exception, dynamohttpservletrequest request, dynamohttpservletresponse response) { // todo auto-generated method stub super.handleformexception(exception, request, response); } }

and here .jsp file:

<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ taglib uri="/dsptaglib" prefix="dsp" %> <dsp:importbean bean="/atg/dynamo/droplet/errormessageforeach"/> <dsp:importbean bean="/dynamusic/myloginbean"/> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>custom login</title> </head> <body> <dsp:form style="color:white"> <table style="background:#3b5998"> <tr> <td> <ul> <dsp:droplet name="errormessageforeach"> <dsp:param bean="myloginbean.formexceptions" name="exceptions"/> <dsp:oparam name="output"> <li> <dsp:valueof param="message"/> </li> </dsp:oparam> </dsp:droplet> </ul> </td> </tr> <tr> <td> user name: </td> <td> password: </td> </tr> <tr> <td> <dsp:input type="text" name="logname" bean="myloginbean.logname"> </dsp:input> </td> <td> <dsp:input type="password" name="logpwd" bean="myloginbean.logpwd"> </dsp:input> </td> <td> <dsp:input type="submit" bean="myloginbean.login"> </dsp:input> </td> </tr> </table> </dsp:form> </body> </html>

this i've tried far , still trying else. please suggest solution , tell me mistakes, if any, in code pasted here.

don't override handleformexception instead of using setmessage, utilize atg's built-in behavior. form handlers inherit vector of form exceptions genericformhandler superclass. add together error, use:

addformexception(new dropletexception("your error message"));

then, @ end of method, call:

return checkformredirect(getsuccessurl(), getfailurl(), prequest, presponse);

this checks if form exceptions have been added, , if so, redirects failurl, otherwise redirects successurl.

by convention, should name form handler *formhandler, illustration profileformhandler, billinginfoformhandler, paymentinfoformhandler etc.

hope helps. see http://docs.oracle.com/cd/e22630_01/platform.1002/apidoc/atg/droplet/genericformhandler.html#getformexceptions()

java atg

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -