SharpTiles

R.Z. Slijp, 2008

The contents of this reference guide is based on the 'JSTL Quick Reference' by Bill Siggelkow(2003)

This document is not copyright protected. However the 'JSTL Quick Reference', which forms the base of this document, is copyrighted by Bill Siggelkow.


Expression language

In Attribute Values

  • <a:tag value="${expr}"/>
  • <a:tag value="me${expr} ${expr}"/>

Bean Property Acces

bean.name

Indexed Property Access

bean.property.index

Map Property Access

bean.property.key

In java dictionary and list access is done with brackets. SharpTiles deviates from this syntax. In SharpTiles access to properties, list, dictionaries is done with the same '.' notation.

For example:

   map["key"][i].property becomes map.key.i.property

The underlying implementation of the properties is now hidden from the view logic.

Operators

Arithmetic expressions

Operator Description
+ Addition
- Subtraction
* Multliplication
/  div Division
%  mod Remainder(modulo)
^  pow Power

Comparison expressions

Operator Description
<  lt Less than
>  gt Greater than
<=  le Less than or equal to
>=  ge Greater than or equal to
==  eq Equal to
!=  ne Not equal to

Boolean logic expressions

Operator Description
&&  and Logic and right parameter lazy evaluated
||  or Logic or right parameter lazy evaluated
!  not not

Other

Operator Description
(  )  , Paranthesis for changing operator precedence or used as parameters in function calls
@ String constant
' Constant (will be interpreted as bool or decimal if possible)

Operator precedence

Priority Operator
1 ^  pow
2 *
/  div
%  mod
3 +
-
!  not
4 ==  eq
!=  ne
5 >  gt
>=  ge
<  lt
<=  le
6 ||  or
7 &&  and
8 (  )  ,
9 fn:

Functions

Function Description
fn:length( IEnumerable object ) : integer If a collection or array is passed, the size of the collection or array is returned; If a string is passed, the number of characters in the string is returned.
fn:reverse( IEnumerable object ) : integer If a collection, string or array is passed. The order of the elements will be reversed.
fn:concat( string left, string right ) : string Concatenates the left string with the right string.
fn:empty( object arg ) : boolean True if the operand is null, an empty String, empty array, empty Map, or empty List; false, otherwise.
fn:contains( string source, string substring ) : boolean Returns true if substring is contained in source; false, otherwise.
fn:containsIgnoreCase( string source, string substring ) : boolean Returns true if substring is contained in source regardless of case; false, otherwise.
fn:indexOf( string source, string substring ) : boolean Returns an integer representing the 0-based index within source of the first occurrence of substring. If substring is empty, 0 is returned.
fn:startsWith( string source, string prefix ) : boolean Returns true if source starts with the specified prefix; false, otherwise.
fn:endsWith( string source, string suffix ) : boolean Returns true if source ends with the specified suffix; false, otherwise.
fn:replace( string source, string oldValue, string newValue ) : string Replaces in source, every occurrence of beforeString with afterString. An empty string is returned if either inputString or beforeString is empty. If afterString is empty, all occurences of the beforeString are removed.
fn:join( string[] parts, string seperator ) : string Joins all elements of the parts into a single string. Separator separates each element in the resulting string. If separator is an empty string, the elements are joined without a separator.
fn:split( string source, string seperator ) : string[] Splits string into a string array using the given set of delimiter characters. The delimiter characters are not included in any returned tokens.
fn:escapeXml( string source ) : boolean Escapes characters (e.g changing "<" to "& lt;") that could be interpreted as XML (including HTML) markup.
fn:toLowerCase( string source ) : boolean Converts all characters of a string to lowercase.
fn:toUpperCase( string source ) : boolean Converts all characters of a string to uppercase.
fn:trim( string source ) : boolean Removes whitespace from both ends of a string.
fn:substring( string source, integer start, integer end ) : string Returns a subset of source using the zero-based indices – inclusive of the begin index, but exclusive of the end index.
fn:substringBefore( string source, string before ) : string Returns the subset of source that procedes the given substring.
fn:substringAfter( string source, string after ) : string Returns the subset of source that succedes the given substring.

Tags

c - Core Tag Library

The core tag lib provides basic functionality for page flow, rendering and handling variables.

General-Purpose Actions


Actions for rendering data, creating and modifying scoped variables, and catching exceptions.

<c:out>

- renders data to the page

<h2>Welcome, <c:out value="${user.name}" default="Guest"/></h2>

