view

scriptcontextname: js, scriptcontext: org.tagnetic.core.scriptcontext.implementer.javascript.JavaScriptContext
Defines the set of tags that are considered part of the "View" in a MVC design. These tags and any script that they use will be "run" or executed at the time that the source files are transformed into the destination files. No context about a particular user's data, session or request should be used as part of these tags. For tags that deal with that sort of information, use the ctrl tags.

define

classname: org.tagnetic.core.tags.define.Define
Defines a variable for use in scripting. The value can be specified in the body of the tag. Both of these examples define a script variable foo with the value of bar:
  • <view:define name="foo" value="bar"/>
  • <view:define name="foo">bar</view:define>

name REQUIRED

The name of the variable.
  • property: name
  • default:

value

The value of the variable.
  • property: value
  • default:

valueisvar

A boolean value "true" or "false") indicating that the variable value is not a literal (string, boolean, or number literal), but the name of an existing variable.
  • property: valueisvar
  • default:

def

classname: org.tagnetic.core.tags.define.DefineInclude

Allows a short-hand way to declare many simple variables as attributes of the def tag. Only supports values that are literals. Use the view:define tag for non-literal values.

Example: <view:def color="blue" shape="round"/> will create two script variables, color with a value of blue and shape with a value of round.

out

classname: org.tagnetic.core.tags.define.Out

Prints out a script variable. There are a few forms the out tag can take:

  • <view:out name="variableName">defaultValue</view:out>, where variableName is the script variable name, and defaultValue is the value that will be printed out if variableName is empty.
  • &view:out-variableName; or &view:out-name:variableName;, where variableName is the script variable name. A defaultValue is not supported with this syntax. This syntax is the alternate tag syntax defined in TagMatchers.xml.

(To support these multiple syntaxes, a name attribute is not formally declared on this tag. Instead the dynamic attributes are used to figure out the name of the script variable.)

include

classname: org.tagnetic.core.tags.define.DefineInclude
Includes the contents of a page that is specified by the path attribute.

path

The path to the file to include. This path should be relative to the page that is using the include tag.
  • property:
  • default:

newscope

By default, the include tag creates a new script scope for the tags used in the body of the include tag, as well as the file that is included as part of the include tag. This can be changed on a tag by tag basis by including this attribute on the particular include tag.
  • property:
  • default: true

includeparam

classname: org.tagnetic.core.tags.define.IncludeParam

Used inside a page that is included by another page. It allows the included page to specify a script variable that is required by the included page. If the page that includes the included file does not define that variable, an exception will be generated, unless a default value is specified as part of this tag. A default value is specified in the body of the tag. Examples:

<view:includeparam name="foo"/> (Will throw exception if foo is not defined)

