|
Views
First of all be sure to understand what Spring views are. Alfresco @MVC uses mainly Json views for data communication and Jsp views when a javascript needs to be processed on the server side. This is just an example of how this could be used with common knowledge and without learning any new framework. Alfresco @MVC will just provide the webscript to integrate Spring @MVC and the taglibs exposing Alfresco's functionality. Tiles2 viewThis samples uses Tiles 2.2.0 which is not supported out of the box by Spring 3.0.0, therefore you need to configure the following class to be used instead of the default one <bean class="com.gradecak.alfresco.mvc.view.tiles2.TilesConfigurer" id="tilesConfigurer"> <property name="definitions"> <list> <value>/WEB-INF/classes/alfresco/module/hr.croatiaosiguranje.webscan/views/**/views.xml </value> </list> </property> </bean> Jackson viewThis view is managed by Spring @ResponseBody and for those who are not familiar with it I can recommend to check this article Be sure to include Jackson libraries on your classpath and to have <annotation-driven></annotation-driven> enabled in your application context. The last thing to ensure is that your client application is sending a header parameter "Accept:application/json" in order to receive a json response, otherwise the server will not be able to detect what http media you need. Here is a general usage example @RequestMapping(value = "user/list", method = RequestMethod.GET )
public @ResponseBody Map<String, Object> getUsers(HttpServletRequest request) {
final Map<String, Object> modelMap = new HashMap<String, Object>();
List<PlmUser> rows = userService.getAllUsers();
modelMap.put("rows", rows);
modelMap.put("totalCount", rows.size());
modelMap.put("success", true);
return modelMap;
}Jsp viewAs this is a standard Spring feature, used with Tiles or not, I will not describe it here but can again point you to the Spring framework documentation. <html xmlns:jsp="http://java.sun.com/JSP/Page">
<jsp:output omit-xml-declaration="yes" />
<jsp:directive.page contentType="text/html;charset=UTF-8" />
<head>
...
</head>
<body>
...
</body>
</html>
|