You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Muhammad Gelbana <m....@gmail.com> on 2012/11/11 17:14:38 UTC

Using maps withing templates

Has anyone used maps withing templates ? I have a very complex object graph
and I can't even process the first level !

I have an object with a map, which contains another map.

I checked that page:
http://tapestry.apache.org/property-expressions.html

But still couldn't get anything working. If anyone knows an open-source
module binding maps to form fields directly from a template, please share
it.

Thank you.

Re: Using maps withing templates

Posted by Lance Java <la...@googlemail.com>.
Chenillekit provides an "ognl:" binding, I'm not sure but this might support
setters on Maps?
http://chenillekit.codehaus.org/chenillekit-tapestry/ognlbinding.html

Here are some example custom bindings prefixes:
http://wiki.apache.org/tapestry/Tapestry5HowTos#Binding_Prefixes





--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-maps-withing-templates-tp5717910p5717927.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Using maps withing templates

Posted by Muhammad Gelbana <m....@gmail.com>.
The value I need to bind actually has a setter\getter so here it is how I
solved this:

> "commonOptions('overridePortOptions')?.value"


That saved me a lot of code, thanks !

Is there an example on how to provide a custom binding for v5.3.6 ?


On Mon, Nov 12, 2012 at 12:12 PM, Lance Java <la...@googlemail.com>wrote:

> Tapestry considers "prop:" bindings to a method invocation as read-only.
> Can
> you give an example of your data? The easiest solution is to wrap your maps
> in a model with getters and setters? If you can't do that, you might want
> to
> consider a custom binding or decorating / overriding the
> PropertyConduitSource.
>
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Using-maps-withing-templates-tp5717910p5717924.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Using maps withing templates

Posted by Lance Java <la...@googlemail.com>.
I meant a prop binding to a custom method invocation (ie not a getter)

eg:
prop:foo will have a read and write binding
prop:someMethod('foo') will have a read-only binding



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-maps-withing-templates-tp5717910p5717929.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Using maps withing templates

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 12 Nov 2012 08:12:27 -0200, Lance Java <la...@googlemail.com>  
wrote:

> Tapestry considers "prop:" bindings to a method invocation as read-only.

Actually, this isn't correct. prop is a read and write binding. When you  
bind a property via the prop binding to a form field component, for  
example, the component uses it to write the user-submitted value to the  
property.

The solution for this is to bind your form field to a property, something  
like ValueType getProperty() and setProperty(ValueType property), where  
the methods read and write to the correct key-pair in the map. As always,  
this is about moving logic from template to Java code, and that's why I  
don't think we need map syntax in the prop binding. And, of course, who  
disagrees with me can write your own binding.

-- 
Thiago H. de Paula Figueiredo

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


Re: Using maps withing templates

Posted by Lance Java <la...@googlemail.com>.
Tapestry considers "prop:" bindings to a method invocation as read-only. Can
you give an example of your data? The easiest solution is to wrap your maps
in a model with getters and setters? If you can't do that, you might want to
consider a custom binding or decorating / overriding the
PropertyConduitSource.





--
View this message in context: http://tapestry.1045711.n5.nabble.com/Using-maps-withing-templates-tp5717910p5717924.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Using maps withing templates

Posted by Muhammad Gelbana <m....@gmail.com>.
That works perfectly but how would it work to write into the variable ? So
the *binding* is complete.

Thank you.

On Mon, Nov 12, 2012 at 4:53 AM, Paul Stanton <pa...@mapshed.com.au> wrote:

> You can write a method in your java class instead of trying to write a
> parameter binding.
>
> eg
>
> getSomething(String key1, String key2)
> {...}
>
> <t:component parameter="getSomething('key1'**, 'key2')" />
>
>
> On 12/11/2012 3:52 AM, Muhammad Gelbana wrote:
>
>> Here is a sample of what I'm trying to do:
>>
>>> ixlTest.parameterGroups{'**testOptions'}{'serverIp'}
>>>
>>
>> And the error I'm getting
>>
>>  Could not convert 'ixlTest.parameterGroups{'**testOptions'}{'serverIp'}'
>>> into a component parameter binding: Error parsing property expression
>>> 'ixlTest.parameterGroups{'**testOptions'}{'serverIp'}': line 1:7
>>> missing EOF
>>> at '.'.
>>>
>>
>> Thank you.
>>
>> On Sun, Nov 11, 2012 at 6:14 PM, Muhammad Gelbana <m.gelbana@gmail.com
>> >wrote:
>>
>>  Has anyone used maps withing templates ? I have a very complex object
>>> graph and I can't even process the first level !
>>>
>>> I have an object with a map, which contains another map.
>>>
>>> I checked that page:
>>> http://tapestry.apache.org/**property-expressions.html<http://tapestry.apache.org/property-expressions.html>
>>>
>>> But still couldn't get anything working. If anyone knows an open-source
>>> module binding maps to form fields directly from a template, please share
>>> it.
>>>
>>> Thank you.
>>>
>>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Using maps withing templates

Posted by Paul Stanton <pa...@mapshed.com.au>.
You can write a method in your java class instead of trying to write a 
parameter binding.

eg

getSomething(String key1, String key2)
{...}

<t:component parameter="getSomething('key1', 'key2')" />

On 12/11/2012 3:52 AM, Muhammad Gelbana wrote:
> Here is a sample of what I'm trying to do:
>> ixlTest.parameterGroups{'testOptions'}{'serverIp'}
>
> And the error I'm getting
>
>> Could not convert 'ixlTest.parameterGroups{'testOptions'}{'serverIp'}'
>> into a component parameter binding: Error parsing property expression
>> 'ixlTest.parameterGroups{'testOptions'}{'serverIp'}': line 1:7 missing EOF
>> at '.'.
>
> Thank you.
>
> On Sun, Nov 11, 2012 at 6:14 PM, Muhammad Gelbana <m....@gmail.com>wrote:
>
>> Has anyone used maps withing templates ? I have a very complex object
>> graph and I can't even process the first level !
>>
>> I have an object with a map, which contains another map.
>>
>> I checked that page:
>> http://tapestry.apache.org/property-expressions.html
>>
>> But still couldn't get anything working. If anyone knows an open-source
>> module binding maps to form fields directly from a template, please share
>> it.
>>
>> Thank you.
>>


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


Re: Using maps withing templates

Posted by Muhammad Gelbana <m....@gmail.com>.
Here is a sample of what I'm trying to do:
>
> ixlTest.parameterGroups{'testOptions'}{'serverIp'}


And the error I'm getting

> Could not convert 'ixlTest.parameterGroups{'testOptions'}{'serverIp'}'
> into a component parameter binding: Error parsing property expression
> 'ixlTest.parameterGroups{'testOptions'}{'serverIp'}': line 1:7 missing EOF
> at '.'.


Thank you.

On Sun, Nov 11, 2012 at 6:14 PM, Muhammad Gelbana <m....@gmail.com>wrote:

> Has anyone used maps withing templates ? I have a very complex object
> graph and I can't even process the first level !
>
> I have an object with a map, which contains another map.
>
> I checked that page:
> http://tapestry.apache.org/property-expressions.html
>
> But still couldn't get anything working. If anyone knows an open-source
> module binding maps to form fields directly from a template, please share
> it.
>
> Thank you.
>