wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts2 Action + 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 Action + Model" Watch "Struts2 Action + Model" New topic
Author

Struts2 Action + Model

Ajay Jeswani
Greenhorn

Joined: Feb 17, 2008
Posts: 5
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

Joined: Sep 29, 2008
Posts: 12617


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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 Action + Model
 
Similar Threads
Tags in struts2
struts2 problem
struts2
Model Object is not working in struts2