You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alec Leamas <le...@gmail.com> on 2008/04/04 19:04:25 UTC

Re: T5, newbie: [Solved] Component parameter passing problems

Thanks to Josh this problem has been solved. The culprit was how I 
invoked the components. I was using  <t:Layout rows="${rows}" ... />

I should use <t:Layout rows="prop:rows" ... />

Thanks for all help! And a special thank to Josh!

--Alec


Davor Hrg wrote:
> how is getRows declared in your page class ?
>
>   
>> OK, thanks...
>>
>> In my page, I have <t:myComponent columns="prop:columns"
>> rows="prop:rows"/>
>>
>> The columns argument, a List<String> is just fine.
>> The rows argument, a List<MyMap> is the problem.
>>
>> The page has a List<MyMap> getRows() which is verified.
>>
>> Looking in MyComponent.java, I have
>>
>>    @Parameter
>>     private List<MyMap>  rows;
>>
>>     @Parameter
>>     private List<String> columns;
>>
>> public String getSomethingStrange()
>> {
>>     return rows.get(0).get( "mail" );
>> }
>>
>> The latter getter fails. The debug info is from a breakpoint inside this
>> method. The error I get is a classcast error "java.lang.String cannot be
>> cast to ...MyMap" If I change the index to 1, there  an error "Caused
>> by: Index: 1, Size: 1" i. e., index out of bounds.
>>
>> Davor Hrg wrote:
>>     
>>> Tapestry support for Java generics is very limited,
>>> you need a value encoder to make this work,
>>>
>>> also, add more details on who calls what... so more is known
>>> of the problem you are trying to solve.
>>>
>>>
>>> Davor Hrg
>>>
>>> On Tue, Apr 1, 2008 at 1:43 PM, Alec Leamas <le...@gmail.com>
>>>       
>> wrote:
>>     
>>>> I have problems passing my own datatype(s) to my own component. The
>>>> component takes two parameters, one List<String> and one List<MyMap>.
>>>> MyMap is declared as MyMap extends TreeMap {...}.
>>>>
>>>> The first parameter, a list of strings arrives safely to my component.
>>>> However, the other one, seems to be mixed up: when I try to access an
>>>> element in my List<MyMap>, it turns out that Tapestry (nothing else
>>>> involved)  have filled  this list with String items, not the expected
>>>> MyMap items. In the end, there is a class cast exception when trying to
>>>> access the MyMap items as Maps.
>>>>
>>>> In the Eclipse debugger, it seems that the value of the List<MyMap>
>>>> instance variable is a single string holding what looks like  the
>>>> serialized value of my List<MyMap>  list. The start is
>>>> "[{key=value,key=value...
>>>>
>>>> I've tried to contribute coercions between MyMap<->Map, but this desn't
>>>> seem to help (?).
>>>>
>>>> Basically, I'm stucked unless I write everything in several big pages
>>>> with duplicated code. Don't really want to do that. :-(
>>>>
>>>> Any hints out there?
>>>>
>>>> --alec
>>>>
>>>> PS  Version: 5.0.11 DS
>>>>
>>>>         


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