Changes for page Groovy in Java EE with Maven
on 2012/04/17 06:12
on 2012/04/17 06:21
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -54,3 +54,46 @@ 54 54 </dependency> 55 55 56 56 4) Download a copy of groovy-all-1.8.4.jar and copy it into the glassfish lib folder (partial path on my system is .../glassfish-3.1.2/glassfish/lib/groovy-all-1.8.4.jar). 57 + 58 + 59 +---- 60 + 61 +With that bit of initial configuration out of the way we can now use Groovy quite seemlessly in our project. 62 + 63 + 64 +== Create a Struts2 action (will use the struts2 conventions plugin to avoid needless configuration) == 65 + 66 +(% style="font-weight: bold;" %)In Netbeans 7.1, create a new package under source packages called com.kenmcwilliams.action.groovy. 67 + 68 +(% style="font-weight: bold;" %)Right click that folder and create a new groovy file (New->Other->Category:Groovy->Groovy Class).(% style="font-weight: normal;" %) If the following options does not exist you will need at add Groovy **(Tools(menu)->Plugins->Availible Plugins(tab)->select "Groovy and Grails")**(%%). 69 + 70 +//package com.kenmcwilliams.action.groovy// 71 +//import com.opensymphony.xwork2.ActionSupport;// 72 +//import com.opensymphony.xwork2.Action;// 73 +\\// class Gest extends ActionSupport{// 74 +// String greeting = "Hello from Groovy!";// 75 +// public String execute(){// 76 +// println "Grooooovy!"// 77 +// return "success";// 78 +// }// 79 + //}// 80 + 81 +Create a view to render the action: 82 + 83 +//<%@taglib prefix="s" uri="/struts-tags"%>// 84 +//<%@page contentType="text/html" pageEncoding="UTF-8"%>// 85 +//<!DOCTYPE html>// 86 +//<html>// 87 +// <head>// 88 +// <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">// 89 +// <title>Message from Groovy</title>// 90 +// </head>// 91 +// <body>// 92 +// <h1>Message from Groovy</h1>// 93 +// <s:property value="greeting"/>// 94 +// </body>// 95 +//</html>// 96 + 97 + 98 +That's all there is to it! 99 +