You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Vic Cekvenich <vc...@basebeans.com> on 2003/02/18 12:59:17 UTC

FMT tag and form bean

I have been nudging people toiwards JSTL.
A nice feature is FMT tag that formats the number, date, etc. in the 
JSP. FMT tag needs the formBeans to return int!

So if one does a FORM for updates you create formbean with String 
getAge(), and number formated in Java before returning the String.

If then you just want to display the # (no update) you need to create a 
bean with int getAge(), and FMT it in JSP.


So return int for JSTL and String for formBean.

A prefered solution is that HTML tag is able to do formating like FMT tag.


.V

Also, it be nice if tiles was able to do some EL, or have a nicer way of 
FORWARDING to diferent JSP from the tile action one day.



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


Re: FMT tag and form bean

Posted by Ted Husted <hu...@apache.org>.
The ActionForm doesn't actually care about the property types. It's just 
that we can't roundtrip whatever they happen to type into an int field 
if validation fails.

The JavaBean spec doesn't allow you to overload properties. Though, you 
could have getAge and getAgeInt, which refered to the same String field.

I don't know what the FMT tag does under the covers, but I think the MVC 
solution would be a bean with FMT features that could be exposed as a 
JSP tag or whatever. Or, better yet, a DynaBean that allowed FMT 
settings for each field.

If such a bean was used to back a html tag, then whatever the bean 
returned is what the html tag would display.

The issue would be what happens when the input doesn't format correctly? 
Does the tag change the input or display input that doesn't meet the 
specification. If they input "a57k" for an int, what do they get back? 
There lies the conundrum =:0)

I suppose one solution would be to pass the bad input off to the 
validation message somehow. So you could display a blank field (or 57) 
with a message like "You entered a57k but a whole number was expected".

But, in any event, I think the key is to think in terms of the 
data-carrier rather than an implementation detail, like the tag.

-Ted.


Vic Cekvenich wrote:
> I have been nudging people toiwards JSTL.
> A nice feature is FMT tag that formats the number, date, etc. in the 
> JSP. FMT tag needs the formBeans to return int!
> 
> So if one does a FORM for updates you create formbean with String 
> getAge(), and number formated in Java before returning the String.
> 
> If then you just want to display the # (no update) you need to create a 
> bean with int getAge(), and FMT it in JSP.
> 
> 
> So return int for JSTL and String for formBean.
> 
> A prefered solution is that HTML tag is able to do formating like FMT tag.
> 
> 
> .V
> 
> Also, it be nice if tiles was able to do some EL, or have a nicer way of 
> FORWARDING to diferent JSP from the tile action one day.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-dev-help@jakarta.apache.org
> 
> 


-- 
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>


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


Re: FMT tag and form bean

Posted by Martin Cooper <ma...@apache.org>.
"Vic Cekvenich" <vc...@basebeans.com> wrote in message
news:b2uiqk$kce$1@main.gmane.org...
> Let's try again:
> :-)
> http://jakarta.apache.org/struts/userGuide/struts-html.html#text
> This does not let me localize or format.
>
> Lets say I have a bean that has a #, String getStartDate().
>
> If I sometimes use this bean on a read only page, I could do JSP FMT to
> format and localize.
>
> I sometime want to use the same bean on a R/W form submit page.
> String getStartDate(), hut html:text does not format or localize. The
> traditional approach I used was to format to native types inside the
> setters/getters.
>
> Point is I can't format a localize in html:text, but can in JSTL.

OK, now I see what you're saying. I was also assuming <html:text> had a
feature it turns out not to have
(yet ;). Still, you could do it like this, although it's a bit ugly:

<fmt:formatDate var="temp" value="${yourFormBean.startDate}" ... />
<html-el:text value="${temp}" ... />

--
Martin Cooper


