my dog learned polymorphism*
The moose likes Struts and the fly likes Validator Issue with multiply beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validator Issue with multiply beans" Watch "Validator Issue with multiply beans" New topic
Author

Validator Issue with multiply beans

Tim Resh
Greenhorn

Joined: Aug 09, 2006
Posts: 19
Here is what I have in my struts-config

<form-bean name="siteForm" type="org.apache.struts.validator.DynaValidatorForm" >
<form-property name="site" type="com.tryit.service.datatransfer.SiteDTO"/>
<form-property name="sitePrefs" type="com.tryit.service.datatransfer.SitePrefsDTO"/>
<form-property name="siteConfiguration" type="com.tryit.service.datatransfer.SiteDTO"/>
</form-bean>


The way the JSP is laid out is each property is a tab on the html. I can validate the first one using following validation.


<form name="siteForm">
<field property="site.name" depends="required">
<arg0 key="label.name"/>
</field>
<field property="site.webUrl" depends="required">
<arg0 key="label.homeUrl"/>
</field>
<field property="site.loginUrl" depends="required">
<arg0 key="label.loginUrl"/>
</field>
<field property="site.description" depends="required">
<arg0 key="label.description"/>
</field>
<field property="site.callinNumber" depends="optionalMask">
<arg0 key="label.callInNumber"/>
<var>
<var-name>mask</var-name>
<var-value>${phone}</var-value>
</var>
</field>
<field property="site.minIntendedAge" depends="optionalMask">
<arg0 key="label.minIntendedAgeMsg"/>
<var>
<var-name>mask</var-name>
<var-value>${numeric}</var-value>
</var>
</field>
<field property="site.callinCode" depends="optionalMask">
<arg0 key="label.callInCode"/>
<var>
<var-name>mask</var-name>
<var-value>${numeric}</var-value>
</var>
</field>
<field property="site.maxIntendedAge" depends="optionalMask">
<arg0 key="label.maxIntendedAgeMsg"/>
<var>
<var-name>mask</var-name>
<var-value>${numeric}</var-value>
</var>
</field>
</form>


and here is my ActionMap


<action path="/updateSite"
type="com.tryit.ui.action.SiteAdminManagement"
parameter="method"
roles="authenticatedUser"
validate="true"
name="siteForm"
input=".siteInfo">
<forward name="adminHome" path=".siteManagementHome"/>
<forward name="manageSite" path=".siteInfo"/>
<forward name="manageSiteConfiguration" path=".siteConfiguration"/>
</action>


and finally an excerpt of the JSP that contains the Configuration tab.

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<html:img srcKey="images.space" width="1" height="13"/><br/>
<table width="575" border="3" cellspacing="0" cellpadding="5" bordercolor="#C1CDE1"
class="innertable">
<tr>
<td align="left" valign="top">
<%--Overview Section--%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<html:form action="<%=IConstants.UPDATE_SITE_CONFIGURATION%>" focusIndex="1">
<bean efine id="siteConfiguration" name="siteForm" property="siteConfiguration" property="siteConfiguration"/>
<tr>
<td class="subhead">
<hr noshade color="#C1CDE1">
</td>
</tr>
<tr>
<td class="normal">
<table>
<tr>
<td align="right" class="formlabel"> <bean:message key="label.prospectPurgeDays"/>
<html:img srcKey="images.space" width="5"/></td>
<td> <html:text property="siteConfiguration.prospectPurgeDays" /> </td>
</tr>
<tr>
<td colspan="2" class="errorlabel">
<html:messages id="error" property="siteConfiguration.prospectPurgeDays" >
<bean:write name="error"/>
</html:messages>



prospectPurgeDays is one of the fields on siteConfiguration data object. I have tried everything in the validation like the folowing but nothing works.

<form name="siteConfiguration">
<field property="siteConfiguration.prospectPurgeDays" depends="required">
<arg0 key="label.propectPurgeDays"/>
<var>
<var-name>mask</var-name>
<var-value>${numeric}</var-value>
</var>
</field>
</form>


tried it with site.siteConfiguration.propectPurgeDays, propectPurgeDays, siteForm.siteConfiguration.prospectPurgeDays etc.... I changed these in the JSP also along with any combination. Two weeks 3 books and I cannot get it.

I just can't get the validator to validate the siteConfiguration but it works on the site tab only.

Any help???
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Show us the Action mapping for the action that <%= IConstants.UPDATE_SITE_CONFIGURATION %> resolves to.


Merrill
Consultant, Sima Solutions
Tim Resh
Greenhorn

Joined: Aug 09, 2006
Posts: 19
resolves to UPDATE_SITE_CONFIGURATION = "/siteConfiguration?method=updateSiteConfiguration

This works as I can click the button to Submit and the information is saved.

I think the issue has to do with DynaAction forms

In the validator on the siteForm

I ended up putting siteConfiguration.prospectPurgeDays


ex..
<field property="siteConfiguration.prospectPurgeDays" depends="intRange">
<arg0 key="label.prospectPurgeDays"/>
<arg1 key="${var:min}" resource="false"/>
<arg2 key="${var:max}" resource="false"/>
<var>
<var-name>min</var-name>
<var-value>0</var-value>
</var>
<var>
<var-name>max</var-name>
<var-value>998</var-value>
</var>


This is not what I wanted to do. I wanted each tab to validate it's fields regardless of the other tabs fields even though they are all in the same Bean siteForm. Now all data validates on siteForm regardless of which tab you are on.

Thanks
 
Consider Paul's rocket mass heater.
 
subject: Validator Issue with multiply beans
 
Similar Threads
Struts Validation Problem
Errors are not getting displayed on JSP when DynaValidatorActionForm is used.
server side validation errors
validation
why after validation&#65292;return zero&#65311;