File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Indexed Properties Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Indexed Properties Help" Watch "Indexed Properties Help" New topic

Indexed Properties Help

Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
I have a DynaValidatorForm defined as such:
<form-bean name="DynamicBuilderForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="builderDTO" type="com.whatever.DynamicBenefitBuilderForm"/>

DynamicBenefitBuilderForm has the following:
DynamicBenefitBuilderRowEntry[] dynamicBenefitBuilderRowEntry = new DynamicBenefitBuilderRowEntry[11];
public DynamicBenefitBuilderRowEntry[] getDynamicBenefitBuilderRowEntry() {
return dynamicBenefitBuilderRowEntry;
public void setDynamicBenefitBuilderRowEntry(DynamicBenefitBuilderRowEntry[] dynamicBenefitBuilderRowEntry) {
this.dynamicBenefitBuilderRowEntry = dynamicBenefitBuilderRowEntry;
public DynamicBenefitBuilderRowEntry getDynamicBenefitBuilderRowEntry(int index) {
return dynamicBenefitBuilderRowEntry[index];
public void setDynamicBenefitBuilderRowEntry(int index, DynamicBenefitBuilderRowEntry rowEntry) {
dynamicBenefitBuilderRowEntry[index] = rowEntry;

My JSP has the following:
<logic:iterate name="DynamicBuilderForm" property="builderDTO.dynamicBenefitBuilderRowEntry" id="dynamicBenefitBuilderRowEntry" indexId="currentIndex">
<html:text name="dynamicBenefitBuilderRowEntry" property="rowName" indexed="true"/>

The HTML that the jsp outputs is:
<input type="text" name="dynamicBenefitBuilderRowEntry[0].rowName">

What I need it to output is something like this I believe:
builderDTO.dynamicBenefitBuilderRowEntry[0].rowName so that struts can call

getBuilderDTO().getDynamicBenefitBuilderRowEntry(0).setRowName(value) but I'm having problems.

Is it even possible to use indexed properties inside of another property of a DynaValidatorForm?

Loading the default values works correctly, saving them to the form does not. I am not getting any exceptions (this code is a short snippet of the production code so what I posted may have errors.

I don't understand why I'm NOT getting any exceptions becuase it looks like
getDynamicBenefitBuilderRowEntry(0).setName(value) would be called on the DynaValidatorForm which does not have that method. Any help would be appreciated.

I understand that I can rewrite the DynaValidatorForm to a standard ActionForm that I could get to solve the problem, but I was wondering if there was a more correct way to do so. Thanks.
[ November 22, 2006: Message edited by: Dom Lassy ]
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
I am not sure. Maybe you could change the id attribute of your iterate tag to use "builderDTO.dynamicBenefitBuilderRowEntry". Another option is to not use the indexed="true" attribute and build the indexed name yourself using some scriptlet code.

An example of using scriptlet code is shown in the "Dynamic Indexes for Indexed Properties" section of this page:

- Brent
I agree. Here's the link:
subject: Indexed Properties Help
It's not a secret anymore!