struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (David M. Karr)
Subject Re: Formatted output within a nested iterate loop
Date Sun, 12 Jan 2003 22:22:38 GMT
>>>>> "Norman" == Norman Klein <> writes:

    Norman> I currently have a nested iterate loop which looks like the following:

    Norman> <nested:iterate id="liabilities" name="OverviewForm"
    Norman> indexId="liabilityIndex" property="liabilities">
    Norman>   	<tr id="lib_<%=liabilityIndex%>_Header" class="appSubHeader">
    Norman> 		<td valign="MIDDLE">
    Norman> 			<nested:text name="liabilities"
    Norman> property="unpaidBalance" />
    Norman> 		</td>
    Norman> </nested iterate>

    Norman> This works fine, but the "unpaidBalance" field really needs to be formatted
    Norman> like this: $100,000.00 instead of 100000.0

    Norman> Since the text tag doesn't directly support a format field, I generally use
    Norman> this trick:

    Norman> <input type="text" name="loan.FFFCFee" size="8" maxlength="150"
    Norman> value="<bean:write name="overviewForm" property="loan.FFFCFee"
    Norman> format="###,###.00" /> ">

    Norman> The "value" field is used to supply the necessary formatting capability.

    Norman> but the following doesn't seem to work:

    Norman> <nested:text name="liabilities" property="unpaidBalance"
    Norman> value="<nested:write name="liabilities" property="unpaidBalance"
    Norman> format="###,###,###.00" />" />

    Norman> and only generates the following error message:

    Norman> 	Error: Attribute: liabilities" is not a valid attribute name 

You have a couple of problems here.

First, you can't nest a custom tag in the attribute value of a custom tag.
You'll have to put the nested value into either a scriptlet variable or a
scoped attribute, and just emit the value as part of the attribute value.

Second (this will probably go away when you fix the first problem), you're
nesting double quotes inside double quotes.  If you have an attribute value
that has to quote something inside the value, then the attribute value needs to
use different quotes than the internal quotes.

David M. Karr          ; Java/J2EE/XML/Unix/C++   ; SCJP; SCWCD

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message