struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Pratt <thechrispr...@gmail.com>
Subject Re: Currency Formatting
Date Tue, 13 Jul 2010 23:03:20 GMT
Define "fails", you get a stack trace? you don't get the output you
expected?  If so, what were you expecting vs. what did you get? I've used
that code a thousand times, so I'm not sure what could be going wrong...
  (*Chris*)

On Tue, Jul 13, 2010 at 3:56 PM, Chris Miles <chris@chrismiles.org> wrote:

> Thanks Chris. The reason I use this method in my iterators is there are a
> few places where I use nested iterators so the # notation is the only way to
> access the current iterator but also the parent iterator.
>
> This specific iterator is not nested so I have changed it for learning and
> trial sake and it fails with the line
>
> <span class="product-price"><s:text name="format.currency"><s:param
> value="price"/></s:text></span>
>
> I can put
>
> <span class="product-price"><s:property value="price"/></span>
>
> and it displays the value fine.
>
>
> Chris
>
> ----- Original Message ----- From: "Chris Pratt" <thechrispratt@gmail.com>
> To: "Struts Users Mailing List" <user@struts.apache.org>
> Sent: Tuesday, July 13, 2010 11:28 PM
> Subject: Re: Currency Formatting
>
>
>  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">&pound;<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 <chris@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">&pound;<s:text
>>> name="format.currency"><s:param value="#product.price"/></s:text></span>
>>> </s:iterator>
>>>
>>>
>>> Chris
>>> ----- Original Message ----- From: "Chris Pratt" <
>>> thechrispratt@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 <chris@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" <
>>>>> thechrispratt@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 <chris@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" <
>>>>>>> thechrispratt@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 <chris@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-unsubscribe@struts.apache.org
>>>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>  ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message