>
> So the only place is in the bean, inside the getStartDate() {}.
>
> The other alternative is to copy.
>
> And I must have misunderstood what you were saying, but I think I now
> understand the issues surouding it enough.
>
> .V
>
>
>
> Martin Cooper wrote:
> > "Vic Cekvenich" <vc...@basebeans.com> wrote in message
> > news:b2uf0d$5gb$1@main.gmane.org...
> >
> >>I would like to format in the JSP if possible (for both).
> >>
> >>Let me just restate what I think you are saying:
> >>"Since JSTL can format strings, allways format and localize in the
> >>formBean".
> >
> >
> > No, that doesn't make any sense. I'm saying "Since JSTL can format
strings,
> > always format and localise in the JSP page". I don't understand why you
need
> > to do any of it in the bean, hence my last message.
> >
> >
> >>So as you point out, I can format and localize both in the bean. (Ex:
> >>formBean.setLocale(x) )
> >
> >
> > Um, I didn't point that out at all.
> >
> > --
> > Martin Cooper
> >
> >
> >
> >>So probably a better choice.
> >>
> >>But... since I like how the FMT tag works.... not sure what "best"
> >>approach is. I almost want to cross post to JSPTag-user, see if Geary is
> >>around. but it's really not that big a deal.
> >>A student in a class asked why this was and I was stuttering, so I
> >>posted to get it of my chest and maybe as a wish list for HTML-EL tag.
> >>
> >>You and Ted pointed out some things however.
> >>
> >>.V
> >>
> >>
> >>
> >>Martin Cooper wrote:
> >>
> >>>"Vic Cekvenich" <vc...@basebeans.com> wrote in message
> >>>news:b2u5oq$p8b$1@main.gmane.org...
> >>>
> >>>
> >>>>Thanks as always Ted and Martin.
> >>>>I would still have to format the number in the bean for Form, and
> >>>>localize dates (for the Candian dates), etc in the bean class.  If the
> >>>>page is read only, I would format in JSP.
> >>>
> >>>
> >>>I guess I don't understand. Why do you need to do formatting in the
> >
> > bean,
> >
> >>>and why is it different if the page is read-only? You should be able to
> >
> > use
> >
> >>>JSTL to do this in either case.
> >>>
> >>>--
> >>>Martin Cooper
> >>>
> >>>
> >>>
> >>>
> >>>>So far getAge() and
> >>>>getAgeInt() look ok. I wonder which way the faces tag will work.
> >>>>(yes, if know, if I copied data for the form bean .... but if I have
> >>>>nested and multi row and many to many, it's kind of a pain; one day I
> >>>>will write reflection with dynaRowSet to clone nesting, localize,
format
> >>>>and put in basicPortal)
> >>>>.V
> >>>>
> >>>>Martin Cooper wrote:
> >>>>
> >>>>
> >>>>>"Vic Cekvenich" <vc...@basebeans.com> wrote in message
> >>>>>news:b2t728$t7c$1@main.gmane.org...
> >>>>>
> >>>>>
> >>>>>
> >>>>>>I have been nudging people toiwards JSTL.
> >>>>>>A nice feature is FMT tag that formats the number, date, etc. in the
> >>>>>>JSP. FMT tag needs the formBeans to return int!
> >>>>>
> >>>>>
> >>>>>No, it does not. If you provide a string to the format tags, such as
> >>>>><fmt:formatNumber>, it will convert it to the appropriate numeric
type.
> >>>
> >>>Try
> >>>
> >>>
> >>>>>the following:
> >>>>>
> >>>>>----- cut here -----
> >>>>><%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
> >>>>>
> >>>>><%
> >>>>>   request.setAttribute("foo", "1234567890");
> >>>>>%>
> >>>>>
> >>>>><fmt:formatNumber value="${foo}" type="currency"/>
> >>>>>----- cut here -----
> >>>>>
> >>>>>To avoid any question of what other JSTL tags might be doing, I've
> >>>>>explicitly stored a string in a request attribute. The output from
the
> >>>
> >>>above
> >>>
> >>>
> >>>>>page is:
> >>>>>
> >>>>>$1,234,567,890.00
> >>>>>
> >>>>>The <fmt:formatNumber> tag did its job just fine when passed a string
> >>>>>instead of an integer.
> >>>>>
> >>>>>--
> >>>>>Martin Cooper
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>>So if one does a FORM for updates you create formbean with String
> >>>>>>getAge(), and number formated in Java before returning the String.
> >>>>>>
> >>>>>>If then you just want to display the # (no update) you need to
create
> >
> > a
> >
> >>>>>>bean with int getAge(), and FMT it in JSP.
> >>>>>>
> >>>>>>
> >>>>>>So return int for JSTL and String for formBean.
> >>>>>>
> >>>>>>A prefered solution is that HTML tag is able to do formating like
FMT
> >>>
> >>>tag.
> >>>
> >>>
> >>>>>>.V
> >>>>>>
> >>>>>>Also, it be nice if tiles was able to do some EL, or have a nicer
way
> >
> > of
> >
> >>>>>>FORWARDING to diferent JSP from the tile action one day.




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


