Thanks for taking time to answer :-)
I first had all of this working for a single page. *After* that, I
started a refactoring effort to be able to share some parts of the code
with other pages. That is, I'm moving out some working code from the
page (java + template) to a component. All of this seems very straight
forward, besides the fact that the two parameters behaves so
differently. Bottom line: the code runs OK when used in single page, but
there are problems factoring out a component.
Part of this is the feeling: the parameter passing works in one case
and not in the other. This makes me unhappy. I want to understand
what's possible and not w r to parameter passing, and this seems to be a
little unclear to me. Davor Hrg indicated that there might be some
problems w generics, so I guess this is not that simple(?). And although
I've read what I found about coercion, I wouldn't say I understand this
fully. I *am* that stupid, have to live with it ;-)
The reasons to extend Map is perhaps outside the scope of this
discussion, although I'm of course ready to go into it this would make
things more clear.
Maybe this boils down to a simple question before diving into more code:
is Tapestry expected to handle my two parameters of type List<String>
and List<MyMap> in the same way? Or is there s difference between a
List of a "well-known" type and List containing a user defined type?
--Alec
Jonathan Barker wrote:
This is really sounding like something unrelated to Tapestry, and there
isn't enough code presented to tell.
Do you have proof that your code works outside of Tapestry? Why, and how,
did you EXTEND TreeMap? Do you have a unit test to prove that your MyMap
works?
If you can present a non-Tapestry test that works, and corresponding
Tapestry test that doesn't, then I think you'll find an answer quickly.
Jonathan
-----Original Message-----
From: Alec Leamas [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 01, 2008 8:37 AM
To: Tapestry users
Subject: Re: T5, newbie: Component parameter passing problems
public List<MyMap> getRows() {...}
Davor Hrg wrote:
how is getRows declared in your page class ?
On Tue, Apr 1, 2008 at 2:09 PM, Michael Kolmodin <[EMAIL PROTECTED]>
wrote:
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 <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
-----------------------------------------------------------------------
---
Michael Kolmodin Fredsgatan 2
Phone: +46 920 269413 S-972 35 Lulea
Mobile +46 70 551 6507 Sweden
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]