You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Peter Neu <pe...@gmx.net> on 2007/04/16 10:19:11 UTC

HowTo Format Numbers in html:text tag?

Hello,

I need to format a number string in a html:text tag because the default
value must be written with a comma sperator. e.g. 4,5 while the value of my
value bean is in fact like this: 4.5.

Normally I would use bean:message and the format attribute. But this does
not work in html:text. 

How can I do this?


Cheers,
Pete 




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: HowTo Format Numbers in html:text tag?

Posted by Lance <la...@marketpipe.com>.
Oops, i mean <fmt:formatNumber />

Lance wrote:
> You could use <fmt:formatDate /> in JSTL
> http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf 
> <http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf>
>
> Peter Neu wrote:
>> Hello,
>>
>> I need to format a number string in a html:text tag because the default
>> value must be written with a comma sperator. e.g. 4,5 while the value 
>> of my
>> value bean is in fact like this: 4.5.
>>
>> Normally I would use bean:message and the format attribute. But this 
>> does
>> not work in html:text.
>> How can I do this?
>>
>>
>> Cheers,
>> Pete
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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


AW: AW: AW: AW: HowTo Format Numbers in html:text tag?

Posted by Peter Neu <pe...@gmx.net>.
Good remarks. I will add the stuff. 

Parse position is something I don't use although the constructor requests
it.

Cheers,
Pete