Attribute Description Required Default
Value Data to output False Default
Default Fallback data to output if value is empty False Body
EscapeXml true to escape special characters False 'True'

<c:set>

- saves data to a scoped variable

<c:set var="dogAge" value="${age div 7}"/> You are <c:out value="${dogAge}"/> in dog years.

Attribute Description Required Default
Value Data to save No Body False Body
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. True

<c:remove>

- deletes a scoped variable

<c:remove var="dogAge" scope="page"/>

Attribute Description Required Default
Var Name of variable or property to delete. Deleting of properties is done by setting the value of properties to null. True
Scope Scope of variable. False 'Page'

<c:catch>

- traps all exceptions or errors from the enclosed body.

<c:catch var="err">
   <c:import value="http://www.sharptiles.org"/>
</c:catch>
<c:if test="${not empty err}">
   Could not connect to Sharptiles web site.
</c:if>

Attribute Description Required Default
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False
Scope Scope of variable. False 'Model'

Conditional Actions


Actions for processing markup based on logical conditions.

<c:if>

- processes the body if test is true
Attribute Description Required Default
Test Condition to evaluate. True 'False'
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

<c:choose>

- multiple conditions - processes the body of the first enclosed when tag where the test condition is true. If none match then the body of the otherwise tag (if present) is processed.

<c:choose>
   <c:when test="${a boolean expr}">
      // do something
   </c:when>
   <c:when test="${another boolean expr}">
      // do something else
   </c:when>
   <c:otherwise>
      // do this when nothing else is true
   </c:otherwise>
</c:choose>

<c:when>

- processes the body if test is true and no other previous <c:when> tags evaluated to true.
Attribute Description Required Default
Test Condition to evaluate. True 'False'

<c:otherwise>

- processes the body if no other previous <c:when> condition was matched. This tag accepts no attributes and, if present, must be the last tag in the <c:choose> body.

Iterator Actions


Actions that loop over collections, for a fixed number of times, or over a set of string tokens. These actions share a lot of the same attributes for iterating over a subset of elements.

<c:forEach>

- repeats the nested body content over a collection or for a fixed number of times.

<c:forEach items="${user.languages}" var="lang" varStatus="status">
   <c:if test="${status.first}">
      You speak these languages:<br/><ul>
   </c:if>
   <li><c:out value="${lang}"/></li>
   <c:if test="${status.last}"></ul></c:if>
</c:forEach>

Attribute Description Required Default
Items Collection, iterator, map, or array to loop over. True
Begin Zero-based index of first item to process, inclusive. False '0'
End Zero-based index of last item to process, inclusive. False
Step Process every stepth element (e.g 2 = every second element). False '1'
Var Name of variable to hold the current item. This variable has only nested visibility. False 'Item'
VarStatus Name of variable to hold the loop status with the following properties:
  • index - position of the current item
  • count - number of times through the loop (starting with 1)
  • first - boolean indicator if this is the first iteration
  • last - boolean indicator if this is the last iteration
False 'Status'

<c:forTokens>

- repeats the nested body content for each token of a delimited string.

<c:set var="users">Fred,Joe,Mary<c:set>
   <c:forTokens var="name" items="${users}" delims=",">
   <c:out value="${name}"/><br/>
</c:forTokens>

Attribute Description Required Default
Items String of tokens to loop over. True
Delims Set of characters that separate the tokens (e.g. delims=",;" will tokenize a string separated by commas or semi-colons). True
Begin Zero-based index of first item to process, inclusive. False '0'
End Zero-based index of last item to process, inclusive. False
Step Process every stepth element (e.g 2 = every second element). False '1'
Var Name of variable to hold the current item. This variable has only nested visibility. False 'Item'
VarStatus Name of variable to hold the loop status with the following properties:
  • index - position of the current item
  • count - number of times through the loop (starting with 1)
  • first - boolean indicator if this is the first iteration
  • last - boolean indicator if this is the last iteration
False 'Status'

URL Related Actions


Actions for importing content from URLs, building URLs, and redirecting.

<c:url>

- builds a URL with the proper rewriting rules applied (only relative URLs are rewritten). Action may include nested <c:param> tags to specify the query string.

<c:url="editProfile.do" var="profileLnk">
      <c:param name="id" value="${user.id}"/>
</c:url>
<a href='<c:out value="${profileLnk}"/>'>
      Edit Profile
</a>

Attribute Description Required Default
Value URL to be processed. True
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

<c:import>

