You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by werner <we...@gefi.at> on 2006/01/19 16:47:20 UTC

[CFORMS] dynamic binding

Does anybody know a clean approach for dynamic binding. For example it
would be nice to use a JXTemplate for the binding and pass it some vars
like it works with showForm:

form.createBinding("binding.jx", {"param1": somevalue, "param2":
somevalue});

I know it's possible to solve this with a special pipline and call the
binding with /binding.jx/param1/param2
But that's ugly IMO. 


Werner

Re: [CFORMS] dynamic binding

Posted by werner <we...@gefi.at>.
Thanks for your answer. I think that Bruno's suggestion (passing
parameter in form.load instead() of form.createBinding() ) is perfect
for me. 

Werner


Am Freitag, den 20.01.2006, 07:00 -0700 schrieb Jason Johnston:

> werner wrote:
> > Am Donnerstag, den 19.01.2006, 11:27 -0700 schrieb Jason Johnston:
> > 
> >>> Does anybody know a clean approach for dynamic binding. For example it
> >>> would be nice to use a JXTemplate for the binding and pass it some vars
> >>> like it works with showForm:
> >>>
> >>> form.createBinding("binding.jx", {"param1": somevalue, "param2":
> >>> somevalue});
> >>>
> >>> I know it's possible to solve this with a special pipline and call the
> >>> binding with /binding.jx/param1/param2
> >>> But that's ugly IMO.
> >>
> > 
> > Thanks for your answer Jason.
> > 
> >>
> >>Looks like somebody posted a patch for this feature:
> >>https://issues.apache.org/jira/browse/COCOON-1418
> >>
> >>In the meantime you can use request attributes or parameters as a
> >>transport for your data.
> >>
> > 
> > That's how I'm doing it right now. But in some cases that is not enough. 
> > Especially when you want to pass more than 3 parameters to the binding.
> 
> You should be able to pass an arbitrary number of attributes.  I was 
> thinking something like:
> 
> cocoon.request.setAttribute("param1", "value1");
> cocoon.request.setAttribute("param2", "value2");
> //...ad nauseum
> form.createBinding("cocoon://binding.jx");
> 
> ...then in your jx template:
> 
> <jx:set var="param1" value="${cocoon.request.getAttribute('param1')}" />
> <jx:set var="param2" value="${cocoon.request.getAttribute('param2')}" />
> etc...
> 
> This is untested but seems to me like it should work.
> 
> If you didn't want to pollute the request object with so many attributes 
> you might be able to use a single request attribute with a JS object as 
> its value: c.r.setAttribute("data", {param1:"value1", param2:"value2"}); 
> you'd have to figure out how to traverse the JS object within the 
> template... I think JXPath expressions could do so.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 



Re: [CFORMS] dynamic binding

Posted by Jason Johnston <co...@lojjic.net>.
werner wrote:
> Am Donnerstag, den 19.01.2006, 11:27 -0700 schrieb Jason Johnston:
> 
>>> Does anybody know a clean approach for dynamic binding. For example it
>>> would be nice to use a JXTemplate for the binding and pass it some vars
>>> like it works with showForm:
>>>
>>> form.createBinding("binding.jx", {"param1": somevalue, "param2":
>>> somevalue});
>>>
>>> I know it's possible to solve this with a special pipline and call the
>>> binding with /binding.jx/param1/param2
>>> But that's ugly IMO.
>>
> 
> Thanks for your answer Jason.
> 
>>
>>Looks like somebody posted a patch for this feature:
>>https://issues.apache.org/jira/browse/COCOON-1418
>>
>>In the meantime you can use request attributes or parameters as a
>>transport for your data.
>>
> 
> That's how I'm doing it right now. But in some cases that is not enough. 
> Especially when you want to pass more than 3 parameters to the binding.

You should be able to pass an arbitrary number of attributes.  I was 
thinking something like:

cocoon.request.setAttribute("param1", "value1");
cocoon.request.setAttribute("param2", "value2");
//...ad nauseum
form.createBinding("cocoon://binding.jx");

...then in your jx template:

<jx:set var="param1" value="${cocoon.request.getAttribute('param1')}" />
<jx:set var="param2" value="${cocoon.request.getAttribute('param2')}" />
etc...

This is untested but seems to me like it should work.

If you didn't want to pollute the request object with so many attributes 
you might be able to use a single request attribute with a JS object as 
its value: c.r.setAttribute("data", {param1:"value1", param2:"value2"}); 
you'd have to figure out how to traverse the JS object within the 
template... I think JXPath expressions could do so.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [CFORMS] dynamic binding

Posted by werner <we...@gefi.at>.
Am Freitag, den 20.01.2006, 09:51 +0100 schrieb Bruno Dumon:

