Personally i prefer overriding protected IModel getListItemModel(final
IModel listViewModel, final int index) which has the same effect but
allows you to create a reusable subclass from listview which always
uses a compoundpropertymodel.
you can simply do return new
CompoundPropertyModel(super.getListItemModel(listViewModel,index));
Maurice
On Nov 17, 2007 1:02 AM, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> what you are doing is fine because you are wrapping the model, not changing it
>
> but also see PropertyListView
>
> -igor
>
>
>
> On Nov 16, 2007 1:29 PM, TheMayor <[EMAIL PROTECTED]> wrote:
> >
> > Hello All,
> >
> > I love to use CompoundPropertyModel whenever I can, and I had a debate today
> > on how to appropriately use it within a ListView.
> >
> > Here is the markup, this is the start of the implementation of a message
> > panel:
> > <!--
> > <table>
> > <tr wicket:id="customerReceivedMessages">
> > <td width="15px">Ic</td>
> > <td width="auto">
> > Some message -
> > Some Summary text...</td>
> > <td width="15px"> </img></td>
> > <td width="10%">Time</td>
> > </tr>
> > </table>
> > -->
> > in the java code I set the model of the page initially:
> >
> > setModel(new CompoundPropertyModel(leadModel));
> >
> > And then when it is time to list all the messages, I use the following code
> > which corresponds to the markup
> >
> > ListView messages = new ListView("customerReceivedMessages") {
> >
> > @Override
> > protected void populateItem(ListItem item) {
> >
> > item.setModel(new CompoundPropertyModel(item.getModel()));
> >
> > item.add(new Label("subject"));
> > item.add(new Label("text"));
> >
> > StaticImage attachIcon = new StaticImage("attachmentIcon", new
> > Model("/_media/paperclip.gif"));
> > if(cm.getFileName() == null || cm.getFileName().equals("")) {
> > attachIcon.setVisible(false);
> > }
> > item.add(attachIcon);
> > item.add(new Label("summaryTime"));
> >
> > }
> >
> >
> > Now the issue is that my architect, who is more experienced wicket told me
> > that I should not be changing the model of item to a CompoundPropertyModel,
> > since ListView is in charge of controlling that model. The code works, but I
> > do get some undesirable side effects, for example:
> >
> > ConversationMessage cm = (ConversationMessage) item.getModelObject();
> >
> > will not work after I call setModel on item, even though the
> > CompoundPropertyModel should have the same ModelObject
> > (ConversationMessage).
> >
> > so 2 questions:
> >
> > Can you confirm that I am doing something wrong here?
> > How can I cleanly still use CompoundPropertyModel within the populateItem so
> > that I can keep the code without all those PropertyModel instantiations I
> > would have to do with the absence of a CompoundPropertyModel?
> >
> >
> > Thanks for taking a look at this.
> > Hassan Chafi
> > http://www.genietown.com GenieTown @ your service
> >
> >
> >
> > --
> > View this message in context:
> > http://www.nabble.com/Changing-the-model-of-a-ListView-item-to-use-CompoundPropertyModel-tf4824021.html#a13801970
> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > 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]