Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <f:form action="#" method="post">
- <f:hidden name="id" />
- </f:form>
- <form action="#" method="post">
- <f:hidden name="id" />
- </form>
- public class HiddenTag extends SimpleTagSupport{
- @Override
- public void doTag() throws JspException, IOException {
- try {
- /*
- * Start Velocity
- * */
- VelocityEngine ve = new VelocityEngine();
- ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "class");
- ve.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
- ve.init();
- VelocityContext context = createContext();
- StringWriter writer = new StringWriter();
- /*
- * Get Open Tag
- * */
- Template template = ve.getTemplate("form.vm");
- template.merge(context, writer);
- /*
- * Get Body Tag
- *
- * I THINK THE ERROR IS HERE
- *
- * */
- JspFragment body = getJspBody();
- body.invoke(writer);
- /**/
- /*
- * Get Close Tag
- * */
- template = ve.getTemplate("form-close.vm");
- template.merge(context, writer);
- getJspContext().getOut().println(writer.getBuffer());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.6.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-tools</artifactId>
- <version>2.0</version>
- </dependency>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement