E.W.C. Taglibs

E.W.C. provides a set of tag libraries for quick UI development. This one provide common tags that don't generate an output, so can be used together with other taglibs that focuses on HTML generation o XML generation.

The component list:

  • ctx : The ctx tag is used to set the scope or context that will be used by tags in its body.
  • if/else : The if tag, combined with the else tag, is used to conditionally process its body.
  • forEach : The forEach tag iterates over a collection, changing the scope to the next item in each iteration.
  • include : The include tag is used to include another page in that point.
  • label : The label tag just evaluates an expression and prints its value.

ctx

The ctx tag is used to set the scope or context that will be used by other tags. This tag can be nested as needed.

This tag expects the following parameters:

  • className : The class name that will be used as the context for the taglibs in its body.

Example:

<ewc:ctx className="demo.UserDemo">
	[...]
</ewc:ctx>

Look for more details at the javadoc . If you are experiencing any problem, have a look at the implementation to completely understand the tag behaviour.

if/else

The if tag, combined with the else tag, is used to conditionally process its body.

The if tag expects the following parameters:

  • src : An expression that must evaluate into a boolean . Can be preceded by "!" to negate the expression.

The else tag must be added after an if tag and doesn't have any parameter.

Example:

<ewc:if src="book.new">
	<h1>Creating a new book</h1>
	[...]
</ewc:if>
<ewc:else>
	<h1>Editing book: <ewc:label src="book.name"/></h1>
	[...]
</ewc:else>

Look for more details at the if and else javadoc. If you are experiencing any problem, have a look at the if and else implementation to completely understand the tags behaviour.

forEach

The forEach tag iterates over a collection, changing the scope to the next item in each iteration.

This tag expects the following parameters:

  • src : The expression that must evaluate in a java.util.Collection . This collection will be iterated and the tag body will be processed once for each item in the collection, having this item as the current context.
  • indexName (optional) : Indicates the index name to use. The index is a parameter that can be used within expressions and that will be substituted by the iteration counter. By default its value is 'i'.

Example:

[...]
<ewc:forEach src="book.pages">
<tr>
	<td>
		<ewc:label src="'Page: @i'" />
	</td>
	<td><ewc:label src="wordCount" /></td>
	<td><ewc-html:button css="button" caption="Select" onClick="../selectPage(@i)" /></td>
	<td><img src="images/page.gif" onclick="<ewc-html:throwEvent event="../selectPage(@i)" />"></td>
	<td>
	<table>
	<ewc:forEach src="paragraphs" indexName="j">
	<tr>
		<td>
		<ewc:label src="'Page:@i Paragraph: @j'" />
		</td>
		<td>
		<ewc-html:textField css="field" rows="3" cols="20" src="text" />
		</td>
	</tr>
	</ewc:forEach>
	</table>
</td></tr>
</ewc:forEach>
[...]

Look for more details at the javadoc . If you are experiencing any problem, have a look at the implementation to completely understand the tag behaviour.

include

The include tag is used to include another page in that point..

This tag expects the following parameters:

  • src (optional) : The expression that must evaluate into a java.lang.String with the relative path to the page to be included.
  • page (optional) : The relative path to the page to be included.

Example:

<ewc:ctx className="demo.UserDemo">

<table width="100%">
<tr>
	<td valign="top">
		<ewc:include page="UserDemo.jsp" />
	</td>
	<td>
		<!-- Include the page pointed in the "currentView" property
	         of "demo.UserDemo" -->
		<ewc:include src="currentView" />
	</td>
</tr>
</table>
</ewc:ctx>

Look for more details at the javadoc . If you are experiencing any problem, have a look at the implementation to completely understand the tag behaviour.

label

The label tag just evaluates an expression and prints its value.

This tag expects the following parameters:

  • src : The expression that will be evaluated into a java.lang.String and printed.

Example:

[...]
<ewc:label src="'Page:@i Paragraph: @j'" />
[...]

Look for more details at the javadoc . If you are experiencing any problem, have a look at the implementation to completely understand the tag behaviour.