MAP | PageMixer Documents > Tutorial > Mixing with Struts > 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 in this section is shown below:
In this tutorial, abbreviated class names are used. Complete names are shown below.
Notation | Full 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 |
Notation | Full name |
---|---|
Bootstrap | pagemixer.filter.Bootstrap |
DummySetup | pagemixer.filter.DummySetup |
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.
ActionInsetFilter.A
for HTML "a
" tag
ActionInsetFilter.IMG
for HTML "img
" tag
ActionInsetFilter.FORM
for HTML "form
" tag
ActionInsetFilter.LINK
for HTML "link
" tag
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.
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.
<html:link
page="/editRegistration?action=Create"
><bean:message key="index.registration"/></html:link>
Then you should create HTML page shown below.
<a
href="/editRegistration?action=Create"
>Register with the MailReader
Demonstration Application</a>
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.
<a href="static-page.html" nonaction="true" >link to non-action(but internal) resource</a> <a href="http://pagemixer.sourceforge.net/index.en.html" external="true" >link to external resource</a>
"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").
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 ActionConfig
s
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).
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) { DummySetup.setup(context, new String[0], 0); } }; ActionInsetFilter.A filter = new ActionInsetFilter.A(); bootstrap.execute(filter);
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.
MAP | PageMixer Documents > Tutorial > Mixing with Struts > Inset URI | << | >> |