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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to