Re: FMT tag and form bean

Posted by Vic Cekvenich <vc...@basebeans.com>.
Let's try again:
:-)
http://jakarta.apache.org/struts/userGuide/struts-html.html#text
This does not let me localize or format.

Lets say I have a bean that has a #, String getStartDate().

If I sometimes use this bean on a read only page, I could do JSP FMT to 
format and localize.

I sometime want to use the same bean on a R/W form submit page.
String getStartDate(), hut html:text does not format or localize. The 
traditional approach I used was to format to native types inside the 
setters/getters.

Point is I can't format a localize in html:text, but can in JSTL.

So the only place is in the bean, inside the getStartDate() {}.

The other alternative is to copy.

And I must have misunderstood what you were saying, but I think I now 
understand the issues surouding it enough.

.V



Martin Cooper wrote:
> "Vic Cekvenich" <vc...@basebeans.com> wrote in message
> news:b2uf0d$5gb$1@main.gmane.org...
> 
>>I would like to format in the JSP if possible (for both).
>>
>>Let me just restate what I think you are saying:
>>"Since JSTL can format strings, allways format and localize in the
>>formBean".
> 
> 
> No, that doesn't make any sense. I'm saying "Since JSTL can format strings,
> always format and localise in the JSP page". I don't understand why you need
> to do any of it in the bean, hence my last message.
> 
> 
>>So as you point out, I can format and localize both in the bean. (Ex:
>>formBean.setLocale(x) )
> 
> 
> Um, I didn't point that out at all.
> 
> --
> Martin Cooper
> 
> 
> 
>>So probably a better choice.
>>
>>But... since I like how the FMT tag works.... not sure what "best"
>>approach is. I almost want to cross post to JSPTag-user, see if Geary is
>>around. but it's really not that big a deal.
>>A student in a class asked why this was and I was stuttering, so I
>>posted to get it of my chest and maybe as a wish list for HTML-EL tag.
>>
>>You and Ted pointed out some things however.
>>
>>.V
>>
>>
>>
>>Martin Cooper wrote:
>>
>>>"Vic Cekvenich" <vc...@basebeans.com> wrote in message
>>>news:b2u5oq$p8b$1@main.gmane.org...
>>>
>>>
>>>>Thanks as always Ted and Martin.
>>>>I would still have to format the number in the bean for Form, and
>>>>localize dates (for the Candian dates), etc in the bean class.  If the
>>>>page is read only, I would format in JSP.
>>>
>>>
>>>I guess I don't understand. Why do you need to do formatting in the
> 
> bean,
> 
>>>and why is it different if the page is read-only? You should be able to
> 
> use
> 
>>>JSTL to do this in either case.
>>>
>>>--
>>>Martin Cooper
>>>
>>>
>>>
>>>
>>>>So far getAge() and
>>>>getAgeInt() look ok. I wonder which way the faces tag will work.
>>>>(yes, if know, if I copied data for the form bean .... but if I have
>>>>nested and multi row and many to many, it's kind of a pain; one day I
>>>>will write reflection with dynaRowSet to clone nesting, localize, format
>>>>and put in basicPortal)
>>>>.V
>>>>
>>>>Martin Cooper wrote:
>>>>
>>>>
>>>>>"Vic Cekvenich" <vc...@basebeans.com> wrote in message
>>>>>news:b2t728$t7c$1@main.gmane.org...
>>>>>
>>>>>
>>>>>
>>>>>>I have been nudging people toiwards JSTL.
>>>>>>A nice feature is FMT tag that formats the number, date, etc. in the
>>>>>>JSP. FMT tag needs the formBeans to return int!
>>>>>
>>>>>
>>>>>No, it does not. If you provide a string to the format tags, such as
>>>>><fmt:formatNumber>, it will convert it to the appropriate numeric type.
>>>
>>>Try
>>>
>>>
>>>>>the following:
>>>>>
>>>>>----- cut here -----
>>>>><%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
>>>>>
>>>>><%
>>>>>   request.setAttribute("foo", "1234567890");
>>>>>%>
>>>>>
>>>>><fmt:formatNumber value="${foo}" type="currency"/>
>>>>>----- cut here -----
>>>>>
>>>>>To avoid any question of what other JSTL tags might be doing, I've
>>>>>explicitly stored a string in a request attribute. The output from the
>>>
>>>above
>>>
>>>
>>>>>page is:
>>>>>
>>>>>$1,234,567,890.00
>>>>>
>>>>>The <fmt:formatNumber> tag did its job just fine when passed a string
>>>>>instead of an integer.
>>>>>
>>>>>--
>>>>>Martin Cooper
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>So if one does a FORM for updates you create formbean with String
>>>>>>getAge(), and number formated in Java before returning the String.
>>>>>>
>>>>>>If then you just want to display the # (no update) you need to create
> 
> a
> 
>>>>>>bean with int getAge(), and FMT it in JSP.
>>>>>>
>>>>>>
>>>>>>So return int for JSTL and String for formBean.
>>>>>>
>>>>>>A prefered solution is that HTML tag is able to do formating like FMT
>>>
>>>tag.
>>>
>>>
>>>>>>.V
>>>>>>
>>>>>>Also, it be nice if tiles was able to do some EL, or have a nicer way
> 
> of
> 
>>>>>>FORWARDING to diferent JSP from the tile action one day.



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


