You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by HHB <hu...@yahoo.ca> on 2009/04/22 16:27:43 UTC

Basic help please

Hey,
I have a panel that consists of two parts:
the first lists groups names.
the second lists the contacts of a group, which gets 
populated upon clicking on the group name (via Ajax).

<wicket:panel>
    <div>
        <div wicket:id="groups">
            <span wicket:id="name">Group Name</span>
        </div>
    </div>
    <div>
        <div>
            <table wicket:id="contactsTable">
                <tr wicket:id="contacts">
                    <td><span wicket:id="gsm">number</span></td>
                </tr>
            </table>
        </div>
    </div>
</wicket:panel>

I created this model:

public class ContactsModel extends 
    LoadableDetachableModel {

    private Long groupId;

    @SpringBean
    private Service service;

    public ContactsModel(Long groupId) {
        InjectorHolder.getInjector().inject(this);
        this.groupId = groupId;
    }

    @Override
    protected Object load() {
        return service.findContactsByGroupId(groupId);
    }

}

And here is a snippet from the panel class:

ListView entry = new ListView("groups", 
    new GroupsModel()) {
    @Override
    protected void populateItem(ListItem item) {
    Group group = (Group) item.getModelObject();
    item.setModel(new CompoundPropertyModel(group));
    item.add(new AjaxFallbackLink("") {
       @Override
       public void onClick(AjaxRequestTarget target) {
          //what to do?
       }
    });
    }
};


Yes, inside onClick I can get the group ID, but what to do?
I have to do something like this inside onClick:
ContactsModel cm = new ContactsModel(groupId);
What to put inside onClick() ?
I'm new to Wicket so I appreciate your time.
Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Basic help please

Posted by Linda van der Pal <lv...@heritageagenturen.nl>.
I think you should detach the model of the contacts and then add the 
contacts to the target.

Linda.

HHB wrote:
> Hey,
> I have a panel that consists of two parts:
> the first lists groups names.
> the second lists the contacts of a group, which gets 
> populated upon clicking on the group name (via Ajax).
>
> <wicket:panel>
>     <div>
>         <div wicket:id="groups">
>             <span wicket:id="name">Group Name</span>
>         </div>
>     </div>
>     <div>
>         <div>
>             <table wicket:id="contactsTable">
>                 <tr wicket:id="contacts">
>                     <td><span wicket:id="gsm">number</span></td>
>                 </tr>
>             </table>
>         </div>
>     </div>
> </wicket:panel>
>
> I created this model:
>
> public class ContactsModel extends 
>     LoadableDetachableModel {
>
>     private Long groupId;
>
>     @SpringBean
>     private Service service;
>
>     public ContactsModel(Long groupId) {
>         InjectorHolder.getInjector().inject(this);
>         this.groupId = groupId;
>     }
>
>     @Override
>     protected Object load() {
>         return service.findContactsByGroupId(groupId);
>     }
>
> }
>
> And here is a snippet from the panel class:
>
> ListView entry = new ListView("groups", 
>     new GroupsModel()) {
>     @Override
>     protected void populateItem(ListItem item) {
>     Group group = (Group) item.getModelObject();
>     item.setModel(new CompoundPropertyModel(group));
>     item.add(new AjaxFallbackLink("") {
>        @Override
>        public void onClick(AjaxRequestTarget target) {
>           //what to do?
>        }
>     });
>     }
> };
>
>
> Yes, inside onClick I can get the group ID, but what to do?
> I have to do something like this inside onClick:
> ContactsModel cm = new ContactsModel(groupId);
> What to put inside onClick() ?
> I'm new to Wicket so I appreciate your time.
> Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>   
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.287 / Virus Database: 270.12.2/2072 - Release Date: 04/21/09 16:48:00
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org