This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validator Issue with multiply beans

 
Tim Resh
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show us the Action mapping for the action that <%= IConstants.UPDATE_SITE_CONFIGURATION %> resolves to.
 
Tim Resh
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic