aspose file tools*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: multiple resource bundles and validation.xml on struts 1.1