You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Norman Klein <no...@first-franklin.com> on 2003/01/12 22:59:40 UTC
Formatted output within a nested iterate loop
I currently have a nested iterate loop which looks like the following:
<nested:iterate id="liabilities" name="OverviewForm"
indexId="liabilityIndex" property="liabilities">
<tr id="lib_<%=liabilityIndex%>_Header" class="appSubHeader">
<td valign="MIDDLE">
<nested:text name="liabilities"
property="unpaidBalance" />
</td>
</nested iterate>
This works fine, but the "unpaidBalance" field really needs to be formatted
like this: $100,000.00 instead of 100000.0
Since the text tag doesn't directly support a format field, I generally use
this trick:
<input type="text" name="loan.FFFCFee" size="8" maxlength="150"
value="<bean:write name="overviewForm" property="loan.FFFCFee"
format="###,###.00" /> ">
The "value" field is used to supply the necessary formatting capability.
but the following doesn't seem to work:
<nested:text name="liabilities" property="unpaidBalance"
value="<nested:write name="liabilities" property="unpaidBalance"
format="###,###,###.00" />" />
and only generates the following error message:
Error: Attribute: liabilities" is not a valid attribute name
Any help would be appreciated.
Thanks, Norman
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Formatted output within a nested iterate loop
Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "usha" == usha <us...@justcommodity.com> writes:
usha> Hi
usha> i have a question on formatting the output through <bean:write>. my ActionForms
usha> contains all the String datatype variable, even though the value in this
usha> varibles may be a date or number. i declared all varibles as string datatype
usha> because from the UI when the user enters the date if i won't declare it as a
usha> string datatype it need to be keyed in some particular format. if this is the
usha> case how can i use 'format' in the <bean:write format="###,###.00"/>
I'm sure there are other ways to do this, but this is a good use of the JSTL.
The "fmt:formatNumber" tag appears to give you this ability.
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net ; SCJP; SCWCD
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Formatted output within a nested iterate loop
Posted by usha <us...@justcommodity.com>.
Hi
i have a question on formatting the output through <bean:write>. my
ActionForms contains all the String datatype variable, even though the
value in this varibles may be a date or number. i declared all varibles
as string datatype because from the UI when the user enters the date if
i won't declare it as a string datatype it need to be keyed in some
particular format. if this is the case how can i use 'format' in the
<bean:write format="###,###.00"/>
Thanks
usha
David M. Karr wrote:
>>>>>>"Norman" == Norman Klein <no...@first-franklin.com> 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.
>
>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Formatted output within a nested iterate loop
Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Norman" == Norman Klein <no...@first-franklin.com> 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++
dmkarr@earthlink.net ; SCJP; SCWCD
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>