Class ConfirmationTag

All Implemented Interfaces:
freemarker.template.TemplateDirectiveModel, freemarker.template.TemplateModel, RequestAccess

public class ConfirmationTag extends FreeMarkerTag
Simple confirmation tag. Will generate an HTML anchor tag with a snippet of JavaScript. When clicked, it will popup a JavaScript confirmation message dialog before submitting a form.
Required attributes:
  • text - this is a message text to display in the confirmation dialog
  • form - this is an ID of a form to submit in case user pressed "OK"

In the example below, it is assumed that there is an object in scope named "post" with at least two properties: "title" and "id".

 <@confirm text="Are you sure you want to delete post: \\\'${post.title}\\\'?">Delete</@confirm>

    <@form controller="posts" action="delete" method="delete">
        <input type="hidden" name="id" value="${}">
The code above will generate the following HTML:
  <a href="#" onClick="if(confirm('Are you sure you want to delete post: \'ActiveWeb Rocks.\'?')) { $('#' + 17).submit(); return true; } else return false;">Delete</a>

    <form action="/kitchensink/posts/delete" method="post" id="17">
        <input type='hidden' name='_method' value='delete' />    <input type="hidden" name="id" value="17">
Igor Polevoy
  • Constructor Details

    • ConfirmationTag

      public ConfirmationTag()
  • Method Details

    • render

      protected void render(Map params, String body, Writer writer) throws Exception
      Description copied from class: FreeMarkerTag
      Implement this method ina concrete subclass.
      Specified by:
      render in class FreeMarkerTag
      params - this is a list of parameters as provided to tag in HTML.
      body - body of tag
      writer - writer to write output to.
      Exception - if any