html/ directory. XSL knowledge is
required for page editing. XSL is somewhat obscure, and so you might never have used it.
It takes input XML and reformats it according to XSL instructions, selecting data from elements,
iterating through elements, and dumping content (ie HTML). The main advantage of XSL is the
separation of processing and formatting. Basically, the java that does the work is all together,
and the XSL which does the formatting is all together. This means that each piece can
be best managed by separate tools, and that changes are located close together. In practice,
it leads to quicker development and lessened maintenance. If this is your first time encountering
XSL, you should read the XSL Overview tutorial.
html tag, no head, no body), just
the content snippet for the current request.var/site/page.xsl
within the benow-web.jar or as var/site/page.xsl, if overriden.
The theme page spits out a <!--page--> tag which is located and used as the insertion
point for the current page snippet (as generated in the previous step). The HTML
now contains the dynamic content amid the theme page.
The theme can be customized to your application, and might spit out a different menu,
title bar or page layout. More on the theme system and customisation can be found in
Theme Customisation page within the advanced section
of this walkthru.
html/ prefix) and hit 'Create New...':
The new page template is copied to the specified file, and is ready to be customised. This template
is found in var/templates/page.template within benow-web.jar, but may be
overriden by specifying a var/templates/page.template within the project filesystem.
You now have the boilerplate for a new page. As can be seen in the screenshot, the
new page from the template already contains information. It defines a stylesheet,
includes some XSL libraries, has some parameters, and defines a template.
java prefix is defined. This is a more advanced topic, which is
covered in the Calling Java from within a page
section of this walkthru.
libutil.xsl and libcontrol.xsl libraries are included. These
libraries contain utility templates for processing and presentation. They can be found within
lib/xsl in benow-web.jar or in the lib/xsl in the
project filesystem. Other libraries, should you need to create one, should go within
the lib/xsl directory and should be refrenced without prefix (ie
<xsl:include href="mylib.xsl"/> and not <xsl:include href="lib/xsl/mylib.xsl"/>)
as lib/xsl is the default search path.
xsl:param elements define two parameters which must be present
within any page definition.
org.benow.security.user.User java object). It can be used to test
and assert permissions during page construction. See the
Security and customisation section for details on
using this user parameter.xsl.RenderControl
java object, which can be used to control the HTML construction process. It is used for
setting the page title, providing a help context, supressing the header, etc.
hit 'View' and a new window/tab will open to the edited page:
Isn't it pretty... but perhaps still a bit unclear as to how it was done. XSL reformats XML,
and we've seen no XML yet. As outlined above, the XML is created for each page request, and
serves as the input to the XSL. The XML for the page request can be shown by clicking the
XML link in the top left (or the shortcut Alt-Shift-X).
The full xml for the page request was:
<index uri="/walkthru/hello.page">
<params>
<pagePath>walkthru/hello.page</pagePath>
</params>
<url>http://localhost:8420/walkthru/hello.page</url>
<headers>
<Host>localhost:8420</Host>
<User-Agent>Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.7pre) Gecko/20091210 Ubuntu/9.10 (karmic) Shiretoko/3.5.7pre</User-Agent>
<Accept>text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8</Accept>
<Accept-Language>en-us,en;q=0.5</Accept-Language>
<Accept-Encoding>gzip,deflate</Accept-Encoding>
<Accept-Charset>ISO-8859-1,utf-8;q=0.7,*;q=0.7</Accept-Charset>
<Keep-Alive>300</Keep-Alive>
<Connection>keep-alive</Connection>
<Referer>http://localhost:8420/admin/dev/index.page?op=view&type=page&item=walkthru/hello.page</Referer>
<Cookie>userInfo=admin 92668751; userInfo=admin 92668751; wdk_pref_cookie_0=eJyNkctKQzEQhl/F7uXQikIrzbLo5mjBLhSRME3GdmiSCZlp63l7o1WoR7wsB/7L9zOuoMekBEFsBpE9F2/w+ua+PZOL29l4f3clk+nAccycqvCRvAm8ovTUbAVLgojGO43TwY6ElgELZhZSLoRiLkfn48mpj9Zj5JpyVNZzQ86BHChxasA5lBpGgbRrZM1F3VYT7Gj1LsAEtcib55qDv1khqOKL9vQuUIVIqHXrJvDBaaydtfPFw2Lezqw9+crq2S1BKurnkJ8rN9gtGYr/H+1W128dH6fnCPSd5NjhSXKArnGh/oqcGQ2HfdRDBsasnf2jrrfqFRPUx5M.; JSESSIONID=1exiiote7y814</Cookie>
</headers>
<session>
<headers>{}</headers>
<addCookies>[javax.servlet.http.Cookie@16e14f9]</addCookies>
<pagexml>[org.benow.web.path.page.XMLChunk@22ed4b]</pagexml>
<xslParams>{}</xslParams>
<params>pagePath{walkthru/hello.page} </params>
<user key="1" type="org.benow.repository.security.UserImpl">
<name>admin</name>
<description><![CDATA[Administrative user.]]></description>
<validated>true</validated>
<validation-code>1260832613816</validation-code>
<needs-password>false</needs-password>
<confirmed>true</confirmed>
</user>
<url>http://localhost:8420/walkthru/hello.page</url>
<userStamp>Thu Dec 17 17:03:02 MST 2009</userStamp>
</session>
<menu key="1">
<name>/</name>
<href>/</href>
<description>root</description>
<pos>0</pos>
<canned>false</canned>
<children type="org.benow.repository.mapping.JSQLArrayList">
<item key="3" type="org.benow.web.menu.MenuItemImpl">
<path>/Administration</path>
<name>Administration</name>
<href>/admin/index.page</href>
<on-click/>
<description>Administer the site</description>
<pos>1</pos>
<canned>false</canned>
<children type="org.benow.repository.mapping.JSQLArrayList">
<item key="4" type="org.benow.web.menu.MenuItemImpl">
<path>/Administration/menu</path>
<name>menu</name>
<href>/admin/dev/menu.page</href>
<on-click/>
<description>Configure the menu</description>
<pos>1</pos>
<canned>false</canned>
</item>
<item key="5" type="org.benow.web.menu.MenuItemImpl">
<path>/Administration/development</path>
<name>development</name>
<href>/admin/dev/index.page</href>
<on-click/>
<description>Edit web items</description>
<pos>2</pos>
<canned>false</canned>
</item>
<item key="6" type="org.benow.web.menu.MenuItemImpl">
<path>/Administration/security</path>
<name>security</name>
<href>/admin/security/index.page</href>
<on-click/>
<description>Manage users, roles and permissions</description>
<pos>3</pos>
<canned>false</canned>
</item>
<item key="7" type="org.benow.web.menu.MenuItemImpl">
<path>/Administration/services</path>
<name>services</name>
<href>/svc/</href>
<on-click/>
<description/>
<pos>4</pos>
<canned>false</canned>
</item>
</children>
</item>
</children>
</menu>
<styles>
<item link="/css/index.css"/>
</styles>
</index>
index element, and contains a bunch of
data, most of which is only useful to the page template. The index
is matched by <xsl:template match="index">. We can further edit the page
to dump some of this info:
This now gets the user name from the user parameter, and displays the current url
from the <url> element:
And so, that is the basics of dynamic web page design. The whole dynamic part is
still missing. The data is still relatively static, but we'll soon be fetching data
from the services, as described in the next section.
op parameter is specified. The op parameter can be used to present
other functionality within the page. If another template were defined, then it can
be matched by passing the associated value for op. For example:
When the page is accessed as /walkthru/hello.page?op=goodbye, then <goodbye>
becomes the top element and matches the goodbye template, causing:
By using different values for the op parameter, different templates within
the page can be used. This centralizes behaviour and makes sites simpler and more
appropriate. We'll be using this behaviour, as we move to
calling services from a page.