This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts2 Model Driven question for a complex model 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 "Struts2 Model Driven question for a complex model" Watch "Struts2 Model Driven question for a complex model" New topic
Author

Struts2 Model Driven question for a complex model

sam jsem
Greenhorn

Joined: Mar 12, 2011
Posts: 9
Hi all.

I am using Struts 2.2.1; and, I have the following concern: I have an object A which has reference to three other objects: B, C, D. In my JSP I make reference to properties in all A, B, C and D. I call an action which implements the ModelDriven Interface.







However, the only properties that gets populated are the simple properties of A. I was under the impression that ModelDriven would populate the entire object graph for you, namely, all the properties of A, B, C and D. I have tested various notation in my JSP including:

Parent.Child.Property



Child.Property



Property



No luck. I believe that it is possible to populate an object graph based on ModelDriven. Am I correct in thinking this? Could you please offer some advice if I am correct in thinking this?

Thanks.
Dejan Lazovic
Greenhorn

Joined: May 11, 2011
Posts: 3
sam jsem wrote:I believe that it is possible to populate an object graph based on ModelDriven.

That's right. Here's a working example I just put together:

Model and action classes:

Action configurations in struts.xml

JSP pages


Do you have the appropriate getter/setter methods implemented in your domain model classes? Are you using a custom interceptor stack?

Best regards
Dejan
Manuel Schenkhuizen
Greenhorn

Joined: Apr 20, 2011
Posts: 14
Since you have implementet ModelDriven,you do not need write "aaa.bbb.bid" in your select tag.
"bbb. bid" is enough.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 Model Driven question for a complex model
 
Similar Threads
Struts select tag problem
Not able to persist values of SELECT Tag in Struts 2.0
s:doubleselect exception/ error
headerKey in s:select tag in struts2.0
Error while forwarding from struts.xml