D
Dave Kawczynski
Is the validator compatable with map-backed ActionForms?
I am having problems implementing the validator when the ActionForm
involved in the form submission is backed by a HashMap. Specifically,
the generated client-sided script does not contain any calls to
validation functions.
Any help would be greatly appreicated!
-dave
PROBLEM: for an ActionForm named testForm, the generated javascript
begins as follows:
function validateTestForm(form) {
if (bCancel)
return true;
else
return true;
}
Here are the associated components:
validator.xml:
<form name="mapBasedFormTest">
<field name="property(firstName)" depends="maxlength">
<arg0 key="errors.maxlength"/>
<arg1 key="test.firstname.displayname"/>
<arg2 name="maxlength" key="${var:maxlength}"
resource="false"/>
<var>
<var-name>maxlength</var-name>
<var-value>10</var-value>
</var>
</field>
<field name="property(lastName)" depends="maxlength">
<arg0 key="errors.maxlength"/>
<arg1 key="test.lastname.displayname"/>
<arg2 name="maxlength" key="${var:maxlength}"
resource="false"/>
<var>
<var-name>maxlength</var-name>
<var-value>50</var-value>
</var>
</field>
</form>
ActionForm:
import org.apache.struts.action.ActionForm;
import java.util.HashMap;
public class FormTest extends ActionForm
{
protected HashMap properties = new java.util.HashMap();
public void setProperty(String key, Object value)
{
this.properties.put(key, value);
}
public Object getProperty(String key)
{
return this.properties.get(key);
}
}
test.jsp:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html>
<body>
<html:form action="/test">
<bean:message key="test.firstname.displayname"/>
<html:text property="property(firstName)"/>
<br/>
<bean:message key="test.lastname.displayname"/>
<html:text property="property(lastName)"/>
<html:submit/>
</html:form>
<html:javascript formName="mapBasedFormTest"/>
</body>
</html>
I am having problems implementing the validator when the ActionForm
involved in the form submission is backed by a HashMap. Specifically,
the generated client-sided script does not contain any calls to
validation functions.
Any help would be greatly appreicated!
-dave
PROBLEM: for an ActionForm named testForm, the generated javascript
begins as follows:
function validateTestForm(form) {
if (bCancel)
return true;
else
return true;
}
Here are the associated components:
validator.xml:
<form name="mapBasedFormTest">
<field name="property(firstName)" depends="maxlength">
<arg0 key="errors.maxlength"/>
<arg1 key="test.firstname.displayname"/>
<arg2 name="maxlength" key="${var:maxlength}"
resource="false"/>
<var>
<var-name>maxlength</var-name>
<var-value>10</var-value>
</var>
</field>
<field name="property(lastName)" depends="maxlength">
<arg0 key="errors.maxlength"/>
<arg1 key="test.lastname.displayname"/>
<arg2 name="maxlength" key="${var:maxlength}"
resource="false"/>
<var>
<var-name>maxlength</var-name>
<var-value>50</var-value>
</var>
</field>
</form>
ActionForm:
import org.apache.struts.action.ActionForm;
import java.util.HashMap;
public class FormTest extends ActionForm
{
protected HashMap properties = new java.util.HashMap();
public void setProperty(String key, Object value)
{
this.properties.put(key, value);
}
public Object getProperty(String key)
{
return this.properties.get(key);
}
}
test.jsp:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html>
<body>
<html:form action="/test">
<bean:message key="test.firstname.displayname"/>
<html:text property="property(firstName)"/>
<br/>
<bean:message key="test.lastname.displayname"/>
<html:text property="property(lastName)"/>
<html:submit/>
</html:form>
<html:javascript formName="mapBasedFormTest"/>
</body>
</html>