Hi Gerd,
[email protected] schrieb:
I'm using the PropertiesInputModule to retrieve property-values inside a
JavaScript FlowScript.
Where I was stumbling over was how to get the value for the third parameter in
getAttribute(propKey, null, objectModel).
After some Googling I found the hint to create that objectModel-Map myself.
The code I'm using now is (fragment):
selector =
cocoon.getComponent(Packages.org.apache.cocoon.components.modules.input.InputModule.ROLE
+ "Selector");
inputModule = selector.select("properties");
var objectModel = new java.util.HashMap();
objectModel.put('request', cocoon.request);
theVal = inputModule.getAttribute(propKey, null, objectModel);
Although this works so far, what I don't like is, that not the "real"
ObjectModel is passed. Maybe in future the module makes use of more than the
request-object.
My Questions:
how to get/pass the "real" ObjectModel?
you can use the FlowHelper:
var flowHelper;
try {
flowHelper =
cocoon.getComponent("org.apache.lenya.cms.cocoon.flow.FlowHelper");
var objectMOdel = flowHelper.getObjectModel(cocoon);
…
}
finally {
cocoon.releaseComponent(flowHelper);
}
> Or is there a more elegant way to get the values of (Lenya) properties
> inside a JavaScript FlowScript?
I don't think so, but the code of the PropertiesInputModule could be
refactored to create a "standalone" service for property access. IMO
coding business logic in Cocoon components isn't a good practise anyway,
they should only be responsible for accessing business services from
pipelines.
HTH,
-- Andreas
--
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]