You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Peter L. Berghold" <Pe...@berghold.net> on 2007/03/05 04:40:12 UTC
ApplicationResource.properties file not be read?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi folks,
I've asked this question before, didn't get an answer but I had moved on
to other things but I'm back tackling this burp.
I have a message resource file that is stored under
<WEBROOT>/WEB-INF/classes/org/bcdc/struts/ApplicationResource.properties
I am referencing that file in my struts-config.xml file as such:
<message-resources parameter="org.bcdc.struts.ApplicationResources" />
Yet, wherever I'm referencing these message resources the entries seem
to be being ignored. Most of where I'm using these resources are in the
validation infrastructure.
Any thoughts as to where to begin?
- --
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Peter L. Berghold Peter@Berghold.Net
"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
iD8DBQFF65EbUM9/01RIhaARAi3SAKCHhlybdlWNx4k65DYhY0O44OLxswCgjwUL
B5L07TCe+wDb2lptuM0J5Zg=
=EYh2
-----END PGP SIGNATURE-----
Lack of Validator Messages SOLVED!!! ( was Re: ApplicationResource.properties
file not be read?)
Posted by "Peter L. Berghold" <Pe...@berghold.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
OK... I figured it out. In all the text I was reading on the topic as I
was going along I totally missed the fact that there is a catalog of
messages that is **required** for the validator to work:
To wit:
errors.required={0} is required.
errors.minlength={0} cannot be less than {1} characters.
errors.maxlength={0} cannot be greater than {2} characters.
errors.invalid={0} is invalid.
errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.0. errors.float={0} must be a float.
errors.double={0} must be a double.
errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is not a valid credit card number.
errors.email={0} is an invalid e-mail address.
Once I added those to my ApplicationResources file all was happy.
On to the next thing!
Thanks everybody for being patient with me!
- --
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Peter L. Berghold Peter@Berghold.Net
"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
iD8DBQFF7KU0UM9/01RIhaARAlqFAJwMiQMg9s4dnZ7zz0d1wQr5rjtj3wCgnOfX
1nrF7Vji3+kiLfoc5qc4K6A=
=r1U9
-----END PGP SIGNATURE-----
Re: ApplicationResource.properties file not be read?
Posted by "Peter L. Berghold" <Pe...@berghold.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Just a quick follow up to clarify what I'm "seeing." When I invoke this
form, hit submit without filling anything in (in my eyes a worst case
scenario) a popup window comes up with an exclamation point with no
messages in it.
- --
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Peter L. Berghold Peter@Berghold.Net
"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
iD8DBQFF7KE/UM9/01RIhaARAk1LAJ98sX/T1KEAQLqwhECuVc7DoOIJlACgjcCZ
Fna6Z6uti741qyOeVaygAjo=
=F32N
-----END PGP SIGNATURE-----
Re: ApplicationResource.properties file not be read?
Posted by "Peter L. Berghold" <Pe...@berghold.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Laurie Harper wrote:
>
> If that's the case, you probably just have an error in your validation
> configuration. Post the relevant parts of that for review.
>
>
OK.. here goes:
I'll use the simplest of the forms and work from there. The JSP for a
form that is used to send email.
- -------------- 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"
onsubmit="return validateSendEmailForm(this);">
<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 style="border: 1px; color: red; ">
<html:errors />
</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="label.from" />
</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="label.subject" />
</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%">
</td>
<td>
<html:submit value="Send" property="action_rq"></html:submit>
</td>
</tr>
</table>
</td>
</tr>
</table>
<html:javascript formName="sendEmailForm"/>
</html:form>
- -------------- 8< snip 8<-------------------------------------------
It's definition in tiles-defs.xml
- -------------- 8< snip 8<-------------------------------------------
<definition name=".public.email.send" extends=".public.layout">
<put name="content" value="/content-pages/public/sendEmail.jsp" />
<put name="title"
value="Bayshore Companion Dog Club:Send Email" />
</definition>
- -------------- 8< snip 8<-------------------------------------------
Here are the entries in struts-config.xml that make use of it:
- -------------- 8< snip 8<-------------------------------------------
<form-bean name="sendEmailForm"
type="org.bcdc.struts.form.SendEmailForm" />
<... and later ...>
<action path="/actions/public/sendEmail"
forward=".public.email.send" />
<... a few lines later...>
<action attribute="sendEmailForm"
input=".public.email.send"
name="sendEmailForm"
path="/actions/public/system/sendEmail"
scope="request"
validate="yes"
type="org.bcdc.struts.action.SendEmailAction">
<forward name="class_detail"
path="/actions/public/class/detail.do" />
<forward name="failure" path="/actions/public/sendEmail.do" />
</action>
- -------------- 8< snip 8<-------------------------------------------
and here is the validation rule for the form.
- -------------- 8< snip 8<-------------------------------------------
<form name="sendEmailForm">
<field property="from_rq" depends="required,email">
<arg key="label.from"/>
</field>
<field property="subject_rq" depends="required">
<arg key="label.subject"/>
</field>
<field property="body_rq" depends="required">
<arg0 key="label.body"/>
</field>
</form>
- -------------- 8< snip 8<-------------------------------------------
The form bean is defined an extension of a ValidatorForm. Just to try
and get things working I went the path of using JavaScript client side
validation, but my goal is to move that to server side eventually.
- --
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Peter L. Berghold Peter@Berghold.Net
"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
iD8DBQFF7J+4UM9/01RIhaARAmmwAJ9IUTDMdv/U2H3d1Pivzd7seX/3zACbBols
mvkVjB3pRgZdqao+htkYBNo=
=1QH3
-----END PGP SIGNATURE-----
Re: ApplicationResource.properties file not be read?
Posted by Laurie Harper <la...@holoweb.net>.
Peter L. Berghold wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Niall Pemberton wrote:
>> It should work - is this exactly how you have things configured -
>> because theres a slight difference in names below - one has an "s" on
>> the end.
>>
>>
>
> eh... yeah.. the lack of "s" was the typo. They are actually the same
> name.
>
> OBTW: if I do a <bean:message key="some.key"/> does work for that
> resource file. It doesn't seem to work for validation though...
Just to be clear: you *can* dereference your l10n properties using
bean:message? If so, the resource bundle(s) are being loaded correctly
and your problem is to do with referencing them for validation.
If that's the case, you probably just have an error in your validation
configuration. Post the relevant parts of that for review.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: ApplicationResource.properties file not be read?
Posted by "Peter L. Berghold" <Pe...@berghold.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Niall Pemberton wrote:
> It should work - is this exactly how you have things configured -
> because theres a slight difference in names below - one has an "s" on
> the end.
>
>
eh... yeah.. the lack of "s" was the typo. They are actually the same
name.
OBTW: if I do a <bean:message key="some.key"/> does work for that
resource file. It doesn't seem to work for validation though...
- --
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Peter L. Berghold Peter@Berghold.Net
"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
iD8DBQFF65qyUM9/01RIhaARAhkCAKCMLClk+WannFXci95alw9l1Z7c3wCdGhol
kzVpiDOE/FVpTGuLzj0ce68=
=2M8I
-----END PGP SIGNATURE-----
Re: ApplicationResource.properties file not be read?
Posted by Niall Pemberton <ni...@gmail.com>.
It should work - is this exactly how you have things configured -
because theres a slight difference in names below - one has an "s" on
the end.
Niall
On 3/5/07, Peter L. Berghold <Pe...@berghold.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi folks,
>
> I've asked this question before, didn't get an answer but I had moved on
> to other things but I'm back tackling this burp.
>
> I have a message resource file that is stored under
>
> <WEBROOT>/WEB-INF/classes/org/bcdc/struts/ApplicationResource.properties
>
> I am referencing that file in my struts-config.xml file as such:
>
> <message-resources parameter="org.bcdc.struts.ApplicationResources" />
>
> Yet, wherever I'm referencing these message resources the entries seem
> to be being ignored. Most of where I'm using these resources are in the
> validation infrastructure.
>
> Any thoughts as to where to begin?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org