Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <f:form action="#" method="post">
  2. <f:hidden name="id" />
  3. </f:form>
  4.  
  5. <form action="#" method="post">
  6. <f:hidden name="id" />
  7. </form>
  8.  
  9. public class HiddenTag extends SimpleTagSupport{
  10.  
  11. @Override
  12. public void doTag() throws JspException, IOException {
  13. try {
  14. /*
  15. * Start Velocity
  16. * */
  17. VelocityEngine ve = new VelocityEngine();
  18. ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "class");
  19. ve.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
  20. ve.init();
  21.  
  22. VelocityContext context = createContext();
  23.  
  24. StringWriter writer = new StringWriter();
  25.  
  26.  
  27. /*
  28. * Get Open Tag
  29. * */
  30. Template template = ve.getTemplate("form.vm");
  31. template.merge(context, writer);
  32.  
  33.  
  34. /*
  35. * Get Body Tag
  36. *
  37. * I THINK THE ERROR IS HERE
  38. *
  39. * */
  40. JspFragment body = getJspBody();
  41. body.invoke(writer);
  42. /**/
  43.  
  44. /*
  45. * Get Close Tag
  46. * */
  47. template = ve.getTemplate("form-close.vm");
  48. template.merge(context, writer);
  49.  
  50. getJspContext().getOut().println(writer.getBuffer());
  51.  
  52. } catch (Exception e) {
  53. e.printStackTrace();
  54. }
  55. }
  56.  
  57. }
  58.  
  59. <dependency>
  60. <groupId>org.apache.velocity</groupId>
  61. <artifactId>velocity</artifactId>
  62. <version>1.6.2</version>
  63. </dependency>
  64.  
  65. <dependency>
  66. <groupId>org.apache.velocity</groupId>
  67. <artifactId>velocity-tools</artifactId>
  68. <version>2.0</version>
  69. </dependency>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement