using form beans as results beans
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   pierre_sirolli
Posted On:   Thursday, January 17, 2002 09:51 AM

Do you think it is a good idea to use form beans as results beans ? Not only, the form beans will contain attributes which maps the html form, but we have Value Objects attributes. Consider the following sequence : form.jsp -> (submit) FindProjectAction -> (sucess) result.jsp form.jsp ... ... Struts populates the ProjectForm bean. then in perform() method of my action class I do Project projectForm = (ProjectForm)form; // business invocation ArrayList listOfProjects = Business.findProjectsWhereNameIs( projectForm.g   More>>

Do you think it is a good idea to use form beans as results beans ?
Not only, the form beans will contain attributes which maps the html form, but
we have Value Objects attributes.


Consider the following sequence :


form.jsp -> (submit) FindProjectAction -> (sucess) result.jsp


form.jsp

...







...



Struts populates the ProjectForm bean.



then in perform() method of my action class I do



Project projectForm = (ProjectForm)form;



// business invocation

ArrayList listOfProjects = Business.findProjectsWhereNameIs( projectForm.getName();


//I need to send this listOfProjects to my jsp page which will display them


projectForm.setListOfProjects( listOfProjects );



return (mapping.finForward("success");





in the result jsp (result.jsp)







<% ArrayList listOfProjects = projectForm.getListOfProjects(); %>



   <<Less

Re: using form beans as results beans

Posted By:   Ted_Husted  
Posted On:   Sunday, January 20, 2002 05:47 AM


I don't see any thing wrong with overloading ActionForms with
properties that would be useful for a result page as well
as the input page. One clear advantage is that you can
document everything in one place.



I'd probably go so far as to add a getter that returned an
iterator to the ArrayList, which you could just pass that to the
logic:iterate tag.


If you use the iterate and bean tags,
there is no need to go through the jsp:useBean red tape,
or bother with scriptlets.


HTH -Ted.

About | Sitemap | Contact