This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Validator Issue with multiply beans

 
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???
 
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
 
My, my, aren't you a big fella. Here, have a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!