Re: FMT tag and form bean

Posted by Martin Cooper <ma...@apache.org>.
"Vic Cekvenich" <vc...@basebeans.com> wrote in message
news:b2uf0d$5gb$1@main.gmane.org...
> I would like to format in the JSP if possible (for both).
>
> Let me just restate what I think you are saying:
> "Since JSTL can format strings, allways format and localize in the
> formBean".

No, that doesn't make any sense. I'm saying "Since JSTL can format strings,
always format and localise in the JSP page". I don't understand why you need
to do any of it in the bean, hence my last message.

>
> So as you point out, I can format and localize both in the bean. (Ex:
> formBean.setLocale(x) )

Um, I didn't point that out at all.

--
Martin Cooper


> So probably a better choice.
>
> But... since I like how the FMT tag works.... not sure what "best"
> approach is. I almost want to cross post to JSPTag-user, see if Geary is
> around. but it's really not that big a deal.
> A student in a class asked why this was and I was stuttering, so I
> posted to get it of my chest and maybe as a wish list for HTML-EL tag.
>
> You and Ted pointed out some things however.
>
> .V
>
>
>
> Martin Cooper wrote:
> > "Vic Cekvenich" <vc...@basebeans.com> wrote in message
> > news:b2u5oq$p8b$1@main.gmane.org...
> >
> >>Thanks as always Ted and Martin.
> >>I would still have to format the number in the bean for Form, and
> >>localize dates (for the Candian dates), etc in the bean class.  If the
> >>page is read only, I would format in JSP.
> >
> >
> > I guess I don't understand. Why do you need to do formatting in the
bean,
> > and why is it different if the page is read-only? You should be able to
use
> > JSTL to do this in either case.
> >
> > --
> > Martin Cooper
> >
> >
> >
> >> So far getAge() and
> >>getAgeInt() look ok. I wonder which way the faces tag will work.
> >>(yes, if know, if I copied data for the form bean .... but if I have
> >>nested and multi row and many to many, it's kind of a pain; one day I
> >>will write reflection with dynaRowSet to clone nesting, localize, format
> >>and put in basicPortal)
> >>.V
> >>
> >>Martin Cooper wrote:
> >>
> >>>"Vic Cekvenich" <vc...@basebeans.com> wrote in message
> >>>news:b2t728$t7c$1@main.gmane.org...
> >>>
> >>>
> >>>>I have been nudging people toiwards JSTL.
> >>>>A nice feature is FMT tag that formats the number, date, etc. in the
> >>>>JSP. FMT tag needs the formBeans to return int!
> >>>
> >>>
> >>>No, it does not. If you provide a string to the format tags, such as
> >>><fmt:formatNumber>, it will convert it to the appropriate numeric type.
> >
> > Try
> >
> >>>the following:
> >>>
> >>>----- cut here -----
> >>><%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
> >>>
> >>><%
> >>>    request.setAttribute("foo", "1234567890");
> >>>%>
> >>>
> >>><fmt:formatNumber value="${foo}" type="currency"/>
> >>>----- cut here -----
> >>>
> >>>To avoid any question of what other JSTL tags might be doing, I've
> >>>explicitly stored a string in a request attribute. The output from the
> >
> > above
> >
> >>>page is:
> >>>
> >>>$1,234,567,890.00
> >>>
> >>>The <fmt:formatNumber> tag did its job just fine when passed a string
> >>>instead of an integer.
> >>>
> >>>--
> >>>Martin Cooper
> >>>
> >>>
> >>>
> >>>
> >>>>So if one does a FORM for updates you create formbean with String
> >>>>getAge(), and number formated in Java before returning the String.
> >>>>
> >>>>If then you just want to display the # (no update) you need to create
a
> >>>>bean with int getAge(), and FMT it in JSP.
> >>>>
> >>>>
> >>>>So return int for JSTL and String for formBean.
> >>>>
> >>>>A prefered solution is that HTML tag is able to do formating like FMT
> >
> > tag.
> >
> >>>>
> >>>>.V
> >>>>
> >>>>Also, it be nice if tiles was able to do some EL, or have a nicer way
of
> >>>>FORWARDING to diferent JSP from the tile action one day.




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


