Rosh,

1. Were any errors produced?  You never check.  Perhaps:
        (errors != null) && errors.size() > 0

2. Do you save the errors with a method such as saveMessages() /
saveErrors() ?   How are you going to get them to your html:form so you can
show them to the client with html:errors, html:messages, etc.

3. Do you go anywhere if you FIND errors?  No.  Your code snippet ALWAYS
returns to your "success" mapping.  If you find errors you might want to go
the "input" mapping or one of your own choosing.  I think the input mapping
might be jumped to by something like this:

return mapping.findForward(mapping.getInput());

I might have typed incorrectly but you can probably get the idea of what I
am suggesting from that code suggestion above.

4. Where in your example JSP do you show your errors if any occur?  See the
section from the html: taglib on html:errors at:
http://struts.apache.org/struts-action/struts-taglib/apidocs/org/apache/stru
ts/taglib/html/package-summary.html#doc.Other.errors
Though I thought it was html:messages now.  I must be using an older version
but the rest should apply.  *shrug*

Much of this is listed in Wendy's example.  I recommend you review it again
before you consider my suggestions so you can see how my suggestions mirror
much of what is shown in her examples.

Regards,
David

-----Original Message-----
From: mosho [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 27, 2006 5:18 PM
To: user@struts.apache.org
Subject: RE: Question about Struts validator



Thanks David and Wendy for your help but it doesn't seem to work.
I added manually validate in my execute method. It still validates if I
directly enter the url.

I am pasting part of my code for you to take a look and let me know where I
am going wrong. Thanks again!


--Struts config part--
<action path="/selState"
            type="com.sami.view.SelStateAction"
            name="selStateForm"
            scope="session"
            input=".selectState">
      <forward name="success" path=".indianLandInfo"/>
    </action>

---SelStateAction--
    SelStateForm sform = (SelStateForm) form;
       String isSubmitted = sform.getIsSubmitted();
       if(isSubmitted == "Yes" || isSubmitted.equalsIgnoreCase("Yes"))
       {
           ActionErrors errors = sform.validate( mapping, request );
       }

    return mapping.findForward("success");

---JSP file---

<html:form action="selState.do" method="POST" onsubmit="return
validateSelStateForm(this);">
 .....
.....
 <html:hidden property="isSubmitted" value="yes" />
</table>
<html:javascript formName="selStateForm" />
</html:form>
--
View this message in context:
http://www.nabble.com/Question-about-Struts-validator-tf1851247.html#a507421
7
Sent from the Struts - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to