You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by st...@outerthought.org on 2003/10/31 12:00:14 UTC
[WIKI-UPDATE] FAQs Fri Oct 31 12:00:14 2003
Page: http://wiki.cocoondev.org/Wiki.jsp?page=FAQs , version: 81 on Fri Oct 31 10:21:26 2003 by Jheymans
+ !Q: I have defined module variables in cocoon.xconf (eg defaultsmetamodule), how do I access these from java code?
+
+ {{
+ <input-modules>\\
+ .....\\
+ <component-instance class="org....input.DefaultsMetaModule" name="defaults">\\
+ <values>\\
+ <skin>defaultSkin</skin>\\
+ <base-url>http://localhost:8080/cocoon</base-url>\\
+ <MYVAR>myvalue</MYVAR>\\
+ </values>\\
+ </component-instance>\\
+ .....\\
+ }}
+
+
+ A: Use the following snippet (same principle for any other module)
+
+ {{
+ //modulename below refers to the name defined in cocoon.xconf\\
+ String modulename = "defaults";\\
+ ComponentSelector selector =\\ (ComponentSelector)this.manager.lookup(InputModule.ROLE + "Selector");\\
+ InputModule module = (InputModule)selector.select("defaults");\\
+ Iterator it = module.getAttributeNames(null, objectModel);\\
+ while (it.hasNext()) {\\
+ String name = (String)it.next();\\
+ logger.debug(name + "->" + module.getAttribute(name, null, null));\\
+ }\\
+ }}
+