If I could jump in and ask a question,

I have searched this list for a best practice regarding the relationship between
      formbeans, value objects, and formatting/cleaning data.

I found the discussion between Jon and Ted interesting.

I am gearing up to try and use struts in my current project so I would like to
      clear on thing up.

We use value objects (with int's,floats, ect)  from Session EJB's.

In addition to this, we populate the editable text boxes with formatted values
      such as currency (with comma's), phone number with brackets , dates ,and
      so on.

So the data going into the page get's formatted and upon submit must get cleaned
      and then validated.

 I was under the impression that  this would be done in the FormBean in a couple
      of different ways.

One is to store the  property as it native type (int), and do the formatting in
      the standard  String getXXX() and clean the data in the standard
      setXXX(String xxx).

The second is to create a standard form bean but supply an extra set of methods
      to deal with the special cases, such as: int getIntXXX() ect.

Am I off base with this line of thinking?





Jon Wall wrote:
>  I'm
> assuming, then, that the ActionForm performs another
> function that I hadn't thought about - converting the
> String and boolean props that you're bringing in on
> the web to the navtive structure used by the backend.
> Is this true?  So what you're telling me is...I not
> only need to create an ActionForm class for each of my
> many components (100+) that actually implements each
> of the public methods, but for each of the non
> String/boolean properties I need to make a sort of
> formatter method.

The ActionForm is really about buffering. It gives the HTML controls
persistance, until the data can be validated and/of converted to your
native structures. What happens when someone tries to toss "47a" at an
Integer property? HTTP is a hostile, uncontrolled environment, and the
ActionForms are designed to compensate for that.

But keep in mind that ActionForms are just for HTML Form input. They are
not expected to be used as anything but buffers for the html form tags.
You do not have to use them to retrieve widgets, just to send widgets
data they need to store.

Once the ActionForm is validated, the BeanUtils can be a very handy way
to copy the data over to your native beans. Usually, you just need to
define your ActionForm properties to match your native bean property
names. The problem is, you need a place to stand if the data fails
validation, and can't be transferred to your native beans. There lies
the rub.












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

Reply via email to