Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 Action + Model

 
Ajay Jeswani
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys !!

1) Is it suppose to use action class as model class in Struts2, no need for separate model ?
2) Which is the best template engine which can be used with Struts2 ?
3) Has validation is different in Struts2 ?

Thanks and regards,
Ajay
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1) Is it suppose to use action class as model class in Struts2, no need for separate model?

That is one approach, although it's very easy to use one or more domain objects as action properties and use their properties on the web page either has form properties or just displayable properties.

There is also use the ModelDriven approach, which is (sort of) similar to ActionForms from Struts 1. See the ModelDriven interceptor docs.

2) Which is the best template engine which can be used with Struts2?

"Best" is somewhat subjective, of course. Out of the box Struts 2 supports JSP, FreeMarker, and Velocity. I'm not very familiar with the Velocity support; both JSP and FreeMarker work well.

3) Has validation is different in Struts2?

Yes, although it's somewhat similar. JavaScript (client-side) validation is somewhat less flexible in Struts 2 (compared to Struts 1), although there's a patch going in soon that alleviates that somewhat. Server-side validation, IMO, is better under Struts 2 than Struts 1, due partially to Struts 2's type conversion capabilities. Type conversion converts form string data into domain objects via an interceptor, rather than in the main code. See the Validation page and the Type Conversion page.

Dave
[ November 11, 2008: Message edited by: David Newton ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic