Craig McClanahan wrote the following on 8/23/2005 4:47 PM:

Is it typical then to end up with several ManagedBean definitions for
the same backingBean but for different mappings?



Why would you need that?  I typically use a 1:1 mapping between JSP
pages and backing beans.

I guess that probably will be the case for most scenarios. It would take too long to describe the last scenario on the project I just worked on, but to break it down into a different analogy.. imagine if you had three separate JSPs: dog.jsp, fish.jsp, cat.jsp. They were all unique enough from a 'view' concept to make them separate pages. Yet, before you went to each page you needed to set up some data in the form for that page. Speaking in Struts terms, each page shared the same "AnimalForm" (even though it could have been broken out into 3 separate ones). Also when the form on each page submitted it only needed to submit to one AnimalAction (no need for a fish, cat, dog action when essentially what happened in each case was very similar). Processing on a save took place like...

saveDispatchMethod(..) {
   //bean utils copy animal form properties into an Animal object
   //save
   animalFactory.getAnimalService(animalType).save( animal );
}

Also there was a setUp() method that would be called before going to fish.jsp, dog.jsp etc and it would set up the correct animal information in the form.

So even though I had separate views (jsps), only one Action was needed to handle all of them.

This became important as later on more 'animal' types might need to be supported. In that case only a new view jsp might need to be added (along with a couple of backend classes - service and dao) yet the Struts controller didn't need to be touched. I didn't need to create a new Action for each type of animal(view). Granted this isn't the typical case but it might come up for others.

In relation to the 'employees' issue at hand, I was hoping to reuse the same backing bean for "employees" and "employee." employees.jsp shows the data grid and "employee.jsp" would be your typical edit/add form. I see though that it would make more sense to break these up into two different managed beans since the prerender for each is completely different.



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

Reply via email to