Thanks for your message. I'll try to explain more clearly:
Page and menu definitions are stored in two files, pages.xml and menus.xml,
which are referenced in the web.xml as follows:
<servlet>
<servlet-name>TilesServlet</servlet-name>
<servlet-class>
org.apache.tiles.web.startup.TilesServlet
</servlet-class>
<init-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/pages.xml,/WEB-INF/menus.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
Page definitions consist of templated JSPs, plus a menu item e.g.
<definition name="/menulayout"
preparer="com.rbsg.application.cws.brand.jsf.XXXBrandPreparer"
template="/templates/layout.jsp">
<put-attribute name="banner" value="/banner.jsp" />
<put-attribute name="title"
value="XXXXX Message Application" />
<put-attribute name="header" value="/header.jsp" />
<put-attribute name="navigation" value="/navigation.jsp" />
<put-attribute name="menu" value="nav.main" />
<put-attribute name="footer" value="/footer.jsp" />
</definition>
The menu item ("nav.main" above) consists of menu entries, plus a rules
definition:
<definition name="menu.messaging.createmessage"
extends="menu.mainMenuLayout"
preparer="com.rbsg.application.cws.web.menu.jsf.TilesMenuRuleControlPreparer">
<put-attribute name="id" value="menu.messaging.createmessage" />
<put-attribute name="title" value="Create message" />
<put-attribute name="link" value="/createmessage.jsp" />
<put-list-attribute name="rules">
<add-attribute value="rule.menu.messaging.view" />
</put-list-attribute>
</definition>
All of these are read and processed by Tiles automatically & successfully. The
preparer class TilesMenuRuleControlPreparer in the menu is supposed to do
retrieve the rules definition ("rule.menu.messaging.view" in the above case),
and process it according to our security rules.
A rules definition is defined as follows:
<definition name="rule.menu.messaging.view">
<put-attribute name="type" value="one_role" />
<put-list-attribute name="roles">
<add-attribute value="ROLE1" />
<add-attribute value="ROLE2" />
<add-attribute value="ROLE3" />
</put-list-attribute>
</definition>
Ultimately I want to retrieve the rules definition, retrieve the roles
specified and process them according to our own security standards here.
Where it's falling down is that in the TilesMenuRuleControlPreparer class, I'm
trying to retrieve the rules definition as follows:
DefinitionManager definitionManager = new
DefinitionManager(
"org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG");
Definition def = definitionManager.getDefinition(name,
tilesRequestContext);
This is failing with a NullPointerException - on debugging, I see that the
Factory instance within the DefinitionManager is null.
I'm trying to find a way to refer to the definition files read in
automatically, so I can retrieve the rules definitions from there.
I hope this explains it further - if not, please get back to me.
Regards,
Jim
Jim Gallagher,
Core Web Security,
Group Technology Solutions,
Royal Bank of Scotland,
Parkgate Business Park,
Parkgate Street,
Dublin 8.
RBS Depot Code: DUB
ITS: 7-4171-7167
External: +353-1-648 7167
Internet mail: [email protected]
P Please don't print this e-mail unless you really need to.
-----Original Message-----
From: Antonio Petrelli [mailto:[email protected]]
Sent: 09 March 2010 10:43
To: [email protected]
Subject: Re: Issue with retrieving Tiles definitions in code
Can you explain what you need in a more abstract way?
What definition files are you reading?
How do you want to override the definitions defined there?
I would like to have a broader knowledge before I can help you.
Antonio
2010/3/9 Gallagher, Jim (UK Europe Middle East & Group Functions, Technology
Services) <[email protected]>:
> Hi,
>
> I'm currently writing a web application using Java 5, Websphere 6.1,
> JSF and Tiles 2.0.6 (versions mandated by organisation).
>
> I'm converting a multi-brand menu system from Struts-Tiles, and having
> an issue when processing definitions. What I'm trying to achieve is:
>
> Define a DefinitionManager in the ViewPreparer for a given definition
> Read another definition (stored in menus.xml, referenced in the
> web.xml) into a Definition object, to process the rules contained
> therein
>
> My problem is that I cannot see how to get a link to the correct
> DefinitionsFactory that contains the default definitions read in at
> application startup. I'd even settle for re-reading them, but cannot
> find a way how to do that either without getting a reference to the
> factory.
>
> Could anyone provide any assistance or advice? All constructive advice
> gratefully received.
>
>
> Regards,
>
> Jim
>
> Jim Gallagher,
> Internet mail: [email protected]
>
>
>
>
>
> The Royal Bank of Scotland plc, Registered in Scotland No. 90312.
> Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB
>
> Authorised and regulated by the Financial Services Authority.
>
> This e-mail message is confidential and for use by the addressee only. If the
> message is received by anyone other than the addressee, please return the
> message to the sender by replying to it and then delete the message from your
> computer. Internet e-mails are not necessarily secure. The Royal Bank of
> Scotland plc does not accept responsibility for changes made to this message
> after it was sent.
>
> Whilst all reasonable care has been taken to avoid the transmission of
> viruses, it is the responsibility of the recipient to ensure that the onward
> transmission, opening or use of this message and any attachments will not
> adversely affect its systems or data. No responsibility is accepted by The
> Royal Bank of Scotland plc in this regard and the recipient should carry out
> such virus and other checks as it considers appropriate.
>
>
*** WARNING : This message originates from the Internet ***
The Royal Bank of Scotland plc, Registered in Scotland No. 90312. Registered
Office: 36 St Andrew Square, Edinburgh EH2 2YB
Authorised and regulated by the Financial Services Authority.
This e-mail message is confidential and for use by the addressee only. If the
message is received by anyone other than the addressee, please return the
message to the sender by replying to it and then delete the message from your
computer. Internet e-mails are not necessarily secure. The Royal Bank of
Scotland plc does not accept responsibility for changes made to this message
after it was sent.
Whilst all reasonable care has been taken to avoid the transmission of viruses,
it is the responsibility of the recipient to ensure that the onward
transmission, opening or use of this message and any attachments will not
adversely affect its systems or data. No responsibility is accepted by The
Royal Bank of Scotland plc in this regard and the recipient should carry out
such virus and other checks as it considers appropriate.