| | |
| | |
| | When [Groovy|http://groovy.codehaus.org/] is present in the classpath of the web application, it's now possible to implement elements in this very nice scripting language. The only requirement is that the source files have to have the .groovy extension. |
| | |
| | For example, {{Simple.groovy}}: |
| | |
| | {code:java} |
| | import com.uwyn.rife.engine.Element |
| | |
| |  | class Simple extends Element |
| | | class simple extends Element |
| | { |
| | void processElement() |
| | { |
| | if (hasSubmission("login")) |
| | { |
 |  | printContent(getParameter("login")+","+getParameter("password")) |
| | | print(getParameter("login")+","+getParameter("password")) |
| | } |
| | else |
| | { |
| | switch (getInput("input1")) |
| | { |
| | case "form": |
 |  | printContent(<<<EOS |
| | |
| | | print(""" |
| | <html><body> |
| | <form action="${getSubmissionQueryUrl("login")}" method="post"> |
| | <input name="login" type="text"> |
| | <input name="password" type="password"> |
| | <input type="submit"> |
| | </form> |
| | </body></html> |
 |  | EOS) |
| | | """) |
| | break |
| | default: |
 |  | printContent(getInput("input1")+","+getInput("input2")) |
| | | print(getInput("input1")+","+getInput("input2")) |
| | break |
| | } |
| | } |
| | } |
| | } |
| | {code} |
 | | |
| | {panel:title=Important Note|borderStyle=dashed|borderColor=orange|borderWidth=1|bgColor=#ffffee|titleBGColor=#ffeebb} |
| | Current versions of Groovy have a bug that makes it impossible to use RIFE's {{print}} method. Therefore, {{printContent}} methods have been added that simply wrap around the {{print}} methods. |
| | |
| | You can track [GROOVY-105|http://jira.codehaus.org/browse/GROOVY-105] to check when it's resolved. |
| | {panel} |