I've never used the iterator tag like that, the standard way to use the Struts 2 Iterator would be:
<s:iterator value="products"> <span class="product-name"><s:property value="name <http://product.name/> "/></span> <span class="product-price">£<s:text name="format.currency"><s:param value="price"/></s:text></span> </s:iterator> Since the iterator tag puts the current value on the top of the stack, there's no reason to define a variable to hold it. It's much simpler to just use the value stack to pull the values from. Don't know if this might help or not. (*Chris*) On Tue, Jul 13, 2010 at 3:23 PM, Chris Miles <ch...@chrismiles.org> wrote: > Chris, > > I have a list of products which contain a double price. > > I now have. > > <s:iterator value="products" var="product"> > <span class="product-name"><s:property value="#product.name"/></span> > <span class="product-price">£<s:text > name="format.currency"><s:param value="#product.price"/></s:text></span> > </s:iterator> > > > Chris > ----- Original Message ----- From: "Chris Pratt" <thechrispr...@gmail.com> > To: "Struts Users Mailing List" <user@struts.apache.org> > Sent: Tuesday, July 13, 2010 11:04 PM > > Subject: Re: Currency Formatting > > > <s:iterator> puts the value on the top of the stack, so if you have a list >> of doubles, we'll call it amounts, it would look something like this: >> >> <s:iterator value="%{amounts}"> >> <s:text name="format.currency"><s:param value="%{top}"/></s:text> >> </s:iterator> >> >> (*Chris*) >> >> On Tue, Jul 13, 2010 at 2:43 PM, Chris Miles <ch...@chrismiles.org> >> wrote: >> >> Chris, >>> >>> Hi that works perfectly for >>> >>> <s:text name="format.currency"><s:param value="total"/></s:text> >>> >>> where total is public Double getTotal >>> >>> but causes all rendering to stop at the following within an iterator. >>> >>> <s:text name="format.currency"><s:param value="#product.price"/> >>> >>> where List<Product> getProducts (for the iterator), public Product >>> getProduct and public Double getPrice >>> >>> and also fails just on >>> >>> <s:text name="format.currency"><s:param value="product.price"/></s:text> >>> >>> where public Product getProduct >>> >>> Is there places where different mechanisms need to be used here? I dont >>> understand the inconstistant result I now get. >>> >>> Nothing in the log files on TRACE >>> >>> >>> Thanks >>> >>> Chris >>> ----- Original Message ----- From: "Chris Pratt" < >>> thechrispr...@gmail.com> >>> To: "Struts Users Mailing List" <user@struts.apache.org> >>> Sent: Tuesday, July 13, 2010 8:16 PM >>> Subject: Re: Currency Formatting >>> >>> >>> >>> try <s:param> instead of <s:property>. >>> >>>> (*Chris*) >>>> >>>> On Tue, Jul 13, 2010 at 12:11 PM, Chris Miles <ch...@chrismiles.org> >>>> wrote: >>>> >>>> At the moment I have in my struts.xml >>>> >>>>> >>>>> <constant name="struts.custom.i18n.resources" >>>>> value="ApplicationResources" >>>>> /> >>>>> >>>>> ApplicationResources.properties is being packaged within >>>>> WEB-INF\classes >>>>> within a WAR within an EAR. >>>>> >>>>> The file contains: format.currency={0,number,currency} >>>>> >>>>> In my JSP I have <s:text name="format.currency"><s:property >>>>> value="product.price"/></s:text> >>>>> >>>>> Without the s:text the price is displayed (a Double). >>>>> >>>>> When the s:text is included all I get is: {0} >>>>> >>>>> thanks >>>>> >>>>> Chris >>>>> ----- Original Message ----- From: "Chris Pratt" < >>>>> thechrispr...@gmail.com> >>>>> To: "Struts Users Mailing List" <user@struts.apache.org> >>>>> Sent: Sunday, July 11, 2010 1:25 AM >>>>> Subject: Re: Currency Formatting >>>>> >>>>> >>>>> >>>>> Define something like: >>>>> >>>>> >>>>>> format.currency={0,number,currency} >>>>>> >>>>>> In your applications.properties file, then use: >>>>>> >>>>>> <s:text name="format.currency"><s:param value="%{amount}"/></s:text> >>>>>> >>>>>> HTH >>>>>> (*Chris*) >>>>>> >>>>>> On Sat, Jul 10, 2010 at 5:53 AM, Chris Miles <ch...@chrismiles.org> >>>>>> wrote: >>>>>> >>>>>> Hi >>>>>> >>>>>> >>>>>>> If I am displaying a Double to a JSP page what is the recommended way >>>>>>> to >>>>>>> format this is as a currency to two decimal points? >>>>>>> >>>>>>> Thanks >>>>>>> >>>>>>> Chris >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>>>> For additional commands, e-mail: user-h...@struts.apache.org >>>>> >>>>> >>>>> >>>>> >>>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>> For additional commands, e-mail: user-h...@struts.apache.org >>> >>> >>> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >