How about providing your contacts listview with some actual objects to show?

new Model() doesn't provide a list to iterate through.

Martijn

On Sun, Apr 26, 2009 at 12:05 PM, HHB <[email protected]> wrote:
> Hey,
> I have a panel that consists of two divs:
> one for listing available groups.
> second will display contacts for a group.
> The contacts div will get populated upon clicking
> of group name.
> ******************************
> 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);
>    }
>
> }
> ******************************
> public class ContactsPanel extends Panel {
>
>    public ContactsPanel(String id) {
>        super(id);
>        setOutputMarkupId(true);
>
>        final PageableListView contacts = new
>          PageableListView("contacts", new Model(), 10) {
>           �...@override
>            protected void populateItem(ListItem item) {
>                Contact contact =
>                (Contact) item.getModelObject();
>                item.setModel(new
>                  CompoundPropertyModel(contact));
>                item.add(new Label("gsm"));
>            }
>        };
>        contacts.setOutputMarkupId(true);
>
>        final WebMarkupContainer wmc =
>           new WebMarkupContainer("contactsTable");
>        wmc.setOutputMarkupId(true);
>        wmc.add(contacts);
>        add(wmc);
>
>        ListView entry = new ListView("groups",
>            new GroupsModel()) {
>           �...@override
>            protected void populateItem(ListItem item) {
>                final Group group = (Group) item.getModelObject();
>                item.setModel(new CompoundPropertyModel(group));
>                AjaxFallbackLink nameLink =
>                    new AjaxFallbackLink("nameLink") {
>                   �...@override
>                    public void onClick(AjaxRequestTarget target) {
>                        Long groupId = group.getId();
>                        ContactsModel model =
>                        new ContactsModel(groupId);
>                        contacts.setModel(model);
>                        target.addComponent(wmc);
>                    }
>                };
>                nameLink.add(new Label("name"));
>                item.add(nameLink);
>            }
>        };
>        add(entry);
>
>        add(new
>            PagingNavigator("contactsNavigator", contacts));
>    }
>
> }
> ******************************
> <wicket:panel>
>    <div style="float: left; width:40%">
>        <div wicket:id="groups">
>            <a href="#" wicket:id="nameLink">
>  <span wicket:id="name">Group Name</span></a><br/>
>        </div>
>    </div>
>    <div>
>        <div style="float: right; width:60%">
>            <table wicket:id="contactsTable">
>                <th>GSM</th>
>                <tr wicket:id="contacts">
>                    <td>
>                    <span wicket:id="gsm">1111111111</span>
>                    </td>
>                </tr>
>            </table>
>            <div wicket:id="contactsNavigator"></div>
>        </div>
>    </div>
> </wicket:panel>
> ******************************
> When creating the contacts PageableListView,
> I have to provide a model and since no group is selected,
> I provided an empty Model()
> The problem is when clicking on a group name in order
> to get its contacts, the PagingNavigator is not working properly.
> It just displays << < > >>
> Any ideas what is going wrong?
> Thanks.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.5 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to