Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: Newbie having trouble with validation... doesn't seem to do anything...

Peter L. Berghold

2006-12-29

Replies:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Laurie Harper wrote:
>
> Getting all the pieces lined up can be a bit tricky the first time
> through :-( If the comments above don't get you there, post your form
> bean code and JSP so we have the complete picture.
>
>

OK.. I've gotten much further thanks to you Laurie, now I'm not seeing
the error messages that I expect.

Looks to me like the MyEclipse IDE doesn't create the form beans
correctly, I'll have to watch that.

Here is my JSP code:


- ------------ 8< snip 8<--------------------------------

<%@(protected)"%>
<%@(protected)"%>
<%@(protected)"%>
<%@(protected)"%>
<%@(protected)"%>





<html:form action="/actions/public/system/sendEmail" method="POST">
 <p>
   Use this form to send an email. All fields are considered mandatory.
   Email addresses will be checked for validity.
 </p>
 <p>
   Please be sure to include your real name in the body of the message to
   avoid confusion on the part of the email recipient
 </p>
 <p>
   <font size="+1" color="red"><html:errors /> </font>

 </p>
 <hr>
 <table width="100%">
   <tr height="30">
     <td width="30%" align="right">
       From:
       <br>
       (Your email address)
     </td>
     <td>
       <html:text property="from_rq" size="40" maxlength="80" />
       <br>
       <html:errors property="from_rq" />
     </td>
   </tr>
   <tr height="30">
     <td width="30%" align="right">
       Subject:
     </td>
     <td>
       <html:text property="subject_rq" size="40" maxlength="72" />
       <br>
       <html:errors property="subject_rq" />
     </td>
   </tr>
   <tr>
     <td width="30%" align="right">
       Message body:
     </td>
     <td>
       <html:textarea property="body_rq" rows="10" cols="40" />
       <br>
       <html:errors property="body_rq" />
     </td>
   </tr>
   <tr>
     <td colspan="2">
       <table width="100%">
         <tr>
           <td width="33%">
             <html:cancel value="abort" property="action_rq" />
           </td>
           <td width="34%">
             &nbsp;
           </td>
           <td>
             <html:submit value="Send" property="action_rq"></html:submit>
           </td>
         </tr>
       </table>
     </td>
   </tr>
 </table>

</html:form>



- ------------ 8< snip 8<--------------------------------
In spite of my having the <html:error property=... /> stuff in there the
messages aren't showing up.

Given I have the validation.xml (here again):

- ------------ 8< snip 8<--------------------------------
<form name="sendEmailForm">
 <field property="from_rq" depends="required,email">
   <arg0 key="sendEmailForm.from_rq.diaplay_name"/>
 </field>
 <field property="subject_rq" depends="required">
   <arg0 key="sendEmailForm.subject_rq.display_name"/>
   
 </field>
 <field property="body_rq" depends="required">
   <arg0 key="sendEmailForm.body_rq.display_name"/>
 </field>
</form>
- ------------ 8< snip 8<--------------------------------

I figured all would be well. I can see by watching my debug output in
the tomcat log that the form validation is behaving now like you
predicted now that I've got the bean parented correctly.


- --
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Peter L. Berghold                         Peter@(protected)
"Those who fail to learn from history are condemned to repeat it."
AIM: redcowdawg     Yahoo IM: blue_cowdawg         ICQ: 11455958
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org

iD8DBQFFlZfVUM9/01RIhaARAnCpAJkBMGbC4urcArvtfE+fUGzGiELsXQCdEXrB
wZ8Gd4iqH1hEMlWTLur/n9s=
=iKQ/
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.