FreeMarker tags are extensions of the generic Tags provided by the framework. You can get started almost immediately jump right in just by knowing the generic structure in which the tags can be accessed: <@saf.xxx> ...</@saf.xxx>, where xxx is any of the tags supported by the framework.
Syntax
For example, in JSP you might create a form using SAF tags.
...
In FreeMarker the same form can also be built using SAF tags.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<@saf.form action="updatePerson"> <@saf.textfield label="First name" name="firstName"/> <@saf.submit value="Update"/> </@saf.form> |
But, wait there's more!
Aside from doing everything that the JSP tags do, the FTL tags boast some advanced features that you can use to make your pages even easier to code. You can even invoke third-party JSP taglibs as if there were native FTL tagsWhile this covers almost all know need to know for for FreeMarker tags, there are a few other advanced features you should read about, specifically with how attributes and parameters work together, and how attribute types (String, List, etc) can affect the tag behavior.
Attributes and Parameters
...
In the new template, the description is referenced via the parameters Map: "${parameters.description}".{
Tip |
---|
...
|
...
|
...
For simple cases, inline attributes are much easier to use than the |
...
Attribute Types
Remember that all tag attributes must first be set as Strings – they are then later evaluated (using OGNL) to a different type, such as List, int, or boolean. This generally works just fine, but it can be limiting when using FreeMarker which provides more advanced ways to apply attributes. Suppose the following example:
...