below code can be used to get message from different applicatyion resource
files.

<bean:message key="sendEmailForm.body_rq.display_name"
bundle="<%=response.getLocale().getLanguage()%>" />

-----Original Message-----
From: Laurie Harper [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 03, 2007 4:03 AM
To: [email protected]
Subject: Re: Newbie having trouble with validation... doesn't seem to do
anything...


Mime-Version:  1.0
Content-Type:  text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding:  7bit

Do you get any output if you include a html:errors tag somewhere without
a 'properties' attribute? It could be that the unconventional property
naming is messing things up.

Can you display message resources using bean:message? For example, do
you get what you expect if you include <bean:message
property="sendEmailForm.body_rq.display_name"/> somewhere on your page?
That will tell you if Struts is finding your resource properties correctly.

L.

Peter L. Berghold wrote:
> -----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<--------------------------------
>
> <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
>
>
>
>
>
> <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                                     [EMAIL 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: [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