> On Fri, 2006-01-20 at 08:21 +0100, werner wrote:
> > Am Donnerstag, den 19.01.2006, 11:27 -0700 schrieb Jason Johnston: 
> > > > Does anybody know a clean approach for dynamic binding. For example it
> > > > would be nice to use a JXTemplate for the binding and pass it some vars
> > > > like it works with showForm:
> > > >
> > > > form.createBinding("binding.jx", {"param1": somevalue, "param2":
> > > > somevalue});
> > > >
> > > > I know it's possible to solve this with a special pipline and call the
> > > > binding with /binding.jx/param1/param2
> > > > But that's ugly IMO.
> > 
> > Thanks for your answer Jason.
> > 
> > > 
> > > Looks like somebody posted a patch for this feature:
> > > https://issues.apache.org/jira/browse/COCOON-1418
> > > 
> > > In the meantime you can use request attributes or parameters as a
> > > transport for your data.
> > 
> > That's how I'm doing it right now. But in some cases that is not
> > enough. Especially when you want to pass more than 3 parameters to the
> > binding.
> > 
> 
> I'm not sure what kind of dynamism you need, but if it is in the JXPath
> expressions you can pass parameters to the binding along with your
> 'bussiness object':
> 
> form.load({"data": dataObject, "param1" : "value1", "param2" :
> "value2"});
> 
> In the binding you'll then need to adjust the fb:context to start form
> "/data". The parameters are accessible in JXPath expressions using e.g.
> "/param1".
> 


Thank you Bruno! That was exactly what I was looking for. I don't know
why I never tried to pass the parameter in form.load() instead of
form.createbinding(). This is perfectly clean and easy. Thank you!

Werner




Re: [CFORMS] dynamic binding

Posted by Bruno Dumon <br...@outerthought.org>.
On Fri, 2006-01-20 at 08:21 +0100, werner wrote:
> Am Donnerstag, den 19.01.2006, 11:27 -0700 schrieb Jason Johnston: 
> > > Does anybody know a clean approach for dynamic binding. For example it
> > > would be nice to use a JXTemplate for the binding and pass it some vars
> > > like it works with showForm:
> > >
> > > form.createBinding("binding.jx", {"param1": somevalue, "param2":
> > > somevalue});
> > >
> > > I know it's possible to solve this with a special pipline and call the
> > > binding with /binding.jx/param1/param2
> > > But that's ugly IMO.
> 
> Thanks for your answer Jason.
> 
> > 
> > Looks like somebody posted a patch for this feature:
> > https://issues.apache.org/jira/browse/COCOON-1418
> > 
> > In the meantime you can use request attributes or parameters as a
> > transport for your data.
> 
> That's how I'm doing it right now. But in some cases that is not
> enough. Especially when you want to pass more than 3 parameters to the
> binding.
> 

I'm not sure what kind of dynamism you need, but if it is in the JXPath
expressions you can pass parameters to the binding along with your
'bussiness object':

form.load({"data": dataObject, "param1" : "value1", "param2" :
"value2"});

In the binding you'll then need to adjust the fb:context to start form
"/data". The parameters are accessible in JXPath expressions using e.g.
"/param1".

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [CFORMS] dynamic binding

Posted by werner <we...@gefi.at>.
Am Donnerstag, den 19.01.2006, 11:27 -0700 schrieb Jason Johnston:

> > Does anybody know a clean approach for dynamic binding. For example it
> > would be nice to use a JXTemplate for the binding and pass it some vars
> > like it works with showForm:
> >
> > form.createBinding("binding.jx", {"param1": somevalue, "param2":
> > somevalue});
> >
> > I know it's possible to solve this with a special pipline and call the
> > binding with /binding.jx/param1/param2
> > But that's ugly IMO.


Thanks for your answer Jason.


> 
> Looks like somebody posted a patch for this feature:
> https://issues.apache.org/jira/browse/COCOON-1418
> 
> In the meantime you can use request attributes or parameters as a
> transport for your data.


That's how I'm doing it right now. But in some cases that is not enough.
Especially when you want to pass more than 3 parameters to the binding.


Werner

> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 



Re: [CFORMS] dynamic binding

Posted by Jason Johnston <co...@lojjic.net>.
> Does anybody know a clean approach for dynamic binding. For example it
> would be nice to use a JXTemplate for the binding and pass it some vars
> like it works with showForm:
>
> form.createBinding("binding.jx", {"param1": somevalue, "param2":
> somevalue});
>
> I know it's possible to solve this with a special pipline and call the
> binding with /binding.jx/param1/param2
> But that's ugly IMO.

Looks like somebody posted a patch for this feature:
https://issues.apache.org/jira/browse/COCOON-1418

In the meantime you can use request attributes or parameters as a
transport for your data.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org