[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-dev
Subject:    Re: automatically handle invalid input format
From:       "enzhong fu" <enzhongfu () adelphia ! net>
Date:       2004-02-28 22:54:43
Message-ID: 004b01c3feb4$50b651c0$27d9a045 () r00492
[Download RAW message or body]

Craig,

I realized Bugzilla should be the way of posting enhancements. I put my
proposal in Bugzilla and also added an alternative solution. Thank you for
answer the posting.

I think form bean provide three things: hide Servlet api, auto populate
fields, has other functions (reset(), validate()). The restriction that its
fields are Strings does not naturally come from the above three. The reason
is type other than String can not store the original input value if it's not
valid format. Making all fields of ActionForm String is a walkaround of
this. Because request parameters are Strings and have the original input
values, we can display them to the user when an invalid format error occurs.
We do not display the form bean when inputs have invalid format so we don't
need to worry about non-String type can not store the original value. It
enhanced the auto populating but it does not change the first and the third
usage.

If I understand you correctly, when you say form bean is part of VIEW tier,
you intend it to reflect strictly an html form. The fields should match html
form, not business object or DTO; The type should be String, not other type;
A business object field's value is transfromed to display string field of
the form bean. My proposal indeed breaks this view. When business objects
and DTOs are nested in a form bean, the form bean CONTAINS model data and
display on html is transfromed in custom tag. The advantage is the
transformation can be automatic so code in Action is saved. Also, when
validation is against types in business objects, it can be used in both web
tier and business tier. I think this view offers more advantages. The form
bean organizes model data but it is NOT part of model tier.

In practice, developers may not realize the original intension of ActionForm
and use other types because they can do so. They get exception and are
confused. At least we could avoid propagating the exception to html. In
RequestProcessor, process() can catch the exception and call
processException(). It's up to the developer to provide handler to deal with
the invalid format. They can implement my proposal there.

Andrew




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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic