aspose file tools*
The moose likes Struts and the fly likes Indexed Properties hidden values in ActionForm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Indexed Properties hidden values in ActionForm" Watch "Indexed Properties hidden values in ActionForm" New topic
Author

Indexed Properties hidden values in ActionForm

Sara Smith
Greenhorn

Joined: Oct 20, 2006
Posts: 28
I have RelationshipDefineDTO object with set/get methods & ArrayList for relAcctDTO objects(RelationAccountDTO) i.e for every RelationshipDefineDTO they are many relAcctDTO objects(RelationAccountDTO)

My requirement is to carry all these fields as hidden parameters from page to page,
i am able to carry all the hidden values of the RelationshipDefineDTO object e.g (clientName, clientID etc) but having problems carring ArrayList values for RelationshipDefineDTO object. Below is what I am doing & any input is appreciated

Code from ActionForm to carry index values


Code for the Object


Code for JSP
<logic:notEmpty name='relationshipForm' property='relDefineDTOList'>
<logic:iterate id='relDefineDTO' name='relationshipForm' property='relDefineDTOList' indexId="index">
<html:hidden name="relDefineDTO" property="clientId" indexed="true" />
<html:hidden name="relDefineDTO" property="clientName" indexed="true" />
<html:hidden name="relDefineDTO" property="clientType" indexed="true" />
<html:hidden name="relDefineDTO" property="cltOrNonCltIndicator" indexed="true" />
<TR>

<TD valign="top" align='Left' nowrap >
<bean:write name='relDefineDTO' property='clientName' />
</TD>
<TD valign="middle" align='center'>
<bean:write name='relDefineDTO' property='clientId' />
</TD>
<TD valign="middle" align='center'>
<bean efine id="primInd" name="relDefineDTO" property="clientRelToPrimary" type="java.lang.String"/>
</TD>

//display relAcctDTO of RelationAccountDTO object

<logic:iterate id="relAcctDTO" name="relDefineDTO" property="relAcctDTO" indexId="acct">
<html:hidden name="relAcctDTO" property="oldWorldNumber" indexed="true" /
<html:hidden name="relAcctDTO" property="accountNumber" indexed="true" />
<html:hidden name="relAcctDTO" property="acctIndicator" indexed="true" />
<TD valign="middle" align='left'>
<bean:write name='relAcctDTO' property='oldWorldNumber'/>
</TD>
<TD valign="middle" align='left'>
<bean:write name='relAcctDTO' property='shortName' /></TD>
<TD valign="middle" align='left'>
<bean:write name='relAcctDTO' property='portfolio' /></TD>
<TD valign="middle" align='left'>
<bean:write name='relAcctDTO' property='accountValue' /></TD>

</logic:iterate>
</TR>

</logic:iterate>
</logic:notEmpty>

Below is the data i am getting for each individual client ids
i.e for every client i am getting the same accountDTO list repeating,
HOW CAN I FIX THIS ISSUE, what am doing wrong?


cltId= 5576283400 cltName= Ellin, Charles relToPrimary= 0 cltInd= 0
AccountNumber= 6890963100 OldWorldNumber = AX 96765 AcctIndicator = I
AccountNumber= 3401963100 OldWorldNumber = AX 96766 AcctIndicator = I
AccountNumber= 9212963100 OldWorldNumber = AX 96767 AcctIndicator = I
AccountNumber= 5312963100 OldWorldNumber = AX 96768 AcctIndicator = I

cltId= 1226283400 cltName= Ellin, Christine relToPrimary= 29 cltInd= 0
AccountNumber= 6890963100 OldWorldNumber = AX 96765 AcctIndicator = I
AccountNumber= 3401963100 OldWorldNumber = AX 96766 AcctIndicator = I
AccountNumber= 9212963100 OldWorldNumber = AX 96767 AcctIndicator = I
AccountNumber= 5312963100 OldWorldNumber = AX 96768 AcctIndicator = I

cltId= 471512000 cltName= SMITH, DONNA relToPrimary= 991 cltInd= 0
AccountNumber= 6890963100 OldWorldNumber = AX 96765 AcctIndicator = I
AccountNumber= 3401963100 OldWorldNumber = AX 96766 AcctIndicator = I
AccountNumber= 9212963100 OldWorldNumber = AX 96767 AcctIndicator = I
AccountNumber= 5312963100 OldWorldNumber = AX 96768 AcctIndicator = I

cltId= 5344012000 cltName= SMITH, JAMES relToPrimary= 991 cltInd= 0
AccountNumber= 6890963100 OldWorldNumber = AX 96765 AcctIndicator = I
AccountNumber= 3401963100 OldWorldNumber = AX 96766 AcctIndicator = I
AccountNumber= 9212963100 OldWorldNumber = AX 96767 AcctIndicator = I
AccountNumber= 5312963100 OldWorldNumber = AX 96768 AcctIndicator = I
RelationshipAccountDTO = 4

EXPECTED Result is as below


cltId= 5576283400 cltName= Ellin, Charles relToPrimary= 0 cltInd= 0
AccountNumber= 6890963100 OldWorldNumber = AX 96765 AcctIndicator = I
AccountNumber= 3401963100 OldWorldNumber = AX 96766 AcctIndicator = I
AccountNumber= 9212963100 OldWorldNumber = AX 96767 AcctIndicator = I
AccountNumber= 5312963100 OldWorldNumber = AX 96768 AcctIndicator = I
RelationshipAccountDTO size = 4

cltId= 1226283400 cltName= Ellin, Christine relToPrimary= 29 cltInd= 0
AccountNumber= 3244963100 OldWorldNumber = AX 94445 AcctIndicator = I
AccountNumber= 4356963100 OldWorldNumber = AX 96556 AcctIndicator = I
RelationshipAccountDTO size = 2

cltId= 471512000 cltName= SMITH, DONNA relToPrimary= 991 cltInd= 0
AccountNumber= 9090955500 OldWorldNumber = AX 94555 AcctIndicator = I
RelationshipAccountDTO size = 1

cltId= 5344012000 cltName= SMITH, JAMES relToPrimary= 991 cltInd= 0
AccountNumber= 8895533100 OldWorldNumber = AX 90965 AcctIndicator = I
RelationshipAccountDTO size = 1
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you're iterating over more than one level, you can't use the indexed="true" attribute in an <html:xxx> tag. You must either use the <nested:xxx> tags or construct the property name yourself. I personally prefer to construct the property name myself. Example:


[ March 15, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Sara Smith
Greenhorn

Joined: Oct 20, 2006
Posts: 28
Hi Merrill,

Thanks a lot for your response.

I get below error message

No getter method for property relDefineDTO[0].relAcctDTO[0].oldWorldNumber of bean org.apache.struts.taglib.html.BEAN


Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The indexed getter method getRelAcctDTO(index) must not be on your form bean but on the RelationshipDefineDTO bean. Because Struts sometimes has a hard time dealing with overloaded methods, it's best if you rename the existing getRelAcctDTO method that returns an ArrayList.

Do you understand why this is? When the form is submitted, the indexed property name above is telling Struts to perform the following actions:
  • Call getRelDefineDTO(0) on the form bean
  • On the bean retrieved from the previous operation, call getRelAcctDTO(0)
  • On the bean retrieved from the previous operation, call setOldWorldNumber("value")


  • [ March 15, 2007: Message edited by: Merrill Higginson ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Indexed Properties hidden values in ActionForm