Link to home
Start Free TrialLog in
Avatar of MissBrucoMela
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("failure");
        }

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=Campo2 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.jsp"/>
       <forward name="failure" path="/pages/login.jsp"/>
    </action>
Avatar of MissBrucoMela
MissBrucoMela

ASKER

I forget...Don't work in this way
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Happens nothing. No error message. What can I do?