MissBrucoMela
asked on
ActionErrors + return message
In my Action class execute method, I save an field from the user's form (login.jsp), if for any reason there is a problem such as a empty field or no valid field I want to report details back to the user so they can correct .
Something like
ActionErrors errors = new ActionErrors();
if ((campo2 == null) || (campo2.length() < 1))
errors.add("campo2", new ActionError("error.campo2. required") );
if (!errors.empty())
{
return mapping.findForward("failu re");
}
In user's form (login.jsp) I have the follow code:
<html:text property="campo2" value=""/>
<html:errors property="campo2"/>
In the bundle resource I have :
error.campo2.required=Camp o2 obbligatorio
In the struts-config.xml , I have :
<action path="/login" type="com.srl.SomeAction" name="loginForm" parameter="method" scope="request" >
<forward name="success" path="/pages/resultPage.js p"/>
<forward name="failure" path="/pages/login.jsp"/>
</action>
Something like
ActionErrors errors = new ActionErrors();
if ((campo2 == null) || (campo2.length() < 1))
errors.add("campo2", new ActionError("error.campo2.
if (!errors.empty())
{
return mapping.findForward("failu
}
In user's form (login.jsp) I have the follow code:
<html:text property="campo2" value=""/>
<html:errors property="campo2"/>
In the bundle resource I have :
error.campo2.required=Camp
In the struts-config.xml , I have :
<action path="/login" type="com.srl.SomeAction" name="loginForm" parameter="method" scope="request" >
<forward name="success" path="/pages/resultPage.js
<forward name="failure" path="/pages/login.jsp"/>
</action>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Happens nothing. No error message. What can I do?
ASKER