Home of: [Atelier "FUJIGURUMA"] >> [PageMixer hosted by SourceForge.net]

SEE "For Readers of English Version",
or Japanese version of this page

Inset URI

This section explains how to inset URI corresponded to mapped "Action" of Struts into "a", "img", "form" or "link" HTML tag element as attribute value, in PageMixer framework.


Class diagram

Class diagram in this section is shown below:

Class diagram
Class diagram (click for large figure)

Class names

In this tutorial, abbreviated class names are used. Complete names are shown below.

Classes of PageMixer framework

NotationFull name
ActionConfigKey jp.ne.dti.lares.foozy.pagemixer.servlet.ActionConfigKey
ActionInsetFilter jp.ne.dti.lares.foozy.pagemixer.struts.ActionInsetFilter
ConsumerContext jp.ne.dti.lares.foozy.pagemixer.mixer.ConsumerContext
HTMLSymbolSet jp.ne.dti.lares.foozy.pagemixer.HTMLSymbolSet
HashMapConsumerContext jp.ne.dti.lares.foozy.pagemixer.mixer.HashMapConsumerContext
StrutsConsumerContext jp.ne.dti.lares.foozy.pagemixer.struts.StrutsConsumerContext

Tutorial specific classes

NotationFull name
Bootstrap pagemixer.filter.Bootstrap
DummySetup pagemixer.filter.DummySetup

Decide inset target

In PageMixer framework, derived classes of "ActionInsetFilter" are used to inset URI for mapped "Action" of Struts. There are some derived class variations shown as below.

Above classes are already concretized, so you should only decide HTML tags in which URI should be inset.

Since PageMixer 3.1, you can prevent filters listed up above from insetting URI of Action by specifing "nonaction" or "external" attribute as "true" in target tags, into which you do not want to inset URI.

This allows you to construct filters listed up above by their default constructors, and control insetting in HTML source side.

How to create HTML page from JSP

In fact, ActionInsetFilter and its derived classes translate value of attribute, already containing URI information in HTML page, to real URI for Action assosiated by attribute value, though this tutorial uses word inset.

So, you should specify attribute value as same as "path"(of "forward") or "input"(of "action") element value specified in "struts-config.xml" file.

For examle, "index.jsp" in struts-mailreader of Struts has code shown below.

><bean:message key="index.registration"/></html:link>

index.jsp in struts-mailreader of Struts(part)

Then you should create HTML page shown below.

>Register with the MailReader
Demonstration Application</a>

"index.en.html" corresponded to index.jsp(part)

This HTML source is very simple and friendly for ordinaly HTML editors, is not it?

Then, examples to prevent filters from insetting URI are shown below.

>link to non-action(but internal) resource</a>

>link to external resource</a>

prevent insetting

"nonaction" attribute prevents filters only from insetting action URI, "external" attribute prevents them also from ensurering session ID(= URL rewriting) in other hand.

NOTE: "External" attribute is not secure enough, because URL rewriting may cause leak session ID via "REFERER" HTTP header for external site.

Please use redirect of HTTP at user navigation to the other sites, for strict security.

Please see API document for detail about any other ActionInsetFilter features for insetting Action URI (e.g.: specify "module").

Dummy configuration

ActionInsetFilter looks path for Action up in "ConsumerContext" by "ActionConfigKey".

With StrutsConsumerContext, it works correctly without no explicit preparation. But with "HashMapConsumerContext" or other ConsumerContext implementation class, you should put corresponding ActionConfigs into it explicitly.

"DummySetup" class sets ConsumerContext up as same as configuration of PageMixer - Struts co-operation demonstration (described in "web.xml" and "struts-config.xml" under "src/demo/struts/war/WEB-INF" of distribution).

Connect and mix

Now, everything needed are ready to use. Execution code to inset URI as value of "href" attribute of "<a>" tag in HTML page is as below.

Bootstrap bootstrap =
new Bootstrap.Default(filename){
    protected void prepare(ConsumerContext context)
                         new String[0],
ActionInsetFilter.A filter = new ActionInsetFilter.A();

Connect and Mix

Sample HTML files as input are placed under "src/demo/struts/war/WEB-INF/page". of distribution. Please specify path to them as value of "filename" in above example.

Please see "Inset data into token" or other sections of "Mixing with PageMixer" tutorial, if you want to know more detail about insetting data into HTML page.

To next section "Handle errors"