- imports the content of a URL-based resource. Action may include nested <c:param> tags to specify the query string (unless the varReader attribute is specified).

<c:import url="includes/header.aspx">
   <c:param name="title">Hello World</c:param>
</c:import>

Attribute Description Required Default
Url URL of the resource to import. True
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

<c:redirect>

- sends the client a response to redirect to the specified URL. This action will abort processing of the current page. Action may include nested <c:param> tags to specify the query string.

<c:if test="${empty user}">
   <c:redirect url="login.aspx"/>
</c:if>

Attribute Description Required Default
Url URL of the resource to redirect to. True

<c:param>

- adds request parameters to a URL. This action can only be nested within <c:import>, <c:url>, or <c:redirect>.
Attribute Description Required Default
Name Name of the query string parameter. True
Value Value of the parameter. If not specified, value is taken from the tag body. False

fmt - Formatting Tag Library

The formatting tag lib handles the translations, character setsand the parsing and formatting of numbers and dates

Internationalization (I18N) Actions


Actions that establish localization (l10n) contexts, specify resource bundles, and format messages.

<fmt:setLocale>

- Sets the default locale for the specified scope. This will override the browserbased locale.

<fmt:setLocale scope="session" value="fr-CA"/>

Attribute Description Required Default
Value String representation of a locale (e.g. en-US) or an actual java.util.Locale object. True
Scope Scope to set the default locale for. False 'Page'

<fmt:requestEncoding>

