2

Is there a way to load mutiple ModelDriven models for one action class or swtich the model on one action class in struts2?

Matt
  • 74,352
  • 26
  • 153
  • 180
user1055108
  • 125
  • 3
  • 9
  • 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 Answers1

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 Headlines or something.

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