File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Validation framework not working for multiple selections!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validation framework not working for multiple selections!!" Watch "Validation framework not working for multiple selections!!" New topic
Author

Validation framework not working for multiple selections!!

Krishnappan Muthuraman
Greenhorn

Joined: Feb 16, 2004
Posts: 21
I am using struts and the ValidatorPlugIn. I am having some issues trying to validate input for an options box. I have the validation working correctly if within the struts-config.xml file the form-property type="java.lang.String" (I can validate the form-property value in the example listed below).

My issue is that I can't validate when the form-property is of type="java.lang.String[]" (I can't validate the form-property assets in the example listed below). Do I need to include something in the validation.xml that indicates I am working with type="java.lang.String[]"

ca_search.jsp (snippets):

<html:form action="/caSearch" target="main" onsubmit="return validateCaSearchForm(this);">

<html:select size="3" property="assets" style="news" multiple="true">
<html ptions collection="assetTypes" property="property" labelProperty="labelProperty"/>
</html:select>

<html:javascript formName="caSearchForm"/>


struts-config.xml:

<form-bean name="caSearchForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="assets" type="java.lang.String[]" />
<form-property name="value" type="java.lang.String" />
<form-property name="sites" type="java.lang.String" />
<form-property name="searchFor" type="java.lang.String" />
<form-property name="sortBy" type="java.lang.String" />
<form-property name="departments" type="java.lang.String" />
<form-property name="action" type="java.lang.String" />
</form-bean>


validation.xml:

<form name="caSearchForm">
<field property="value" depends="required">
<arg0 key="ca_search.val"/>
</field>
<field property="assets" depends="required">
<arg0 key="ca_search.assets"/>
</field>
</form>


Again, I have the validation working correctly when form-property is of type="java.lang.String". I can't however validate when the form-property is of type="java.lang.String[]".
 
 
subject: Validation framework not working for multiple selections!!
 
Similar Threads
server side validation errors
Struts Validation of options box (java.lang.String[])
What Are the Causes for Validation Not Doing Anything?
Why My Validation Lets All Errors Pass Through?
Struts Validator With Modules