You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by ma...@schrick-design.de on 2009/02/25 16:08:42 UTC
getting objectmodel in flowscript (using properties module), Lenya 2.0.x
Hi Lenya Devs,
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?
Or is there a more elegant way to get the values of (Lenya) properties inside a JavaScript FlowScript?
Many thanks ahead,
Gerd
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org
Re: getting objectmodel in flowscript (using properties module),
Lenya 2.0.x
Posted by Andreas Hartmann <an...@apache.org>.
Hi Gerd,
mail@schrick-design.de 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: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org