Re: FMT tag and form bean

Posted by Vic Cekvenich <vc...@basebeans.com>.
I would like to format in the JSP if possible (for both).

Let me just restate what I think you are saying:
"Since JSTL can format strings, allways format and localize in the 
formBean".

So as you point out, I can format and localize both in the bean. (Ex: 
formBean.setLocale(x) )
So probably a better choice.

But... since I like how the FMT tag works.... not sure what "best" 
approach is. I almost want to cross post to JSPTag-user, see if Geary is 
around. but it's really not that big a deal.
A student in a class asked why this was and I was stuttering, so I 
posted to get it of my chest and maybe as a wish list for HTML-EL tag.

You and Ted pointed out some things however.

.V



Martin Cooper wrote:
> "Vic Cekvenich" <vc...@basebeans.com> wrote in message
> news:b2u5oq$p8b$1@main.gmane.org...
> 
>>Thanks as always Ted and Martin.
>>I would still have to format the number in the bean for Form, and
>>localize dates (for the Candian dates), etc in the bean class.  If the
>>page is read only, I would format in JSP.
> 
> 
> I guess I don't understand. Why do you need to do formatting in the bean,
> and why is it different if the page is read-only? You should be able to use
> JSTL to do this in either case.
> 
> --
> Martin Cooper
> 
> 
> 
>> So far getAge() and
>>getAgeInt() look ok. I wonder which way the faces tag will work.
>>(yes, if know, if I copied data for the form bean .... but if I have
>>nested and multi row and many to many, it's kind of a pain; one day I
>>will write reflection with dynaRowSet to clone nesting, localize, format
>>and put in basicPortal)
>>.V
>>
>>Martin Cooper wrote:
>>
>>>"Vic Cekvenich" <vc...@basebeans.com> wrote in message
>>>news:b2t728$t7c$1@main.gmane.org...
>>>
>>>
>>>>I have been nudging people toiwards JSTL.
>>>>A nice feature is FMT tag that formats the number, date, etc. in the
>>>>JSP. FMT tag needs the formBeans to return int!
>>>
>>>
>>>No, it does not. If you provide a string to the format tags, such as
>>><fmt:formatNumber>, it will convert it to the appropriate numeric type.
> 
> Try
> 
>>>the following:
>>>
>>>----- cut here -----
>>><%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
>>>
>>><%
>>>    request.setAttribute("foo", "1234567890");
>>>%>
>>>
>>><fmt:formatNumber value="${foo}" type="currency"/>
>>>----- cut here -----
>>>
>>>To avoid any question of what other JSTL tags might be doing, I've
>>>explicitly stored a string in a request attribute. The output from the
> 
> above
> 
>>>page is:
>>>
>>>$1,234,567,890.00
>>>
>>>The <fmt:formatNumber> tag did its job just fine when passed a string
>>>instead of an integer.
>>>
>>>--
>>>Martin Cooper
>>>
>>>
>>>
>>>
>>>>So if one does a FORM for updates you create formbean with String
>>>>getAge(), and number formated in Java before returning the String.
>>>>
>>>>If then you just want to display the # (no update) you need to create a
>>>>bean with int getAge(), and FMT it in JSP.
>>>>
>>>>
>>>>So return int for JSTL and String for formBean.
>>>>
>>>>A prefered solution is that HTML tag is able to do formating like FMT
> 
> tag.
> 
>>>>
>>>>.V
>>>>
>>>>Also, it be nice if tiles was able to do some EL, or have a nicer way of
>>>>FORWARDING to diferent JSP from the tile action one day.



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


