You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jayaraman Dorai <ja...@Wellogic.com> on 2002/06/05 02:10:58 UTC

Collection and form bean

I have a collection of Value objects which I iterate through the logic iterate in JSP. This value object has a int. The requirement is to display a blank instead of a 0. I can convert this value object into a form bean which has a string equivalent for this int and replace a 0 with an empty string. But the idea of iterating over a collection of form beans doesn't sound well for me. Is that ok? 
 
In the struts example, the collection of subscription is iterated and not the subscriptionForm. If subscription had an int attribute would it be wise to iterate through the collection of subscriptionForm. Which is more MVC? The jsp page iterating over the model object or the form object.
 
Jayaraman

Re: Collection and form bean

Posted by Ted Husted <hu...@apache.org>.
You probably want there to be a collection of beans, and a helper method
on the bean that returns a blank instead of 0. Then all the JSP has to
do is call the helper, without having to know anything about the blank
or 0 requirement. 

In a case like this, whether the bean object itself was born in a model
package or controller package isn't pertinent. The page is only bound to
the property name, not the object. You could switch the bean object at
any time, and so long as the property name stayed the same, the page
would be none the wiser.

-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services

Jayaraman Dorai wrote:
> 
> I have a collection of Value objects which I iterate through the logic iterate in JSP. This value object has a int. The requirement is to display a blank instead of a 0. I can convert this value object into a form bean which has a string equivalent for this int and replace a 0 with an empty string. But the idea of iterating over a collection of form beans doesn't sound well for me. Is that ok?
> 
> In the struts example, the collection of subscription is iterated and not the subscriptionForm. If subscription had an int attribute would it be wise to iterate through the collection of subscriptionForm. Which is more MVC? The jsp page iterating over the model object or the form object.
> 
> Jayaraman

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>