wood burning stoves 2.0*
The moose likes Struts and the fly likes passing formBeans to tiles... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "passing formBeans to tiles..." Watch "passing formBeans to tiles..." New topic

passing formBeans to tiles...

Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I have an actionForm that as part of it has a collection of actionForms.

Is it possible to outside of the <html:form > tags reference this beans property that holds the forms?

where mainForm is the bean name referenced in "someAction"

and then inside of subForm.jsp how do I get the form tag to hold the properties of the subForm bean that is passed in?

I can do a <tiles:get name="subForm"/> but how do I get this to be the bean referenced inside of the <html:form> tag in subForm.jsp?

I appreciate any help thanks,
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
I'm not sure, nor can I even imagine, what you are trying to do here -- why would Tiles care about the FormBean? Tiles is really just some sort of CompositeView Dispatcher .... so, um ... yeah. Technically speaking though, the FormBean will be bound in the appropriate context, which means that anybody in the pipeline can access it (after it gets to the action Servlet of course).

Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
I want multiple instances of a formBeanA to be held in a collection in formBeanB. I want a jsp page That starts with FormB on top and then inserts multiple tiles underneath each tile holding a form that is of type formbeanA.
I understand <tiles:insert .... <put ... </tiles:insert> and then using <tiles:get ....>

My question is in the inserted.jsp where you have the get. How would you associate the formbean that is passed in to the <html:form action=.... tag?

Everytime you have the tags <html:form action="..."> struts creates an instance of the form bean associated to that action in the struts config (or so it appears to me). I don't want this new/empty formbean... I want the one I passed in.

Kevin Judd

Joined: Dec 02, 2004
Posts: 9
You can define a form bean as having session scope instead of request scope. In this case, the bean is always there. This is tricky to handle, though; you will obviously take over responsibility for initializing the bean data. The books I have read on Struts (Cavaness, Husted) describe how to do this and list the caveats. You may want to review their treatment.

Kevin Judd, SCJP
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
Well I've found I can just initialize all of the forms with the values from the collection. Though submitting each form individually seems to be tricky as they all have the same name/action associated to them. I think I can work around this with some javascript though.

I agree. Here's the link: http://aspose.com/file-tools
subject: passing formBeans to tiles...
Similar Threads
How to iterate over one List and get a nested property defined in a different List
including page with a non-string object
Struts Tiles Inheritance problem
passing html tags through tile
how to combine html:text and bean:write