My problem is not just with lists: If I use a custom type as parameter instead of my List<MyMap> parameter I get the error: "Could not find a coercion from type java.lang.String to type net.kln.yalt.report.Report" where the Report is my custom type.

This is strange. I "have* been able to transfer the Report to a very simple test component. Enclosing my "real" component, which doesn't seem to accept parameter + the test component which accepts it.

So now I have five cases of parameter passing, with two components. Both components are invoked from the same template, and uses the same getters to provide the data. Results:

- List<String>  : works OK in all cases.
- List<MyMap>: the parameter passed seems to be wrong, a single string instead of a List<> when sent to class below. - Report: Exception "Could not find coercion from String to Report" when sent to class below.
- Report: works OK when sent to test component (4 lines).
- List<MyMap>: work ok when sent to test component

A little confused, I am. Part of this has been discussed earlier, no visible solution though (http://article.gmane.org/gmane.comp.java.tapestry.user/55319).

--alec


-------- Suspected class, does not accept parameters OK? -----------------------
package net.kln.yalt.components;
import "stuff"
@IncludeStylesheet("context:css/yalt.css")
public class Layout
{
   @Parameter( "false")
   private String       connectionUrl;

   @Parameter
//    private List<IRow>  listSource;
   private Report listSource;

   @Parameter
   private List<String> columns;

   @Inject
   private Messages     messages;

   @Inject
   @Path( "context:icons/connect_no.png")
   private Asset        disconnectIcon;

   @Inject
   @Path( "context:icons/connect_established.png")
   private Asset        connectIcon;

   @Inject
   @Path( "context:icons/yalt.svg")
   private Asset        yaltIcon;

   public Asset getYaltIcon()  { return yaltIcon; }

   public boolean isConnected()
  {
       return connectionUrl != null && !connectionUrl.equals( "false");
   }

   public Asset getDisconnectIcon() { return disconnectIcon; }

   public Asset getConnectIcon() {  return connectIcon; }
public boolean isListsVisible() { return listSource != null; } public String getConnectionTooltip()
   {
       return messages.format( "connectionTooltip",
                               connectionUrl.replace( "%20", " "));
   }

   public List<String> getColumns() { return columns; }

//  public List<IRow> getListSource() TODO revert
   public Report getListSource() { return listSource;   }
public String getOrvar() { return "" + listSource.size() } // Test code!
}

--------------------------------- test component, seems to work -----------------------------
public class ReportSize
{
  @Parameter
  private  Report report;
@Parameter
  private List<IRow> rows;
public Integer getReportSize() { return report.size(); }
  public String getFirstMail()
  {
       return rows.get( 0).getColumnValue( "mail");
  }
}


onathan 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]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to