Generic Tags

When pages are being rendered Generic Tags control the execution flow. Struts 2 Generic tags are also used for data extraction. Struts 2 Tags are of two types: Generic Tags and UI tags. Generic Tags are further classified into Control Tags and Data Tags while Struts UI Tags are classified into Form Tags and Non - Form tags.

Generic Tags


Generic Tags

When pages are being rendered Generic Tags control the execution flow. Struts 2 Generic tags are also used for data extraction.

Struts 2 Tags are of two types: Generic Tags and UI tags. These tags are provided with the Struts 2 framework. Generic Tags simply output some content directly from the tag while the UI tags uses templates and often group the output together with theme.

Generic Tags are further classified into Control Tags and Data Tags while Struts UI Tags are classified into Form Tags and Non - Form tags.

Control Tags:

  • if: tag could be used by itself
  • else-if: tag could be used with if tag
  • else: tag could be used with if tag
  • append: tag is used to merge multiple iterators into one iterator.
  • generator: is used to generate iterators based on different attributes passed.
  • iterator: tag is used to iterate over a value. An iterable value can be either of: java.util.Collection, java.util.Iterator.
  • merge: tag is used to merge iterators.
  • sort: sorts a List using a Comparator
  • subset: tag takes an iterator and outputs a subset of it.

Data Tags:

Data Tags is Struts 2 are used by developers to make GUI for their struts 2 based applications. They help in data manipulation or creation.

  • a Tag: renders HTML <a> tag.
  • action Tag: by specifying the action name, a developer can call the actions directly from a JSP page.
  • bean Tag: instantiates a class that confirms JavaBeans specification. The body of the tag contains a number of Param elements to set any changeful methods on that class.
  • date Tag: formats Date quickly and easily.
  • debug Tag:
  • i18n Tag:
  • include Tag: allows inclusion of JSP file in another JSP page.
  • param Tag: parameterizes other tags. It has two parameters: name (String) parameter and value (Object) parameter
  • push Tag: pushes value on stack for ease
  • set Tag: assigns a variable to a complex expression so that once can refer the variable each time rather than the complex expression
  • text Tag: renders a i18n text message
  • url Tag: creates URL
  • property Tag: gets the property of a value