Thanks for your reply Antonio.
This behaviour was available in Struts-Tiles, has it been removed from Tiles
2.0?
The rules definition is, as you say, not designed to be rendered. It's purpose
is to hold a list of security roles - these roles are processed
programmatically and this decides whether the user sees that menu item (or
entire menu), based on their assigned role.
This functionality is used in our (very extensive) Branding & Security
framework for Struts-Tiles, and I'd be keen to maintain it with only minimal
change if possible. However, if it's not possible to recreate this in Tiles
2.0, I'd appreciate any suggestions as to how to achieve the objective.
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 11:11
To: [email protected]
Subject: Re: Issue with retrieving Tiles definitions in code
2010/3/9 Gallagher, Jim (UK Europe Middle East & Group Functions, Technology
Services) <[email protected]>:
> 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.
This is normal, you are not using the correct tool.
DefinitionManager is a tool used by Tiles to define newly-created definitions,
not to retrieve already stored ones.
However, there is a problem: you cannot get a definition using the Tiles API.
You can only render it, and use the attributes in the template page. So I think
we need to find a workaround.
The definition has no meaning without a template (its own, or inherited from an
extended definition).
How do you want to use these "rules"?
Antonio
*** 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.