Re: FMT tag and form bean

Posted by Martin Cooper <ma...@apache.org>.
"Vic Cekvenich" <vc...@basebeans.com> wrote in message
news:b2u5oq$p8b$1@main.gmane.org...
> Thanks as always Ted and Martin.
> I would still have to format the number in the bean for Form, and
> localize dates (for the Candian dates), etc in the bean class.  If the
> page is read only, I would format in JSP.

I guess I don't understand. Why do you need to do formatting in the bean,
and why is it different if the page is read-only? You should be able to use
JSTL to do this in either case.

--
Martin Cooper


>  So far getAge() and
> getAgeInt() look ok. I wonder which way the faces tag will work.
> (yes, if know, if I copied data for the form bean .... but if I have
> nested and multi row and many to many, it's kind of a pain; one day I
> will write reflection with dynaRowSet to clone nesting, localize, format
> and put in basicPortal)
> .V
>
> Martin Cooper wrote:
> > "Vic Cekvenich" <vc...@basebeans.com> wrote in message
> > news:b2t728$t7c$1@main.gmane.org...
> >
> >>I have been nudging people toiwards JSTL.
> >>A nice feature is FMT tag that formats the number, date, etc. in the
> >>JSP. FMT tag needs the formBeans to return int!
> >
> >
> > No, it does not. If you provide a string to the format tags, such as
> > <fmt:formatNumber>, it will convert it to the appropriate numeric type.
Try
> > the following:
> >
> > ----- cut here -----
> > <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
> >
> > <%
> >     request.setAttribute("foo", "1234567890");
> > %>
> >
> > <fmt:formatNumber value="${foo}" type="currency"/>
> > ----- cut here -----
> >
> > To avoid any question of what other JSTL tags might be doing, I've
> > explicitly stored a string in a request attribute. The output from the
above
> > page is:
> >
> > $1,234,567,890.00
> >
> > The <fmt:formatNumber> tag did its job just fine when passed a string
> > instead of an integer.
> >
> > --
> > Martin Cooper
> >
> >
> >
> >>So if one does a FORM for updates you create formbean with String
> >>getAge(), and number formated in Java before returning the String.
> >>
> >>If then you just want to display the # (no update) you need to create a
> >>bean with int getAge(), and FMT it in JSP.
> >>
> >>
> >>So return int for JSTL and String for formBean.
> >>
> >>A prefered solution is that HTML tag is able to do formating like FMT
tag.
> >>
> >>
> >>.V
> >>
> >>Also, it be nice if tiles was able to do some EL, or have a nicer way of
> >>FORWARDING to diferent JSP from the tile action one day.




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


