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
