You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Oliphant, Geoff" <ge...@sealcorp.com.au> on 2000/11/22 10:29:25 UTC

Tag use within another tag

Hi all,

I've got a jsp page that outputs a table of data from two beans.  I use
iterate tags to produce a row in the table for each record in an ArrayList
in the first bean.  So that works fine, I can output fields in the row from
each field from the arraylist in the bean using <iterate> and
<htmlProperty>.

The problem arises when I want to produce the last field in the row.  That
field comes from a similar array list in the second bean - only this field
has to be based on the primary key of the object in the first bean so that
the two match up.  A demonstration will probably prove more helpful than
words:

First code: no problem:

<struts:ifAttributeExists name="currentAccount" scope="session">
  <struts:iterate id="asset" name="currentAccount" property="assets">
	<td valign="top"><span class="content2"><struts:htmlProperty
name="asset" property="assetCode"/></span></td>
	<td valign="top"><span class="content2"><img src="images/shim.gif"
width="1" height="1"><struts:htmlProperty name="asset"
property="name"/></span></td>
	<td valign="top">&nbsp;</td>
	<td valign="top">
	  <div align="right"><span class="content2"><struts:htmlProperty
name="asset" property="assetProfilePercentage"/></span></div>
	</td>
	<td valign="top">
	  <div align="right"><span class="content2"><struts:htmlProperty
name="asset" property="assetValue"/></span></div>
	</td>

So within this first bean I need to get a value out of the second bean based
on the first bean's value of AssetCode:

	<td valign="top">
		  <div align="right"><span class="content2">
		  <struts:ifAttributeExists name="proposedAccount"
scope="session">
		  <struts:iterate id="element" name="proposedAccount"
property="assets">
		  <struts:ifPropertyEquals name="element"
property="assetCode" value='<struts:htmlProperty name="asset"
property="assetCode"/>'>
		  <struts:htmlProperty name="element"
property="assetValue"/>
		  </struts:ifPropertyEquals>
		  </struts:iterate>
		  </struts:ifAttributeExists>
		  &nbsp;</span></div>
		</td>
	  </tr>
	  </struts:iterate>
</struts:ifAttributeExists>

The problem arises when the value attribute of the ifPropertyEquals tag.  I
need to output the assetValue ONLY if the assetCode matches the current
iteration of the first bean.

I've looked at the archives to find similar problems and have tried
everything - including changing the tld to allow realtime expression on
value of ifPropertyEquals.

Any help is greatly appreciated.

Geoff


================================================================================================
                                     IMPORTANT INFORMATION

This message and any files transmitted with it are confidential and should be read only by those
persons to whom it is addressed.   
If you have received this message in error, please notify us immediately by way of reply. Please
also destroy and delete the message from your computer. Any unauthorised form of reproduction
of this message is strictly prohibited.

It is the duty of the recipient to virus scan and otherwise test the information provided before
loading onto any computer system.  
SEALCORP does not warrant that the information is free of a virus or any other defect or error.

SEALCORP is not liable for the proper and complete transmission of the information contained in
this communication, nor for any delay in its receipt.

Any views expressed in this message are those of the individual sender, except where the sender
specifically states them to be the views of SEALCORP.

================================================================================================