Re: FMT tag and form bean

Posted by Vic Cekvenich <vc...@basebeans.com>.
Thanks as always Ted and Martin.
I would still have to format the number in the bean for Form, and 
localize dates (for the Candian dates), etc in the bean class.  If the 
page is read only, I would format in JSP.  So far getAge() and 
getAgeInt() look ok. I wonder which way the faces tag will work.
(yes, if know, if I copied data for the form bean .... but if I have 
nested and multi row and many to many, it's kind of a pain; one day I 
will write reflection with dynaRowSet to clone nesting, localize, format 
and put in basicPortal)
.V

Martin Cooper wrote:
> "Vic Cekvenich" <vc...@basebeans.com> wrote in message
> news:b2t728$t7c$1@main.gmane.org...
> 
>>I have been nudging people toiwards JSTL.
>>A nice feature is FMT tag that formats the number, date, etc. in the
>>JSP. FMT tag needs the formBeans to return int!
> 
> 
> No, it does not. If you provide a string to the format tags, such as
> <fmt:formatNumber>, it will convert it to the appropriate numeric type. Try
> the following:
> 
> ----- cut here -----
> <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
> 
> <%
>     request.setAttribute("foo", "1234567890");
> %>
> 
> <fmt:formatNumber value="${foo}" type="currency"/>
> ----- cut here -----
> 
> To avoid any question of what other JSTL tags might be doing, I've
> explicitly stored a string in a request attribute. The output from the above
> page is:
> 
> $1,234,567,890.00
> 
> The <fmt:formatNumber> tag did its job just fine when passed a string
> instead of an integer.
> 
> --
> Martin Cooper
> 
> 
> 
>>So if one does a FORM for updates you create formbean with String
>>getAge(), and number formated in Java before returning the String.
>>
>>If then you just want to display the # (no update) you need to create a
>>bean with int getAge(), and FMT it in JSP.
>>
>>
>>So return int for JSTL and String for formBean.
>>
>>A prefered solution is that HTML tag is able to do formating like FMT tag.
>>
>>
>>.V
>>
>>Also, it be nice if tiles was able to do some EL, or have a nicer way of
>>FORWARDING to diferent JSP from the tile action one day.



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


Re: FMT tag and form bean

Posted by Martin Cooper <ma...@apache.org>.
"Vic Cekvenich" <vc...@basebeans.com> wrote in message
news:b2t728$t7c$1@main.gmane.org...
> I have been nudging people toiwards JSTL.
> A nice feature is FMT tag that formats the number, date, etc. in the
> JSP. FMT tag needs the formBeans to return int!

No, it does not. If you provide a string to the format tags, such as
<fmt:formatNumber>, it will convert it to the appropriate numeric type. Try
the following:

----- cut here -----
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

<%
    request.setAttribute("foo", "1234567890");
%>

<fmt:formatNumber value="${foo}" type="currency"/>
----- cut here -----

To avoid any question of what other JSTL tags might be doing, I've
explicitly stored a string in a request attribute. The output from the above
page is:

$1,234,567,890.00

The <fmt:formatNumber> tag did its job just fine when passed a string
instead of an integer.

--
Martin Cooper


>
> So if one does a FORM for updates you create formbean with String
> getAge(), and number formated in Java before returning the String.
>
> If then you just want to display the # (no update) you need to create a
> bean with int getAge(), and FMT it in JSP.
>
>
> So return int for JSTL and String for formBean.
>
> A prefered solution is that HTML tag is able to do formating like FMT tag.
>
>
> .V
>
> Also, it be nice if tiles was able to do some EL, or have a nicer way of
> FORWARDING to diferent JSP from the tile action one day.




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