<view:includeparam name="foo">defaultValue</view:includeparam> (If foo is not defined by the including page, then foo's value will be defaultValue.)

name REQUIRED

The name of the script variable.
  • property: name
  • default:

resourcebundle

classname: org.tagnetic.core.tags.resource.Bundle
Specifies a Java Resource Bundle to be used in the page. Use the view:res tag to output a specific resource, based on the currently defined locale. Locales are defined in a tagneticconfig file's compilation child elements.

name REQUIRED

The name to identify this bundle. Used in the view:res tag to limit the search scope when trying to print out a resource.
  • property: name
  • default:

base REQUIRED

The Java package/class name that is the base of the resource bundle.
  • property: base
  • default:

res

classname: org.tagnetic.core.tags.resource.ResourceOut

Prints out a resource value, based on the currently defined locale. The resource must be located in a bundle that was defined with the view:resourcebundle tag. The bundle attribute of this tag can be used to specify a specifc bundle to use to find the resource. If no bundle name is specified, then all resource bundles that were defined as part of the page will be searched. There are a few forms the out tag can take:

  • <view:res name="resName">defaultValue</view:out> or <view:res name="resName" bundle="bundleName">defaultValue</view:out>, where resName is the script variable name, and defaultValue is the value that will be printed out if resName is empty.
  • &view:out-resName; or &view:out-name:resName; or &view:out-name:resName-bundle:bundleName;, where resName is the script variable name. A defaultValue is not supported with this syntax. This syntax is the alternate tag syntax defined in TagMatchers.xml.

(To support these multiple syntaxes, a name attribute is not formally declared on this tag. Instead the dynamic attributes are used to figure out the name of the resource key.)

bundle

A name of a bundle, to limit the search scope for finding the resource. This name should match the value given in the name attribute of the view:resourcebundle tag.
  • property: bundle
  • default:

choose

classname: org.tagnetic.core.tags.logic.Choose

A wrapper tag that is required if the view:elsif and/or view:else tags are to be used with a view:if tag. Example:

<view:choose> <view:if><view:test>value == 'one'</view:test> Value is one. </view:if> <view:elseif><view:test>value == 'two'</view:test> Value is two. </view:elseif> <view:else> Value is not one or two. </view:else> </view:choose>

if

classname: org.tagnetic.core.tags.logic.If

Only includes the body of the tag if a view:test expression evaluates to true in the scripting language. There are two ways to use this tag:

  • Single if statement, no associated elseif/else cases:
    <view:if><test>value == 'one'</test></view:if>
  • Part of a if/elseif/else set (see view:choose example).

elseif

classname: org.tagnetic.core.tags.logic.ElseIf

Used as part of an if/elseif/else set. It should have a nested view:test tag. See view:choose example.

else

classname: org.tagnetic.core.tags.logic.Else

Used as part of an if/elseif/else set. The body of the tag is included in the page output when the associated if/elseif tests fail. See view:choose example.

test

classname: org.tagnetic.core.tags.logic.Test

Used as a child of view:if or view:elseif. The body of the view:test tag is a script expression that should be interpreted as a true/false result. The boolean result is communicated to the parent view:if or view:elseif tag. See view:choose example for usage.

The body of the tag does *not* have to be XML escaped (for instance, < does not have to be written as &lt;). This means the source document that has this tag will not validate as valid XML. If you want have the source validate, then declare an overlay in your tagnetic config file that will XML unescape the body of the tag before it is sent to the script engine. Make sure to set the priority to 0 so that the overlay executes before the normal view:test tag handler.

<tags nsprefix="view" scriptcontextname="js" scriptcontext="org.tagnetic.core.scriptcontext.implementer.javascript.JavaScriptContext"> <tag name="test" classname="org.tagnetic.core.tags.XmlUnEscapeTag" priority="0"/> </tags>

If you use the overlay, then you can write the script in XML escaped format. For instance, the script expression "value < 5" would be written as: <view:test>value &lt; 5</view:test>.

script

classname: org.tagnetic.core.tags.ScriptTag

The body of the tag does *not* have to be XML escaped (for instance, < does not have to be written as &lt;). This means the source document that has this tag will not validate as valid XML. If you want have the source validate, then declare an overlay in your tagnetic config file that will XML unescape the body of the tag before it is sent to the script engine. Make sure to set the priority to 0 so that the overlay executes before the normal view:script tag handler.

<tags nsprefix="view" scriptcontextname="js" scriptcontext="org.tagnetic.core.scriptcontext.implementer.javascript.JavaScriptContext"> <tag name="script" classname="org.tagnetic.core.tags.XmlUnEscapeTag" priority="0"/> </tags>

If you use the overlay, then you can write the script in XML escaped format. For instance, the script expression "value = ''" would be written as: <view:script>value = '&lt;weirdstring&gt;'</view:script>.

foreach

classname: org.tagnetic.core.tags.logic.ForEach

Allows iteration over simple integer increment count, a script array, or the properties in a script object. Each successful iteration will output the body of the tag.

  • Integer iteration: To use a simple iteration, do not specify a value for the object attribute. The start and end attributes are required. The example below iterates to 10 in steps of 2. The body of the view:foreach tag will be outputted 5 times. loopStatus is the default loopstatusvar. See that attribute for details:

    <view:foreach start="0" end="10" step="2"> Index value is: <view:out name="loopStatus.currentIndex"/><br> </view:foreach>

  • Array iteration: To iterate over a script array, give the script array variable name as the value to the object attribute. The start, end, and step attributes can be used to control what array indices are used in the iterations. Example:

    <view:script> function Pair(name, value) { this.name = name; this.value = value; } var testArray = new Array(); testArray[0] = new Pair('heavy', 'blue'); testArray[1] = new Pair('light', 'green'); testArray[2] = new Pair('heavy', 'red'); </view:script> <view:foreach object="testArray" var="pair"> <p>Current index is [&view:out-loopStatus.currentIndex;]<br> Current loop count is [&view:out-loopStatus.loopCount;]<br> My pair's weight is [&view:out-pair.name;], color is [&view:out-pair.value;]</p> </view:foreach>

  • Object member iteration: iterates over the members of an object. Similar to the for (param in object) iteration available in javascript. To use this type of iteration, give the script variable name for the object as the value of the object attribute. The The start, end, and step attributes don't have meaning in this type of iteration. Example:

    <view:script> var testObject = { name: 'Washing machine', stockNumber: 3343200, price: '$2.00', quantity: 5 }; </view:script> <view:foreach object="testObject" var="propValue"> Member name: [&view:out-loopStatus.propertyKey;], value is [&view:out-propValue;]<br /> </view:foreach>

object

The script variable name that is a reference to either an array or object. See examples in the general tag description above for more information.
  • property: object
  • default:

var

The script variable that will hold a reference to the value/object that is at the current index in the array for array iteration, or a reference to the value of the current object member for object iteration. If no value is given, then no variable will be set. See examples in the general tag description above for more information.
  • property: var
  • default:

start

An integer literal or a script variable that evaluates to an integer value. Specifies the start position for the foreach tag in integer or array iteration. See examples in the general tag description above for more information.
  • property: start
  • default:

end

An integer literal or a script variable that evaluates to an integer value. Specifies the end position for the foreach tag in integer or array iteration. See examples in the general tag description above for more information.
  • property: end
  • default:

step

An integer literal or a script variable that evaluates to an integer value. Specifies the step amount that should be used in integer or array iteration. See examples in the general tag description above for more information.
  • property: step
  • default:

loopstatusvar

The variable name for a script object that contains information about the current iteration. If this attribute is not set, then a default name will be used: loopStatus. The object has the following properties:
  • start: integer specifying the start value for the iterations.
  • end: integer specifying the end value for the iterations.
  • currentIndex: integer value of the current iteration.
  • isFirst: boolean indicating if this is the first iteration.
  • isLast: boolean indicating if this is the last iteration.
  • loopCount: integer counting the number of actual iterations. Value starts at 1.
  • property: loopstatusvar
  • default:

xmldatasource

classname: org.tagnetic.core.tags.datasource.XmlDataSource

Loads XML into a script variable. If javascript is the script language, then the E4X language extensions are used to manipulate the data in script.

var REQUIRED

The script variable name that will hold the XML content.
  • property: var
  • default:

path

The path to the XML file. The path is considered relative to the page that is using the xmldatasource tag.
  • property: path
  • default:

tagcollection

classname: org.tagnetic.tagneto.tags.view.TagCollection

Inserts the collection of tags that match the name attribute. It essentially dumps the tags that are collected by the TagCollector class. The TagCollector class is used in HtmlTags.xml to collect script, link and style tags.

You do not need to use the tagcollection tag if you want the collected tags to be inserted as children of the HTML HEAD element. The TagCollector class automatically puts in a post file filter that uses the TagCollection class to insert all collected tags in the HEAD element.

However, if you want more control over where the tags are outputted, use this tag. Once the collection of tags with the specified tag name is outputted with this tag, they will not be dumped as part of the post file filter process in the HEAD area.

name REQUIRED

The name of the type of collected tag to output, for instance script or link.
  • property: name
  • default:

noparse

classname: org.tagnetic.core.tags.NoParseTag
Instructs the parser not to parse any tags in the body of the tag.

htmlescape

classname: org.tagnetic.tagneto.tags.html.HtmlEscapeTag

HTML-escapes some characters in the body of the tag:

  • < converts to &lt;
  • > converts to &gt;
  • & converts to &amp;
Copyright © 2005 tagnetic.org.