> -----Ursprüngliche Nachricht-----
> Von: Lance [mailto:lance.semmens@marketpipe.com]
> Gesendet: Montag, 16. April 2007 12:10
> An: Struts Users Mailing List
> Betreff: Re: AW: AW: AW: HowTo Format Numbers in html:text tag?
> 
> Looks ok to me altho im not familiar with parse position
> 
> You might wanna allow blank too
>     if (price != null && price.trim().length() != 0) {
> 
> And catch NumberFormatException / set an error
> 
> And setPriceDouble(null) in your forms reset() method
> 
> Peter Neu wrote:
> > OK so what I did is:
> >
> > --jsp---
> >   <input   name="price" value="<bean:write name="Obj" property="price"
> > format="##"/>" />
> >
> > -> Value gets displayed with commas.
> >
> > --action-form-
> >
> > NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.GERMAN);
> > DecimalFormat df = (DecimalFormat) nf;
> > df.setDecimalSeparatorAlwaysShown(false);
> > df.applyPattern("#,###,###,###,###.#########");
> >
> >
> > if (price != null) {
> >             if (price.contains(".")) {
> >                 ActionError msg = new
> > ActionError("servlets.jsp.error.edit1");
> >                 errors.add("uploadErr", msg);
> >                 System.out.println("error");
> >             } else {
> >                   ParsePosition pp2  = new ParsePosition(0);
> >                 Number inNbr = df.parse(price, pp2);
> >                 setPriceDouble(inNbr.doubleValue());
> >             }
> >         }
> >
> > In my struts action form I check for null values and the copy the string
> > representation into a double value.
> >
> > Does that make sense?
> >
> >
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Lance [mailto:lance.semmens@marketpipe.com]
> >> Gesendet: Montag, 16. April 2007 11:31
> >> An: Struts Users Mailing List
> >> Betreff: Re: AW: AW: HowTo Format Numbers in html:text tag?
> >>
> >> Your brute force approach does not use <html:text /> tho?
> >> Also, I have a suspicion that struts will either throw an exception or
> >> set nulls for inputted numbers that contain commas, you might need to
> >> use Strings on your form and format / parse to numbers in your
> action(s).
> >>
> >> Peter Neu wrote:
> >>
> >>> But that's more code than the brute force approach:
> >>>
> >>> <input name="usage" value="<bean:write name="Obj" property="usage"
> >>> format="##"/>" />
> >>>
> >>> If have about 20-30 items. :o(
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>> -----Ursprüngliche Nachricht-----
> >>>> Von: Lance [mailto:lance.semmens@marketpipe.com]
> >>>> Gesendet: Montag, 16. April 2007 11:05
> >>>> An: Struts Users Mailing List
> >>>> Betreff: Re: AW: HowTo Format Numbers in html:text tag?
> >>>>
> >>>> You could combine with struts-el
> >>>>
> >>>> <!-- store in formattedNumber (don't output -->
> >>>> <fmt:formatDate value="${myForm.myNumber}" pattern="??"
> >>>> var="formattedNumber" />
> >>>>
> >>>> <!-- use the formatted value -->
> >>>> <html-el:text property="myNumber" value="${formattedNumber}" />
> >>>>
> >>>> Peter Neu wrote:
> >>>>
> >>>>
> >>>>> That looks cool but I need to embed the value in the html:text field
> >>>>>
> >> so
> >>
> >>>> the
> >>>>
> >>>>
> >>>>> user is able to edit the value. That won't work with 2 tags. :o(
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>> -----Ursprüngliche Nachricht-----
> >>>>>> Von: Lance [mailto:lance.semmens@marketpipe.com]
> >>>>>> Gesendet: Montag, 16. April 2007 10:45
> >>>>>> An: Struts Users Mailing List
> >>>>>> Betreff: Re: HowTo Format Numbers in html:text tag?
> >>>>>>
> >>>>>> You could use <fmt:formatDate /> in JSTL
> >>>>>> http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf
> >>>>>> <http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf>
> >>>>>>
> >>>>>> Peter Neu wrote:
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> Hello,
> >>>>>>>
> >>>>>>> I need to format a number string in a html:text tag because the
> >>>>>>>
> >>>>>>>
> >>>> default
> >>>>
> >>>>
> >>>>>>> value must be written with a comma sperator. e.g. 4,5 while the
> >>>>>>>
> >> value
> >>
> >>>> of
> >>>>
> >>>>
> >>>>>> my
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> value bean is in fact like this: 4.5.
> >>>>>>>
> >>>>>>> Normally I would use bean:message and the format attribute. But
> this
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>> does
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>> not work in html:text.
> >>>>>>>
> >>>>>>> How can I do this?
> >>>>>>>
> >>>>>>>
> >>>>>>> Cheers,
> >>>>>>> Pete
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> ------------------------------------------------------------------
> --
> >>>>>>>
> >> -
> >>
> >>>>>>> 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
> >>>>
> >>>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: AW: AW: AW: HowTo Format Numbers in html:text tag?

Posted by Lance <la...@marketpipe.com>.
Looks ok to me altho im not familiar with parse position

You might wanna allow blank too
    if (price != null && price.trim().length() != 0) {

And catch NumberFormatException / set an error

And setPriceDouble(null) in your forms reset() method

Peter Neu wrote:
> OK so what I did is:
>
> --jsp---
>   <input   name="price" value="<bean:write name="Obj" property="price"
> format="##"/>" /> 
>
> -> Value gets displayed with commas. 
>
> --action-form-
>
> NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.GERMAN);
> DecimalFormat df = (DecimalFormat) nf;
> df.setDecimalSeparatorAlwaysShown(false);
> df.applyPattern("#,###,###,###,###.#########");
>
>
> if (price != null) {
>             if (price.contains(".")) {
>                 ActionError msg = new
> ActionError("servlets.jsp.error.edit1");
>                 errors.add("uploadErr", msg);
>                 System.out.println("error");
>             } else {
>                   ParsePosition pp2  = new ParsePosition(0);
>                 Number inNbr = df.parse(price, pp2);
>                 setPriceDouble(inNbr.doubleValue());
>             }
>         }
>
> In my struts action form I check for null values and the copy the string
> representation into a double value.
>
> Does that make sense?
>
>
>   
>> -----Ursprüngliche Nachricht-----
>> Von: Lance [mailto:lance.semmens@marketpipe.com]
>> Gesendet: Montag, 16. April 2007 11:31
>> An: Struts Users Mailing List
>> Betreff: Re: AW: AW: HowTo Format Numbers in html:text tag?
>>
>> Your brute force approach does not use <html:text /> tho?
>> Also, I have a suspicion that struts will either throw an exception or
>> set nulls for inputted numbers that contain commas, you might need to
>> use Strings on your form and format / parse to numbers in your action(s).
>>
>> Peter Neu wrote:
>>     
>>> But that's more code than the brute force approach:
>>>
>>> <input name="usage" value="<bean:write name="Obj" property="usage"
>>> format="##"/>" />
>>>
>>> If have about 20-30 items. :o(
>>>
>>>
>>>
>>>
>>>
>>>       
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: Lance [mailto:lance.semmens@marketpipe.com]
>>>> Gesendet: Montag, 16. April 2007 11:05
>>>> An: Struts Users Mailing List
>>>> Betreff: Re: AW: HowTo Format Numbers in html:text tag?
>>>>
>>>> You could combine with struts-el
>>>>
>>>> <!-- store in formattedNumber (don't output -->
>>>> <fmt:formatDate value="${myForm.myNumber}" pattern="??"
>>>> var="formattedNumber" />
>>>>
>>>> <!-- use the formatted value -->
>>>> <html-el:text property="myNumber" value="${formattedNumber}" />
>>>>
>>>> Peter Neu wrote:
>>>>
>>>>         
>>>>> That looks cool but I need to embed the value in the html:text field
>>>>>           
>> so
>>     
>>>> the
>>>>
>>>>         
>>>>> user is able to edit the value. That won't work with 2 tags. :o(
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>>> -----Ursprüngliche Nachricht-----
>>>>>> Von: Lance [mailto:lance.semmens@marketpipe.com]
>>>>>> Gesendet: Montag, 16. April 2007 10:45
>>>>>> An: Struts Users Mailing List
>>>>>> Betreff: Re: HowTo Format Numbers in html:text tag?
>>>>>>
>>>>>> You could use <fmt:formatDate /> in JSTL
>>>>>> http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf
>>>>>> <http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf>
>>>>>>
>>>>>> Peter Neu wrote:
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> Hello,
>>>>>>>
>>>>>>> I need to format a number string in a html:text tag because the
>>>>>>>
>>>>>>>               
>>>> default
>>>>
>>>>         
>>>>>>> value must be written with a comma sperator. e.g. 4,5 while the
>>>>>>>               
>> value
>>     
>>>> of
>>>>
>>>>         
>>>>>> my
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> value bean is in fact like this: 4.5.
>>>>>>>
>>>>>>> Normally I would use bean:message and the format attribute. But this
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>> does
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> not work in html:text.
>>>>>>>
>>>>>>> How can I do this?
>>>>>>>
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Pete
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --------------------------------------------------------------------
>>>>>>>               
>> -
>>     
>>>>>>> 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
>>>>
>>>>         
>>>
>>> ---------------------------------------------------------------------
>>> 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


AW: AW: AW: HowTo Format Numbers in html:text tag?

Posted by Peter Neu <pe...@gmx.net>.
OK so what I did is:

--jsp---
  <input   name="price" value="<bean:write name="Obj" property="price"
format="##"/>" /> 

-> Value gets displayed with commas. 

--action-form-

NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.GERMAN);
DecimalFormat df = (DecimalFormat) nf;
df.setDecimalSeparatorAlwaysShown(false);
df.applyPattern("#,###,###,###,###.#########");


if (price != null) {
            if (price.contains(".")) {
                ActionError msg = new
ActionError("servlets.jsp.error.edit1");
                errors.add("uploadErr", msg);
                System.out.println("error");
            } else {
                  ParsePosition pp2  = new ParsePosition(0);
                Number inNbr = df.parse(price, pp2);
                setPriceDouble(inNbr.doubleValue());
            }
        }

In my struts action form I check for null values and the copy the string
representation into a double value.

Does that make sense?


> -----Ursprüngliche Nachricht-----
> Von: Lance [mailto:lance.semmens@marketpipe.com]
> Gesendet: Montag, 16. April 2007 11:31
> An: Struts Users Mailing List
> Betreff: Re: AW: AW: HowTo Format Numbers in html:text tag?
> 
> Your brute force approach does not use <html:text /> tho?
> Also, I have a suspicion that struts will either throw an exception or
> set nulls for inputted numbers that contain commas, you might need to
> use Strings on your form and format / parse to numbers in your action(s).
> 
> Peter Neu wrote:
> > But that's more code than the brute force approach:
> >
> > <input name="usage" value="<bean:write name="Obj" property="usage"
> > format="##"/>" />
> >
> > If have about 20-30 items. :o(
> >
> >
> >
> >
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Lance [mailto:lance.semmens@marketpipe.com]
> >> Gesendet: Montag, 16. April 2007 11:05
> >> An: Struts Users Mailing List
> >> Betreff: Re: AW: HowTo Format Numbers in html:text tag?
> >>
> >> You could combine with struts-el
> >>
> >> <!-- store in formattedNumber (don't output -->
> >> <fmt:formatDate value="${myForm.myNumber}" pattern="??"
> >> var="formattedNumber" />
> >>
> >> <!-- use the formatted value -->
> >> <html-el:text property="myNumber" value="${formattedNumber}" />
> >>
> >> Peter Neu wrote:
> >>
> >>> That looks cool but I need to embed the value in the html:text field
> so
> >>>
> >> the
> >>
> >>> user is able to edit the value. That won't work with 2 tags. :o(
> >>>
> >>>
> >>>
> >>>> -----Ursprüngliche Nachricht-----
> >>>> Von: Lance [mailto:lance.semmens@marketpipe.com]
> >>>> Gesendet: Montag, 16. April 2007 10:45
> >>>> An: Struts Users Mailing List
> >>>> Betreff: Re: HowTo Format Numbers in html:text tag?
> >>>>
> >>>> You could use <fmt:formatDate /> in JSTL
> >>>> http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf
> >>>> <http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf>
> >>>>
> >>>> Peter Neu wrote:
> >>>>
> >>>>
> >>>>> Hello,
> >>>>>
> >>>>> I need to format a number string in a html:text tag because the
> >>>>>
> >> default
> >>
> >>>>> value must be written with a comma sperator. e.g. 4,5 while the
> value
> >>>>>
> >> of
> >>
> >>>> my
> >>>>
> >>>>
> >>>>> value bean is in fact like this: 4.5.
> >>>>>
> >>>>> Normally I would use bean:message and the format attribute. But this
> >>>>>
> >>>>>
> >>>> does
> >>>>
> >>>>
> >>>>> not work in html:text.
> >>>>>
> >>>>> How can I do this?
> >>>>>
> >>>>>
> >>>>> Cheers,
> >>>>> Pete
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> --------------------------------------------------------------------
> -
> >>>>> 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
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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


Re: AW: AW: HowTo Format Numbers in html:text tag?

Posted by Lance <la...@marketpipe.com>.
Your brute force approach does not use <html:text /> tho?
Also, I have a suspicion that struts will either throw an exception or 
set nulls for inputted numbers that contain commas, you might need to 
use Strings on your form and format / parse to numbers in your action(s).

Peter Neu wrote:
> But that's more code than the brute force approach: 
>
> <input name="usage" value="<bean:write name="Obj" property="usage"
> format="##"/>" />
>
> If have about 20-30 items. :o(
>
>
>
>
>   
>> -----Ursprüngliche Nachricht-----
>> Von: Lance [mailto:lance.semmens@marketpipe.com]
>> Gesendet: Montag, 16. April 2007 11:05
>> An: Struts Users Mailing List
>> Betreff: Re: AW: HowTo Format Numbers in html:text tag?
>>
>> You could combine with struts-el
>>
>> <!-- store in formattedNumber (don't output -->
>> <fmt:formatDate value="${myForm.myNumber}" pattern="??"
>> var="formattedNumber" />
>>
>> <!-- use the formatted value -->
>> <html-el:text property="myNumber" value="${formattedNumber}" />
>>
>> Peter Neu wrote:
>>     
>>> That looks cool but I need to embed the value in the html:text field so
>>>       
>> the
>>     
>>> user is able to edit the value. That won't work with 2 tags. :o(
>>>
>>>
>>>       
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: Lance [mailto:lance.semmens@marketpipe.com]
>>>> Gesendet: Montag, 16. April 2007 10:45
>>>> An: Struts Users Mailing List
>>>> Betreff: Re: HowTo Format Numbers in html:text tag?
>>>>
>>>> You could use <fmt:formatDate /> in JSTL
>>>> http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf
>>>> <http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf>
>>>>
>>>> Peter Neu wrote:
>>>>
>>>>         
>>>>> Hello,
>>>>>
>>>>> I need to format a number string in a html:text tag because the
>>>>>           
>> default
>>     
>>>>> value must be written with a comma sperator. e.g. 4,5 while the value
>>>>>           
>> of
>>     
>>>> my
>>>>
>>>>         
>>>>> value bean is in fact like this: 4.5.
>>>>>
>>>>> Normally I would use bean:message and the format attribute. But this
>>>>>
>>>>>           
>>>> does
>>>>
>>>>         
>>>>> not work in html:text.
>>>>>
>>>>> How can I do this?
>>>>>
>>>>>
>>>>> Cheers,
>>>>> Pete
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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
>>     
>
>
>
> ---------------------------------------------------------------------
> 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


AW: AW: HowTo Format Numbers in html:text tag?

Posted by Peter Neu <pe...@gmx.net>.
But that's more code than the brute force approach: 

<input name="usage" value="<bean:write name="Obj" property="usage"
format="##"/>" />

If have about 20-30 items. :o(




> -----Ursprüngliche Nachricht-----
> Von: Lance [mailto:lance.semmens@marketpipe.com]
> Gesendet: Montag, 16. April 2007 11:05
> An: Struts Users Mailing List
> Betreff: Re: AW: HowTo Format Numbers in html:text tag?
> 
> You could combine with struts-el
> 
> <!-- store in formattedNumber (don't output -->
> <fmt:formatDate value="${myForm.myNumber}" pattern="??"
> var="formattedNumber" />
> 
> <!-- use the formatted value -->
> <html-el:text property="myNumber" value="${formattedNumber}" />
> 
> Peter Neu wrote:
> > That looks cool but I need to embed the value in the html:text field so
> the
> > user is able to edit the value. That won't work with 2 tags. :o(
> >
> >
> >> -----Ursprüngliche Nachricht-----
> >> Von: Lance [mailto:lance.semmens@marketpipe.com]
> >> Gesendet: Montag, 16. April 2007 10:45
> >> An: Struts Users Mailing List
> >> Betreff: Re: HowTo Format Numbers in html:text tag?
> >>
> >> You could use <fmt:formatDate /> in JSTL
> >> http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf
> >> <http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf>
> >>
> >> Peter Neu wrote:
> >>
> >>> Hello,
> >>>
> >>> I need to format a number string in a html:text tag because the
> default
> >>> value must be written with a comma sperator. e.g. 4,5 while the value
> of
> >>>
> >> my
> >>
> >>> value bean is in fact like this: 4.5.
> >>>
> >>> Normally I would use bean:message and the format attribute. But this
> >>>
> >> does
> >>
> >>> not work in html:text.
> >>>
> >>> How can I do this?
> >>>
> >>>
> >>> Cheers,
> >>> Pete
> >>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: AW: HowTo Format Numbers in html:text tag?

Posted by Lance <la...@marketpipe.com>.
You could combine with struts-el

<!-- store in formattedNumber (don't output -->
<fmt:formatDate value="${myForm.myNumber}" pattern="??" 
var="formattedNumber" />

<!-- use the formatted value -->
<html-el:text property="myNumber" value="${formattedNumber}" />

Peter Neu wrote:
> That looks cool but I need to embed the value in the html:text field so the
> user is able to edit the value. That won't work with 2 tags. :o(
>
>   
>> -----Ursprüngliche Nachricht-----
>> Von: Lance [mailto:lance.semmens@marketpipe.com]
>> Gesendet: Montag, 16. April 2007 10:45
>> An: Struts Users Mailing List
>> Betreff: Re: HowTo Format Numbers in html:text tag?
>>
>> You could use <fmt:formatDate /> in JSTL
>> http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf
>> <http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf>
>>
>> Peter Neu wrote:
>>     
>>> Hello,
>>>
>>> I need to format a number string in a html:text tag because the default
>>> value must be written with a comma sperator. e.g. 4,5 while the value of
>>>       
>> my
>>     
>>> value bean is in fact like this: 4.5.
>>>
>>> Normally I would use bean:message and the format attribute. But this
>>>       
>> does
>>     
>>> not work in html:text.
>>>
>>> How can I do this?
>>>
>>>
>>> Cheers,
>>> Pete
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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


AW: HowTo Format Numbers in html:text tag?

Posted by Peter Neu <pe...@gmx.net>.
That looks cool but I need to embed the value in the html:text field so the
user is able to edit the value. That won't work with 2 tags. :o(

> -----Ursprüngliche Nachricht-----
> Von: Lance [mailto:lance.semmens@marketpipe.com]
> Gesendet: Montag, 16. April 2007 10:45
> An: Struts Users Mailing List
> Betreff: Re: HowTo Format Numbers in html:text tag?
> 
> You could use <fmt:formatDate /> in JSTL
> http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf
> <http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf>
> 
> Peter Neu wrote:
> > Hello,
> >
> > I need to format a number string in a html:text tag because the default
> > value must be written with a comma sperator. e.g. 4,5 while the value of
> my
> > value bean is in fact like this: 4.5.
> >
> > Normally I would use bean:message and the format attribute. But this
> does
> > not work in html:text.
> >
> > How can I do this?
> >
> >
> > Cheers,
> > Pete
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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


Re: HowTo Format Numbers in html:text tag?

Posted by Lance <la...@marketpipe.com>.
You could use <fmt:formatDate /> in JSTL
http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf 
<http://bellsouthpwp.net/b/i/billsigg/jstl-quick-reference.pdf>

Peter Neu wrote:
> Hello,
>
> I need to format a number string in a html:text tag because the default
> value must be written with a comma sperator. e.g. 4,5 while the value of my
> value bean is in fact like this: 4.5.
>
> Normally I would use bean:message and the format attribute. But this does
> not work in html:text. 
>
> How can I do this?
>
>
> Cheers,
> Pete 
>
>
>
>
> ---------------------------------------------------------------------
> 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