Is there a way to load mutiple ModelDriven models for one action class or swtich the model on one action class in struts2?
Asked
Active
Viewed 647 times
2
-
why you need multiple model for a single action? the second part of your question is not clear enough, can you rephrase that? – Umesh Awasthi Feb 29 '12 at 01:13
1 Answers
1
You can return arbitrary objects through ModelDriven
by using ModelDriven<Object>
. This is often used in CRUD actions to return either a list of domain objects, or a single domain object.
Alternatively, a model object may be composited from other objects, for example, a UserModel
might have both List<User>
and User
properties, each filled with data when appropriate. The properties don't need to be the same type, though, so a model might have User
properties, and a list of Headline
s or something.

Dave Newton
- 158,873
- 26
- 254
- 302