Escolar Documentos
Profissional Documentos
Cultura Documentos
The Visual Page Editor (VPE) allows you to work with either a visual representation of a JSP
file or with the underlying source code for the JSP file. In order to display a JSP file that contains
tag library tags properly, we need to specify how to render the library tags as HTML tags and
how to use them in the visual representation.
VPE uses an XML template file to specify this for a particular tag library. The templates use tags
and expressions to define how source-tags (the actual JSP library tags) can be rendered as
visual-tags (HTML tags).
Template Files
All template files are located inside this folder:
<ExadelStudioHome>\eclipse\plugins\com.exadel.vpe_x.x.x\templates
One XML file in this folder lists all the templates available to load by VPE in this folder:
vpe-templates-list.xml
This cataloging XML file uses two tags. The root element is <vpe:templates-list>. This
element has one or more child elements of this form:
<vpe:templates file="vpe-templates-taglibname.xml"/>
These are the standard templates listed in the template list file:
1. Create a new template file inside the templates directory. For example, let’s say vpe-
templates-myTags.xml.
2. Add this entry for your template inside the vpe-templates-list.xml file:
<vpe:templates file="vpe-templates-MyTags.xml"/>
3. The vpe-templates-MyTags.xml file you create should use a <vpe:templates>
element as the root element and begin with a taglib declaration that should match the
taglib declaration used in the JSP file. Here’s an example:
<vpe:templates>
<vpe:template-taglib uri="http://java.sun.com/jsf/html"
prefix="h"/>
……………………………….
</vpe:templates>
Template Structure
Each tag library templates file consists of one or more separate templates for handling particular
source-tags in the tag library. The basic template structure is represented by this code:
<vpe:tag name="a" case-sensitive="no">
<vpe:template children="yes" modify="yes">
<span class="{@class}" style="{@style}color:blue;text-
decoration:underline"/>
<vpe:dnd>
<vpe:drag start-enable="yes"/>
<vpe:drop container="yes">
<vpe:container-child tag-name="#text"/>
</vpe:drop>
</vpe:dnd>
</vpe:template>
</vpe:tag>
DRAFT Page 2 of 9
Confidential, Exadel, Inc. ©2005
<vpe:dnd>...</vpe:dnd>
This section describes how the visual-tag behaves in the visual view during drag and drop.
<vpe:drag start-enable="yes"/> defines if it’s allowed or not to start dragging the
visual-element. <vpe:drop container="yes">...</vpe:drop> defines if it’s allowed or
not to drop something else inside this visual-tag. And finally, <vpe:container-child tag-
name="#text"/> defines what can be dragged and dropped. In this example it is only plain
text.
The result of the “test” expression determines if the template will be applied to the source-tag.
The first template to match is the one that gets applied.
DRAFT Page 3 of 9
Confidential, Exadel, Inc. ©2005
This example shows the usage of “{@style}” in the template “span” tag’s “style” attribute to
include the value of the source-tag’s “style” attribute in the visual tag’s “style” attribute..
Using “vpe:if”
Here is an example of branching to determine which of two or more templates get applied for
rendering a source-tag.
Using “vpe:attribute”
This tag is used to add additional attributes to the visual-tag.
DRAFT Page 4 of 9
Confidential, Exadel, Inc. ©2005
Using “vpe:value”
This tag is used to display a value of a source-tag attribute attribute as text in the visual view.
Using “vpe:grid”
This tag specifies that the matched source-tag should be laid out as a table. The “layout” attribute
is used for specifying the table format in the visual view.
DRAFT Page 5 of 9
Confidential, Exadel, Inc. ©2005
DRAFT Page 6 of 9
Confidential, Exadel, Inc. ©2005
DRAFT Page 7 of 9
Confidential, Exadel, Inc. ©2005
Example
<vpe:tag name="h:selectManyMenu" case-sensitive="yes">
<vpe:template children="yes" modify="yes">
<select style="{@style}" class="{@styleClass}"
title="{tagstring()}"/>
</vpe:template>
</vpe:tag>
Here, the “style” and “class” attributes of the visual-tag, “<select>,” would be assigned the same
values as the same attributes in the source-tag , “<h:selectManyMenu>.”
You can also use these special function in the values for template tag attributes. In the example
above, the “title” attribute of the visual-tag “<select> will be assigned to this string: <vpe:tag
name="h:selectManyMenu" case-sensitive="yes"> The following functions are
available:
String Functions
• name() – element name of the source tree
• src(path) – transform a relative file path to a local file path
• if(BooleanExpression, ret1, ret2) – returns ret1, if BoolenExpression is true and
returns ret2, if BoolenExpression is false
• tagstring() – returns text of the source-tag
• parentname()– returns the name of the parent tag
Boolean Functions
• not(BooleanExpression) – logical negation.
• hasinparents(tagName) – returns true if, in the chain of parents, a tag with name of
tagName is found.
• attrpresent(attrName) – returns true if the tag has an attribute with the name of
“attrName”
DRAFT Page 8 of 9
Confidential, Exadel, Inc. ©2005
DRAFT Page 9 of 9