Re: [Wicket-user] Map.Entry and serialization

2007-05-30 Thread Sven Schliesing
Ah, perfect :)

Thank you so much for your help!

Johan Compagner wrote:
> Model model = new Model(map)
> {
>   getObject()
>   {
>   return new List(map.entries())
>   }
> }
> 
> ListView lv = new ListView(x,model);
> johan


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Map.Entry and serialization

2007-05-30 Thread Johan Compagner

Model model = new Model(map)
{
 getObject()
 {
 return new List(map.entries())
 }
}

ListView lv = new ListView(x,model);
johan


On 5/30/07, Sven Schliesing <[EMAIL PROTECTED]> wrote:


I tried that already. But I ran into the following problem:
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be
cast to java.util.List
at org.apache.wicket.markup.html.list.ListView.getList(
ListView.java:174)
at
org.apache.wicket.markup.html.list.ListView.getViewSize(ListView.java:227)
at
org.apache.wicket.markup.html.list.ListView.onBeforeRender(ListView.java
:538)
at org.apache.wicket.Component.beforeRender(Component.java:3037)
at
org.apache.wicket.MarkupContainer.onBeforeRenderChildren(
MarkupContainer.java:1433)
... 28 more

The method-body:
public final List getList()
{
final List list = (List)getModelObject();
if (list == null)
{
return Collections.EMPTY_LIST;
}
return list;
}

So there is a need to use a List. I can't override getList() cause it's
final.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Map.Entry and serialization

2007-05-30 Thread Sven Schliesing
I tried that already. But I ran into the following problem:
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be 
cast to java.util.List
at 
org.apache.wicket.markup.html.list.ListView.getList(ListView.java:174)
at 
org.apache.wicket.markup.html.list.ListView.getViewSize(ListView.java:227)
at 
org.apache.wicket.markup.html.list.ListView.onBeforeRender(ListView.java:538)
at org.apache.wicket.Component.beforeRender(Component.java:3037)
at 
org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1433)
... 28 more

The method-body:
public final List getList()
{
final List list = (List)getModelObject();
if (list == null)
{
return Collections.EMPTY_LIST;
}
return list;
}

So there is a need to use a List. I can't override getList() cause it's 
final.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Map.Entry and serialization

2007-05-30 Thread Johan Compagner

ahh ok change this
new ListView("list", new ArrayList>(map.entrySet()))
{

thats wrong you can't keep Map.Entry objects in a arraylist.
why not keep the map yourself?

new ListView("list", new Model(map) {

johan


On 5/30/07, Sven Schliesing <[EMAIL PROTECTED]> wrote:


Changing the code to:
new ListView("list", new ArrayList>(map.entrySet())) {
public void populateItem(ListItem listItem) {
  Map.Entry entry = (Map.Entry)
listItem.getModelObject();
  ...
}
};

doesn't fix the problem. Furthermore
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html says that
Maps are not serializable. Now I'm confused.

btw: I didn't make the variable final to use it in an inner class. It
was just a leftover of c&p.


Sven

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Map.Entry and serialization

2007-05-30 Thread Matthieu Casanova

2007/5/30, Sven Schliesing <[EMAIL PROTECTED]>:


Changing the code to:
new ListView("list", new ArrayList>(map.entrySet())) {
public void populateItem(ListItem listItem) {
  Map.Entry entry = (Map.Entry)
listItem.getModelObject();
  ...
}
};

doesn't fix the problem. Furthermore
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html says that
Maps are not serializable. Now I'm confused.

btw: I didn't make the variable final to use it in an inner class. It
was just a leftover of c&p.



I don't know exactly how to fix the problem, but that's right,
Map.Entryaren't serializable.
The Map are serializable if the content is serializable. But when you
serializes a map, only keys and values are serialized, not the entries (that
are rebuilt when unserializing the map). So maybe you should create ( or use
if there is one) a Model that uses your map directly.

Matthieu
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Map.Entry and serialization

2007-05-30 Thread Sven Schliesing
Changing the code to:
new ListView("list", new ArrayList>(map.entrySet())) {
public void populateItem(ListItem listItem) {
  Map.Entry entry = (Map.Entry)
listItem.getModelObject();
  ...
}
};

doesn't fix the problem. Furthermore 
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Map.html says that 
Maps are not serializable. Now I'm confused.

btw: I didn't make the variable final to use it in an inner class. It 
was just a leftover of c&p.


Sven

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Map.Entry and serialization

2007-05-29 Thread Johan Compagner

no Maps are serializable
and yes your problem is the final keyword before that variable.
because you make it final so that you can reuse that in an (anonymous) inner
class
and then that Entry is placed in the session because it becomes a member of
that inner class

just remove the final keyword (and fix the problem a bit different) and you
will see that the serialization problem will be fixed

johan


On 5/29/07, Sven Schliesing <[EMAIL PROTECTED]> wrote:


So the problem isn't the final keyword but the fact that Maps aren't
serializable, right?

Johan Compagner wrote:
> remove the final keyword of the entry variable.
> You shouldn't keep entry objects like that then it will become members
> and an Map.Entry isn't serializeable
> because the HashMap doesn't serialize those (they aren't meant to be)
>
> johan

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Map.Entry and serialization

2007-05-29 Thread Sven Schliesing
So the problem isn't the final keyword but the fact that Maps aren't 
serializable, right?

Johan Compagner wrote:
> remove the final keyword of the entry variable.
> You shouldn't keep entry objects like that then it will become members 
> and an Map.Entry isn't serializeable
> because the HashMap doesn't serialize those (they aren't meant to be)
> 
> johan

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Map.Entry and serialization

2007-05-29 Thread Johan Compagner

remove the final keyword of the entry variable.
You shouldn't keep entry objects like that then it will become members and
an Map.Entry isn't serializeable
because the HashMap doesn't serialize those (they aren't meant to be)

johan


On 5/29/07, Sven Schliesing <[EMAIL PROTECTED]> wrote:


Hi,

I just ran into problems with a List view. The Model used for this is
actually a Map so I put in a entrySet() from the map in the ListView:

new ListView("list", new ArrayList>(map.entrySet())) {
   public void populateItem(final ListItem listItem) {
 final Map.Entry entry = (Map.Entry)
listItem.getModelObject();
 ...
   }
};


Unfortunately I'm getting an error message that Map.Entry is not
serializable.

I'm sure this is a known problem with a known fix. Isn't it?

Thanks in advance!

Sven

PS: I'm relatively new to Wicket. So feel free to kick me to a faq I
missed that covers this issue.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] Map.Entry and serialization

2007-05-29 Thread Sven Schliesing
Btw: I'm using 1.3.0-incubating-SNAPSHOT if that matters.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


[Wicket-user] Map.Entry and serialization

2007-05-29 Thread Sven Schliesing
Hi,

I just ran into problems with a List view. The Model used for this is 
actually a Map so I put in a entrySet() from the map in the ListView:

new ListView("list", new ArrayList>(map.entrySet())) {
   public void populateItem(final ListItem listItem) {
 final Map.Entry entry = (Map.Entry) 
listItem.getModelObject();
 ...
   }
};


Unfortunately I'm getting an error message that Map.Entry is not 
serializable.

I'm sure this is a known problem with a known fix. Isn't it?

Thanks in advance!

Sven

PS: I'm relatively new to Wicket. So feel free to kick me to a faq I 
missed that covers this issue.


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user