This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Struts and the fly likes multiple resource bundles and validation.xml on struts 1.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "multiple resource bundles and validation.xml on struts 1.1" Watch "multiple resource bundles and validation.xml on struts 1.1" New topic
Author

multiple resource bundles and validation.xml on struts 1.1

Eduardo Plata
Greenhorn

Joined: Nov 19, 2004
Posts: 17
Hi, I'm trying to display a error message using xml struts plugin validator that it's on another resource bundle, but the key doesn't get the value. I have this:

On strtus-config.xml
<CODE>
...
<form-bean name="myForm" type="com.i2b.sged.struts.MyActionForm" />
...
<action input="/jsp/lajsp.jsp" name="myForm" path="/myAction" scope="request" type="com.i2b.sged.struts.MyAction" validate="true">
<forward name="success" path="/jsp/lasalida.jsp" />
</action>
...
<message-resources parameter="resources.sged"/>
<message-resources key="prueba" parameter="resources.prueba"/>
</CODE>
On my ActionForm
<CODE>
public ActionErrors validate(ActionMapping actionMapping,
HttpServletRequest httpServletRequest) {

ActionErrors messages = super.validate(actionMapping,httpServletRequest);
MessageResources bundle = MessageResources.getMessageResources("resources.prueba");
String mensaje = bundle.getMessage("prueba.campo2"); // -> this works fine
if (messages == null)
messages = new ActionErrors();
if ("another validation ....")
messages.add("prueba.campo2",new ActionMessage("errors.required",mensaje));
return messages;
}
</CODE>
and at last, on my validation.xm
<CODE>
<formset>
<!-- An example form -->
<form name="myForm">
<field
property="campo1"
depends="required">
<arg position="0" key="prueba.test" bundle="prueba"/>
</field>
</form>
</formset>
</CODE>

now, when the submit fails on validation the resource bundle "prueba" is not found and the mesagge displayed is only: " is required"

Thanks in advance
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: multiple resource bundles and validation.xml on struts 1.1
 
It's not a secret anymore!