Aspect4Facelets SourceForge.net Logo

Documentation

User Guide

The AspectResolver searches for resources also in the META-INF directories. This makes it possible to pack your web application in several jar files.

The AspectCompileAspect searches for all files extensions.xml in META-INF directories. When a file is loaded for compilation, it is looked if there are aspects which can be applied. The file with the applied aspects is then compiled as usual.

The extension.xml files have a very simple schema and only very few types of aspects are supported (so far). The root node of the xml has to be called extensions. As children it contains a list of aspects.

All aspects specify an x-path to select a single node (I think I should allow to select multiple nodes...). On this node the aspect is applied.

The following aspects are supported:

append-child
The content defined by the aspect is inserted as new child to the node. Example:
DocumentAspectResult
<ul id="modules"/>
<append-child file="/p.xhtml"
	path="//*[@id='modules']"
	source="e1.xhtml" />
with
<li>Text</li>
<ul id="modules">
	<li>Text</li>
</ul>
insert-after
The content defined by the aspect is inserted as new sibbling to the node. Example:
DocumentAspectResult
<ul id="test"/>
<p>Text</p>
<insert-after source="e2.xhtml"
	path="//*[@id='test']"
	file="/p.xhtml" />
with
<li>This is the inserted after.</li>
<ul id="test"/>
<li>This is the inserted after.</li>
<p>Text</p>
insert-child
The content defined by the aspect is inserted as new child to the node at a given position. Example:
DocumentAspectResult
<ul id="test">
	<li>eins</li>
	<li>zwei</li>
<ul>
<insert-child source="e3.xhtml"
	path="//*[@id='test']"
	index="1"
	file="/p.xhtml" />
with
<li>This is the text.</li>
<ul id="test"/>
	<li>eins</li>
	<li>This is the text.</li>
	<li>zwei</li>
<ul>
remove
The selected node is removed. Example:
DocumentAspectResult
<ul>
	<li id="test">eins</li>
	<li>zwei</li>
<ul>
<remove path="//*[@id='test']"
	file="/p.xhtml" />
<ul/>
	<li>zwei</li>
<ul>
add-attribute
Adds an attribute to the selected node. Example:
DocumentAspectResult
<ul id="test">
	<li>eins</li>
	<li>zwei</li>
<ul>
<add-attribute path="//*[@id='test']"
	name="a"
	value="v"
	file="/p.xhtml" />
<ul id="test" a="v"/>
	<li>eins</li>
	<li>zwei</li>
<ul>

Use the following attributes:

Attribute Description Comment
file path of the file to be compiled. This has to be a constant. I think, I'll change it to some kind of pattern machting.
path x-path to select the node where the aspect should be applied.
source path to the file containing the content to be inserted relative to the extensions.xml
index Position at which the content is inserted only for insert-child