- Instructs JSTL to use a specific character encoding (see http://www.iana.org/assignments/character-sets) to decode request parameters. Omitting a value indicates to use automatic detection of the proper encoding.

<fmt:requestEncoding key="UTF-7"/>

Attribute Description Required Default
Value Character encoding (e.g. "UTF-8") to use. True

<fmt:bundle>

- Sets the localization context, based on the specified resource bundle, to be used within the body content of this tag.

<fmt:bundle baseName="resources" prefix="label.">
   <fmt:message key="userId"/>
<fmt:bundle>

Attribute Description Required Default
BaseName Fully-qualified name of the base bundle without a file type (such as ".resx"). True
Prefix String prefix to be prepended to the value of the message key. Note that the prefix must include all characters – a separator character (e.g. ".") is not assumed. False

<fmt:setBundle>

- Creates and stores in a scoped variable, a localization context based on the specified resource bundle.

<fmt:setBundle baseName="ApplicationResources" var="tilesMessages" scope="Application"/>

Attribute Description Required Default
BaseName Fully-qualified name of the base bundle without a file type (such as ".properties"). True
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. True

<fmt:message>

- Looks up a localized message in a resource bundle. This tag can contain nested <fmt:param> tags to specify message format substitution values. The resultant message is printed or stored in a scoped variable.

<fmt:message key="title" bundle="${tilesMessages}"/>

Attribute Description Required Default
Key Message key to be looked up. True
Bundle Localization context (set by prio configuration, <fmt:bundle>, or <fmt:setBundle>, which specifies the resource bundle the message key is to be looked up in. False
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

<fmt:param>

- Supplies a parameter for message format substitution in a containing <fmt:message> tag. Parameters are substituted in sequential order.
Attribute Description Required Default
Value Value used for parametric message format substitution. False

Internationalization (I18N) Actions


Actions that format and parse numbers, currencies, percentages, dates and times.

<fmt:formatNumber>

- Formats a number, currency, or percentage in a locale-sensitive manner. The formatted value is printed or stored in a scoped variable.

<fmt:formatNumber type="Currency" value="3.977">

Attribute Description Required Default
Value Numeric value to format. False Body
Type Specifies the type of value. Valid values are:
  • Number
  • Currency
  • Percentage
False 'Number'
Pattern Custom formatting pattern (overrides other formatting options including type - see System.Globalization.NumberFormatInfo) False
CurrencyCode Currency code (ISO 4217) used for formatting currencies. Such as "USD" (US dollars) or "EUR" (euro). False
CurrencySymbol Currency symbol used when formatting currencies. Such as "$" for US dollars, or "F" for Francs. False CurrencyCode
GroupingUsed Specifies if grouping separators will be used (for example - formatting "23890" as "23,890"). False 'True'
MinFractionDigits Maximum number of digits to print in the fractional part of the number. False '2'
MaxFractionDigits Minimum number of digits to print in the fractional part of the number. False
MinIntegerDigits Maximum number of digits to print in the integer part of the number. False
MaxIntegerDigits Minimum number of digits to print in the integer part of the number. False
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

<fmt:parseNumber>

- Parses a String representing a number, currency, or percentage in a localesensitive manner. The parsed value is printed or stored in a scoped variable.

<fmt:parseNumber var="num" type="Number" Styles="AllowDecimalPoint,AllowThousands" value="2,447"/>
<c:out value="${num}"/>

Attribute Description Required Default
Value Value to parse. False Body
Type Specifies the type of value. Valid values are:
  • Number
  • Currency
  • Percentage
False 'Number'
Styles Specifies the number style of value as "," seperated list. Valid values are String representation of System.Globalization.NumberStyles:
  • None
  • AllowLeadingWhite
  • AllowTrailingWhite
  • AllowLeadingSign
  • Integer
  • AllowTrailingSign
  • AllowParentheses
  • AllowDecimalPoint
  • AllowThousands
  • Number
  • AllowExponent
  • Float
  • AllowCurrencySymbol
  • Currency
  • Any
  • AllowHexSpecifier
  • HexNumber
False
ParseLocale String representation of a locale (e.g. en_US) or an actual System.Globalization.CultureInfo object used for parsing. False
IntegerOnly Specifies if only the integer portion of the value should be parsed. False 'False'
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

<fmt:formatDate>

- Formats a date and/or time in a locale-sensitive manner. The formatted value is printed or stored in a scoped variable.

<fmt:formatDate value="${now}" pattern="yy-MMM-dd>"/>

Attribute Description Required Default
Value Date value to format. Value must be a System.Date object or String representation. False Body
Type Specifies the type of value. Valid values are:
  • Time
  • Date
  • Both
False
DateStyle Predefined formatting style for a date (ignored if type="time") - see System.Globalization.DateTimeFormatInfo
  • Default
  • Short
  • Long
False
TimeStyle Predefined formatting style for a time (ignored if type="date") - see System.Globalization.DateTimeFormatInfo. Valid values are:
  • Default
  • Short
  • Long
False
Pattern Custom formatting style (overrides type, dateStyle, and timeStyle) - see System.Globalization.DateTimeFormatInfo. False
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

<fmt:parseDate>

- Parses a string representing a date and/or time in a locale-sensitive manner. The parsed value is printed or stored in a scoped variable.

<fmt:parseDate var="bday" pattern="MM/dd/yy" value="05/10/63"/>
<fmt:formatDate value="${bday}" dateStyle="Long"/>

Attribute Description Required Default
Value Date/time string to parse. False Body
ParseLocale String representation of a locale (e.g. en_US) or an actual System.Globalization.CultureInfo object used for parsing. False
Exact Forces the date parser to do an exact parse. False 'True'
Type Specifies the type of value. Valid values are:
  • Time
  • Date
  • Both
False
DateStyle Predefined formatting style for a date (ignored if type="time") - see System.Globalization.DateTimeFormatInfo
  • Default
  • Short
  • Long
False
TimeStyle Predefined formatting style for a time (ignored if type="date") - see System.Globalization.DateTimeFormatInfo. Valid values are:
  • Default
  • Short
  • Long
False
Pattern Custom formatting style (overrides type, dateStyle, and timeStyle) - see System.Globalization.DateTimeFormatInfo. False
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

x - XML Tag Library

The XML tag library supports parsing of XML documents, selection of XML fragments, conditional and iterative processing based on XML content, and XSLT transformations. A common pattern for using the XML tags is as follows:
  1. Use <x:parse> to parse XML into a scoped variable. The XML can come from the body literally, from the body via <c:import>, or from the value attribute which may refer to any XML source. <x:parse var="varName" ...>
  2. Use the scoped variable from <x:parse> to specify the XML document to use in XPath expressions. <x:out source="${varName}" select="XPathexpression"/> The following example demonstrates the above techniques.

<x:parse var="doc">
   <users>
      <user id="997">
         <first-name>George</first-name>
         <last-name>Burdell</last-name>
      </user>
   <user id="998">
         <first-name>Joseph</first-name>
         <last-name>Blough</last-name>
      </user>
   </users>
</x:parse>

<c:set var="userId" value="${user.id}" scope="page"/>

<x:set var="user" source="${doc}" select="//users/user[@id=$pageScope:userId]"/>

Hi <x:out source="${user}" select="/first-name"/> !

General-Purpose Actions


Actions for parsing XML, outputting to the page, and selecting XML fragments. The examples that follow demonstrate use of the XML tags for processing Rich Site Summary (RSS) feeds. RSS has more or less the following format:

<x:parse>

- Parses XML content, provided by the value attribute or the tags body, into a scoped variable(s). This variable can then be used for subsequent processing by other XML tags.

<c:import var="rss" url="http://news.google.com/?output=rss"/>
<x:parse var="news" xml="${rss}"/>

Attribute Description Required Default
Doc Text of the document to a parse as a String or Reader False Body
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. True

<x:out>

- Prints the result of the XPath expression as a string.

<x:out source="${news}" select="//channel/title"/>

Attribute Description Required Default
Source Var containing DOM model where the XPath expression is run over. True
Select XPath expression. True
EscapeXml true to escape special characters False 'True'

<x:set>

- Saves the result of the select XPath expression to a scoped variable. Returned value may be a node set (XML fragment), boolean, string, or number.

<x:set source="${news}" select="//channel/item" var="newsItems"/>

Attribute Description Required Default
Source Var containing DOM model where the XPath expression is run over. False
Select XPath expression. False
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

Conditional Actions


Actions that format and parse numbers, currencies, percentages, dates and times.

<x:if>

- Processes the body if select XPath evaluates to true (following the rules of the boolean() XPath function).

<x:if source="${news}" select="item[contains(description,'Linux')]">
   Linux is in the news today!
</x:if>

Attribute Description Required Default
Source Var containing DOM model where the XPath expression is run over. True
Select XPath expression. True
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

<x:choose>

- Processes the body of the first enclosed <x:when> tag where the select XPath expression evaluates to true. If none match then the body of the <x:otherwise> tag (if present) is processed.

<x:choose>
   <x:when source="${news}" select="//item">
      We've got news :)
   </x:when>
   <x:otherwise>
      No news today :(
   </x:otherwise>
</x:choose>

<x:when>

- Represents an alternative in an <x:choose> tag. Processes the body if the select expression evaluates to true and no other previous <x:when> tags in the <x:choose> matched.
Attribute Description Required Default
Source Var containing DOM model where the XPath expression is run over. True
Select XPath expression. True

<x:otherwise>

- Processes the body if no other previous <x:when> condition in the <x:choose> matched. This tag accepts no attributes and, if present, must be the last tag in <x:choose> body.

Iterator Actions


Actions that format and parse numbers, currencies, percentages, dates and times.

<x:forEach>

- Repeats the nested body content over a node set determined by an XPath expression, setting the context node to each element in the iteration.

<x:forEach source="${news}" select="//item">
   <a href='<x:out select="link"/>'>
   <x:out select="title"/></a>
</x:forEach>

Attribute Description Required Default
Source Var containing DOM model where the XPath expression is run over. True
Select XPath expression. True
Begin Zero-based index of first item to process, inclusive. False '0'
End Zero-based index of last item to process, inclusive. False
Step Process every stepth element (e.g 2 = every second element). False '1'
Var Name of variable to hold the current item. This variable has only nested visibility. False 'Item'
VarStatus Name of variable to hold the loop status with the following properties:
  • index - position of the current item
  • count - number of times through the loop (starting with 1)
  • first - boolean indicator if this is the first iteration
  • last - boolean indicator if this is the last iteration
False 'Status'

Transformation Actions


JSTL provides an <x:transform> tag for performing XSLT transformations. The <x:param> tag can be nested in the <x:transform> tag to set a parameter that is used in the stylesheet.

<x:transform>

- Conducts an XSLT transformation on source XML. The source XML is provided by the doc attribute or the body of the tag. The XSL stylesheet is specified by the xslt attribute. While in most cases, the stylesheet will be set up by back-end code - it is possible to define the stylesheet inline and make it available with <c:set> as in the following example:

<c:set var="xsl">
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="item">
         <li>
            <xsl:value-of select="title"/>
         </li>
   </xsl:template>
   <xsl:template match="/">
      <ol>
         <xsl:apply-templates select="//item"/>
      </ol>
   </xsl:template>
<x:transform doc="${news}" xslt="${xsl}"/>

Attribute Description Required Default
Doc Source XML document for the transformation. Value can be a String, Stream, TextReader, XmlReader, System.Xml.XPath.XPathDocument or any value exported <x:parse> or <x:set>. True
CacheVar Var to save a cached instance of the parsed xsl template in. False
CacheScope Scope of the cached instance. False 'Session'
Xslt XSLT stylesheet to use. The value must be String, Stream, TextReader, XmlReader, System.Xml.XPath.XPathDocument or any value exported <x:parse> or <x:set>. True
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

Conducts an XSLT transformation on source XML. The source XML is provided by the doc attribute or the body of the tag. The XSL stylesheet is specified by the xslt attribute. While in most cases, the stylesheet will be set up by back-end code - it is possible to define the stylesheet inline and make it available with <c:set> as in the following example:

<x:param>

- Sets a transformation parameter that will be passed to stylesheet which declares parameters using the <xsl:param> tag. The <x:param> tag can only be nested within an <x:transform> tag. Any <x:param> tags must come after the XML body content of the <x:transform> tag, if present.

<x:transform doc="${news}" xslt="${searchXsl}"/>
   <x:param name="searchParam">Web Services</x:param>
</x:transform>

Attribute Description Required Default
Name Name of the parameter as a String. This name must match the name in the corresponding <xsl:param> XSLT tag. True
Value Value of the parameter. If not specified, value is taken from the tag body. False Body
NameSpaceUri Namespace uri used in the False

sharp - Sharp Tag Library

Sharp Actions


Miscelanious actions.

<sharp:marker>

- Marks the nested body. The body is included inside a <div> element.
Attribute Description Required Default
Id Marker Id which will return in the output True

<sharp:include>

- Includes and evaluates a fragment.
Attribute Description Required Default
File Includes the template into current template True

<sharp:scope>

- Pushes a new tag scope on the stack. So tag level variables can be used without changes the early created variables.

html - Html wrapper Tag Library

The html tag lib provides a wrapper to access the HtmlHelper.

This taglib basicly is a wrapper for all extension methods on the HtmlHelper. This allows you add a tag like

<html:checkBox name="rememberMe" isChecked="${Model.checkBoxValue}" class="loginform"/>

to your page. The example wraps the following method:

InputExtensions.CheckBox( HtmlHelper htmlHelper, string name, boolean isChecked, IDictionary<string, object> htmlAttributes ) : string


In a aspx page the example would look like this:

<%=HtmlHelper.CheckBox("rememberMe", ViewData.Model.CheckBoxvalue, new {class="formInput"});%>


SharpTiles will always look for a matching method with the least amount of parameters. The parameter names are matched on name with two exceptions, htmlHelkper and htmlAttributes the htmlHelper is added automaticly by the framework. The htmlAttributes is a dictionary containing key value pairs of unmatched attributes. So our example requires a method with name checkBox and a parameter name and a parameter isChecked. Further more there isn't a method which takes class as a parameter so this is stored in the htmlAttributes. This makes that the method we are looking for also required a parameters htmlAttributes. SharpTiles will search for this method and makes the call. All parameters are evaluated by shaprtiles before being passed through the html helper.
Below this introduction all wrapped methods are enumerated. A different version of your HtmlHelper might change the availability of the wrapped methods.

<html:action>

- Renders an action url.

<html:action action='${Model.action}' controller='LoginController'/>

Attribute Description Required Default
Action Action to be called on the controller False
Controller Controller to redirect to False
Scope Scope of variable False 'Page'
Var Name of variable to store data. An existing variable will be changed. If the property is the property of an object(in any scope). The value of the property will be changed. False

<html:form>

- Simulates the form extensions method. A new implementation was required, because the existing form extensions writes directly to the http response.

<html:form action='${Model.action}' controller='${Model.controller}' method='post'>   <html:textBox name='${Model.textBoxName}' value='${Model.textBoxValue}' class='${Model.style}'/> </html:form>

Attribute Description Required Default
Action Name of the action used to handle the post False
Controller Name of the controller to post to. If omitted the current controller is used False
Method Set how this form is posted.
  • Get
  • Post
False 'Post'
Id The id of the form False

All the html helper methods

<html:checkBox>

- Wraps the check box helper method

<html:checkBox name='${Model.checkBoxName}' isChecked='${Model.checkBoxValue}' class='${Model.style}'/>

Function
InputExtensions.CheckBox( HtmlHelper htmlHelper, string name ) : string
InputExtensions.CheckBox( HtmlHelper htmlHelper, string name, boolean isChecked ) : string
InputExtensions.CheckBox( HtmlHelper htmlHelper, string name, IDictionary<string, object> htmlAttributes ) : string
InputExtensions.CheckBox( HtmlHelper htmlHelper, string name, boolean isChecked, IDictionary<string, object> htmlAttributes ) : string

<html:hidden>

- Wraps the hidden helper method

<html:hidden name='${Model.hiddenName}' value='${Model.hiddenValue}' class='${Model.style}'/>

Function
InputExtensions.Hidden( HtmlHelper htmlHelper, string name ) : string
InputExtensions.Hidden( HtmlHelper htmlHelper, string name, object value ) : string
InputExtensions.Hidden( HtmlHelper htmlHelper, string name, object value, IDictionary<string, object> htmlAttributes ) : string

<html:password>

- Wraps the password helper method

<html:password name="${Model.passwordName}" value="${Model.passwordValue}" class="${Model.style}"/>

Function
InputExtensions.Password( HtmlHelper htmlHelper, string name ) : string
InputExtensions.Password( HtmlHelper htmlHelper, string name, object value ) : string
InputExtensions.Password( HtmlHelper htmlHelper, string name, object value, IDictionary<string, object> htmlAttributes ) : string

<html:radioButton>

- Wraps the radion button helper method

<html:radioButton name="${Model.radioButtonName}" value="${Model.radioButtonValue}" class="${Model.style}"/>

Function
InputExtensions.RadioButton( HtmlHelper htmlHelper, string name, object value ) : string
InputExtensions.RadioButton( HtmlHelper htmlHelper, string name, object value, IDictionary<string, object> htmlAttributes ) : string
InputExtensions.RadioButton( HtmlHelper htmlHelper, string name, object value, boolean isChecked ) : string
InputExtensions.RadioButton( HtmlHelper htmlHelper, string name, object value, boolean isChecked, IDictionary<string, object> htmlAttributes ) : string

<html:textBox>

- Wraps the text box helper method

<html:textBox name='${Model.textBoxName}' value='${Model.textBoxValue}' class='${Model.style}"/>

Function
InputExtensions.TextBox( HtmlHelper htmlHelper, string name ) : string
InputExtensions.TextBox( HtmlHelper htmlHelper, string name, object value ) : string
InputExtensions.TextBox( HtmlHelper htmlHelper, string name, object value, IDictionary<string, object> htmlAttributes ) : string

<html:dropDownList>

- Wraps the drop down list helper method

<html:dropDownList name='${Model.dropDownListName}' selectList='${Model.selectList}"/>

Function
SelectExtensions.DropDownList( HtmlHelper htmlHelper, string name, string optionLabel ) : string
SelectExtensions.DropDownList( HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, string optionLabel ) : string
SelectExtensions.DropDownList( HtmlHelper htmlHelper, string name ) : string
SelectExtensions.DropDownList( HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList ) : string
SelectExtensions.DropDownList( HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes ) : string
SelectExtensions.DropDownList( HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, string optionLabel, IDictionary<string, object> htmlAttributes ) : string

<html:listBox>

- Wraps the list box helper method

<html:listBox name='${Model.listBoxName}' selectList='${Model.mutliList}'/>

Function
SelectExtensions.ListBox( HtmlHelper htmlHelper, string name ) : string
SelectExtensions.ListBox( HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList ) : string
SelectExtensions.ListBox( HtmlHelper htmlHelper, string name, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes ) : string

<html:textArea>

- Wraps the textarea box helper method

<html:textArea name='${Model.textAreaName}' value='${Model.textAreaValue}' columns='${Model.columns}' rows='${Model.rows}' class='htmlEditor'/>

Function
TextAreaExtensions.TextArea( HtmlHelper htmlHelper, string name ) : string
TextAreaExtensions.TextArea( HtmlHelper htmlHelper, string name, IDictionary<string, object> htmlAttributes ) : string
TextAreaExtensions.TextArea( HtmlHelper htmlHelper, string name, string value ) : string
TextAreaExtensions.TextArea( HtmlHelper htmlHelper, string name, string value, IDictionary<string, object> htmlAttributes ) : string
TextAreaExtensions.TextArea( HtmlHelper htmlHelper, string name, string value, integer rows, integer columns, IDictionary<string, object> htmlAttributes ) : string

<html:validationMessage>

- Wraps the validation message helper

<html:validationMessage modelName='${Model.modelName}' validationMessage='${Model.validationMessage}'/>

Function
ValidationExtensions.ValidationMessage( HtmlHelper htmlHelper, string modelName ) : string
ValidationExtensions.ValidationMessage( HtmlHelper htmlHelper, string modelName, string validationMessage ) : string
ValidationExtensions.ValidationMessage( HtmlHelper htmlHelper, string modelName, IDictionary<string, object> htmlAttributes ) : string
ValidationExtensions.ValidationMessage( HtmlHelper htmlHelper, string modelName, string validationMessage, IDictionary<string, object> htmlAttributes ) : string

<html:validationSummary>

- The name of the tile to import

<html:validationSummary message='msg' class='errorReport'/>

Function
ValidationExtensions.ValidationSummary( HtmlHelper htmlHelper ) : string
ValidationExtensions.ValidationSummary( HtmlHelper htmlHelper, string message ) : string
ValidationExtensions.ValidationSummary( HtmlHelper htmlHelper, string message, IDictionary<string, object> htmlAttributes ) : string

tiles - Tiles Tag Library

The tiles tag lib provides functionality to include defined tiles in to the page.

<tiles:insert>

- Inserts a configured tile into the page. The available tiles set is configured in a seperate config file.

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Sample</title>
  </head>
  <body>
    <div id="menu">
      <tiles:insert name='menu'/>
    </div>
    <hr />
    <div id="main">
      <tiles:insert name='body'/>
    </div>
  </body>
</html>

Attribute Description Required Default
Name The name of the tile to import True
Mandatory If this attribute is set to false and the attribute specified by the name does not exist then nothing will be rendered. The default value, true, will raise an error. False 'True'

<tiles:insertTemplate>

- Allows pages to enter a masterpage without explictely defining it in the tiles.xml configuration file.
Contributed by Ronald Dehuysser

<tiles:insertTemplate template="/Views/Shared/Masterpage.tile">
  <tiles:putAttribute name="title" value="Sample Title"/>
  <tiles:putAttribute name="Top Navigation" value="/Views/Shared/navigation.tile"/>
  <tiles:putAttribute name="body">
    <div id="main">
      <p>Dit is de body</p>
    </div>
</tiles:insertTemplate>

Attribute Description Required Default
Template Defines the template that will be used to display the current page. True

<tiles:putAttribute>

- This tag allows attibutes to be add to the current page.
Contributed by Ronald Dehuysser

See the example for the <tiles:insertTemplate /> tag.

Attribute Description Required Default
Name This attribute defines the name of the current tile attribute and must match one of the Tiles insert names in the masterpage so it can be imported. True
Value The value of the attribute to be imported. This value is not required and can be provided in the body of the tag. If provided, it can be a plain string value or a url. If the value starts with a '/' it is used as a url and the file provided by the url is imported. False Body
TileType Like tiles defined in the tiles.xml The tile factory will guess the tile type (template or string). You can override the guessing by defining the type
  • String
  • File
  • Definition
False

Contact form fixed

I regret reporting that the contact form was broken for the last week. All mails send to us were corrupted(empty). So reported bugs in the last week are not received. I'm aware that the timing with regards to the monorail release isn't very handy. The contact form is fixed now. I apologize.

4 February, 2010

Monorail released M5

Monorail is released. The release also contains some minor fixes.

23 January, 2010

Monorail almost finished

Maikel Willemse is coding a Monorail view engine. It's available in the nightly release. A tutorial and a new release will be available shortly.

2 January, 2010

No more tiles.xml
(if you like)

A NSTL view engine is now available. You can do SharpTiles without having a tiles.xml. You will lose the power of dependency injection. If you are interested check out the tutorial page.

21 July, 2009

Developer M3 released

Fixed a couple of parse bugs. Cleaned up refreshing of resources, resource locations and registration of the TilesViewEngine. Wrote some tutorials
Ronald Dehuysser contributed the <tiles:insertTemplate/> and <tiles:putAttribute/> tag.

8 June, 2009

HtmlHelper wrapped II

Updated tag reference documentation.

5 April, 2009

Ready for MVC RC 2

SharpTiles is now ready to use with MVC RC 2.

6 March, 2009

HtmlHelper wrapped

The MVC HtmlHelper is now wrapped and can be used. For it's only available in the nightly build. When the documentation and new Tutorials are made a new release will be made.

22 December, 2008

Ready for Beta 1

SharpTiles is now ready to use with MVC Beta 1. The tutorial page will be updated soon.

3 November, 2008

We've got Tiles

It took me a bit longer than expected but Milestone 1 is reached. Tiles are now available.

23 July, 2008

First release

Finally, after some hard work my pet project is ready for its initial release. Here it is! Please give it some thoughts and feel free to add comments.

23 May, 2008

SID: PopUp 0