Hi there,

after working on this for two days, I still didn't figure out how to do this...

(Just for the record, I'm on Struts 1.2.7)

I still can't display two errors bundle on the same jsp page. My jsp includes :

<html:errors bundle="org.apache.struts.action.MESSAGE" />
<html:errors bundle="ValidationProgramme" />

and my struts-config.xml includes :

<message-resources key="org.apache.struts.action.MESSAGE" 
parameter="ca.uquebec.sid.trousse.mvc.parameters.MessageResources" null="false" 
/>
        
<message-resources key="ValidationProgramme" 
parameter="ca.uquebec.sid.utils.ValidationProgramme" null="false" />

and I still get only the messages from the org.apache.struts.action.MESSAGE 
bundle. The messages comming from the ValidationProgramme bundle are displayed 
as ???[name]??? which means that they cannot be found in the bundles.

Is it possible that those ???[name]??? are comming from my first html:error tag 
and that the second is not interpreted at all ??


[Added later to the message...]

Seems like I can't even display the messages from the ValidationProgramme 
bundle after all. I kept only one message ressource, ValidationProgramme, in my 
struts-config.xml and only included the <html:error key="ValidationProgramme" 
/> tag. I get the error sayint that no message ressources were found in the 
org.apache.struts.action.MESSAGES.

Why can't I define my own message bundles and keys ???



____________________________
Luc Boudreau
SID - Université du Québec
[EMAIL PROTECTED]
 
-----Message d'origine-----
De : Niall Pemberton [mailto:[EMAIL PROTECTED] 
Envoyé : 4 octobre 2005 12:28
À : Struts Users Mailing List
Objet : Re: Question about validator and multiple message ressources

OK, you still don't say what version of Struts you're using? I'll assume
Struts 1.2.7

As Martin pointed out, you can't use the same key when defining the
<message-resources> in your struts config. Struts uses that key (with a
prefix) to store the MessageResources in the ServletContext - so if you use
the same key, then the second <message-resources> will just overwite the
first in the ServletContext - effectively loosing the first set for good.

Say you define your message resources as follows:

<message-resources
parameter="ca.uquebec.sid.trousse.mvc.parameters.MessageResources"null="fals
e" />
<message-resources key="myValidations"
parameter="ca.uquebec.sid.utils.ValidationProgramme" null="false" />

You'll notice that there is no "key" specifed the the first message
resources - they are effectively the "default" message resources. To display
error messages from the first bundle in your JSP using the html:errors tag
then you can just specify <html:errors/> - to display messages from the
second resource bundle, then you would need to use the bundle attribute -
something like <html:errors bundle="myValidations"/> - alternatively you can
do a similar thing with the <html:messages> tag.

I out some info here a while ago that may help...

http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html

Niall


----- Original Message ----- 
From: <[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Tuesday, October 04, 2005 4:54 PM
Subject: RE: Question about validator and multiple message ressources


The validations that I included in my validation class are custom made and
are using an Oracle connection to perform complicated validations which are
stored in a Validation Servlet. I'm not using the standard validations that
comes with Struts.

My validation Servlet instanciates a generalised validation class which
posses it's own message ressources and when I launch a validation, it
returns null if it's valid or throws an exception containing a message key
if an error is encountered. This message key is then added to the validator
framework's errors to display via :

catch (ValidationException exception)
{
errors.add(field.getKey(), new ActionMessage(exception.getMessage()));
}

I can only access one message ressource from my struts-config.xml and it's
either the last one I've defined using the org.apache.struts.action.MESSAGE
key for both or no one at all if I define any other key for both.



____________________________
Luc Boudreau
SID - Université du Québec
[EMAIL PROTECTED]


-----Message d'origine-----
De : Niall Pemberton [mailto:[EMAIL PROTECTED]
Envoyé : 4 octobre 2005 11:30
À : Struts Users Mailing List
Objet : Re: Question about validator and multiple message ressources

What version of Struts are you using? If its Struts 1.2.7, then it is
possible to do this - Commons Validator 1.1.4 had "bundle" and "resource"
attributes added which enable you to specify alternate resource bundles. If
you look at Strut's FieldChecks class, which contains all the standard
validators which do this.

Niall

----- Original Message ----- 
From: <[EMAIL PROTECTED]>
Sent: Tuesday, October 04, 2005 4:09 PM


Well, I've already tried to change the key of my message ressources but it
seems that it doesn't change anything.

Because I add errors from a validator plugin class, which is coded in java
inside my application, I cannot specify the key of my message ressource,
like if I was in the jsp page using the bean:write tag.

Is there any way to explicitly specify which ressource key to use when we
add error messages from a java class used by the validator framework ?

-----Message d'origine-----
De : Martin Gainty [mailto:[EMAIL PROTECTED]
Envoyé : 4 octobre 2005 10:54

Bonjour Luc-
the key characteristic (for message-resources) must be a unique identifier.
Right now they are the same (org.apache.struts.action.MESSAGE)
Bon Chance/HTH,
Martin-

----- Original Message ----- 
From: <[EMAIL PROTECTED]>
Sent: Tuesday, October 04, 2005 10:06 AM


Hi there,

I need to add multiple message ressources to an application and to access
them from a custom validation class created with the validator framework.

I've added the following in struts-config.xml :

--------------------------------------------------------------------------
<message-resources key="org.apache.struts.action.MESSAGE"
parameter="ca.uquebec.sid.trousse.mvc.parameters.MessageResources"
null="false" />

<message-resources key="org.apache.struts.action.MESSAGE"
parameter="ca.uquebec.sid.utils.ValidationProgramme" null="false" />
--------------------------------------------------------------------------

.. and my message is added with the following code :

--------------------------------------------------------------------------
errors.add(field.getKey(), new ActionMessage("Message.key"));
--------------------------------------------------------------------------

.. but my application can only find the messages located in the second
ressource.

How can I use both message ressources with the validator framework and
custom validation classes ??



---------------------------------------------------------------------
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