You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Rene Stolle <re...@googlemail.com> on 2011/04/23 19:01:10 UTC
CompoundPropertyModel and Image
Hi there,
I have a rather simple problem, but could find a solution yet. I wanna
combine text and an image in ONE model. The image is defined by a
ContextRelativeResource. It works all as assumed, except for the
image. Here the whole thing:
public class Team extends WebPage
{
public static class TeamMember implements Serializable
{
final String name;
final Integer age;
final ContextRelativeResource picture;
// final PackageResource picture;
public TeamMember (final String name, final Integer age, String pic)
{
this.name = name;
this.age = age;
this.picture = new ContextRelativeResource ("image/" + pic);
}
}
public Team ()
{
CompoundPropertyModel<TeamMember> tm = new
CompoundPropertyModel<TeamMember> (reneTm) ;
setDefaultModel (tm) ;
add (new Label ("name")); // works with string
add (new Label ("age")); // works with Integer
add (new Image ("picture")); // DOESNT WORK??
// Image image = new Image ("picture", tm.getObject ().picture);
// image.getDefaultModelObject () == NULL ????
}
}
For the completeness, here the markup:
<table border="1">
<tr>
<td>
<span wicket:id="name"></span>
</td>
<td>
<img src="#" alt="" wicket:id="picture">
</td>
<td>
<span wicket:id="age"></span>
</td>
</tr>
</table>
It seems, that Image doesnt use the CompoundPropertyModel which I set
as the default model. If I would use Label instead of Image, the
correct ContextRelativeResource will be retrieved from the model.
What did I do wrong, or how to combine text and image in one Model??
Regards,
Rene
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: CompoundPropertyModel and Image
Posted by andrea del bene <an...@libero.it>.
Hi,
I've checked Image's source class and it seems that it doesn't support
compound models (see comments in method initModel()).
> Hi there,
>
> I have a rather simple problem, but could find a solution yet. I wanna
> combine text and an image in ONE model. The image is defined by a
> ContextRelativeResource. It works all as assumed, except for the
> image. Here the whole thing:
>
> public class Team extends WebPage
> {
> public static class TeamMember implements Serializable
> {
> final String name;
> final Integer age;
> final ContextRelativeResource picture;
> // final PackageResource picture;
>
> public TeamMember (final String name, final Integer age, String pic)
> {
> this.name = name;
> this.age = age;
> this.picture = new ContextRelativeResource ("image/" + pic);
> }
> }
>
> public Team ()
> {
> CompoundPropertyModel<TeamMember> tm = new
> CompoundPropertyModel<TeamMember> (reneTm) ;
> setDefaultModel (tm) ;
>
> add (new Label ("name")); // works with string
> add (new Label ("age")); // works with Integer
>
> add (new Image ("picture")); // DOESNT WORK??
>
> // Image image = new Image ("picture", tm.getObject ().picture);
> // image.getDefaultModelObject () == NULL ????
>
> }
> }
>
> For the completeness, here the markup:
>
> <table border="1">
> <tr>
> <td>
> <span wicket:id="name"></span>
> </td>
> <td>
> <img src="#" alt="" wicket:id="picture">
> </td>
> <td>
> <span wicket:id="age"></span>
> </td>
> </tr>
> </table>
>
> It seems, that Image doesnt use the CompoundPropertyModel which I set
> as the default model. If I would use Label instead of Image, the
> correct ContextRelativeResource will be retrieved from the model.
>
> What did I do wrong, or how to combine text and image in one Model??
>
> Regards,
> Rene
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org