com.socialsite.user.AllUsersPanel.java Source code

Java tutorial

Introduction

Here is the source code for com.socialsite.user.AllUsersPanel.java

Source

/**
 *     Copyright SocialSite (C) 2009
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.socialsite.user;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.IDataProvider;

import com.socialsite.BasePanel;
import com.socialsite.image.ImagePanel;
import com.socialsite.image.ImageType;
import com.socialsite.persistence.User;

/**
 * @author Ananth
 */
public class AllUsersPanel extends BasePanel {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public AllUsersPanel(String id, IDataProvider<User> dataProvider) {
        super(id);
        final DataView<User> userList = new DataView<User>("friends", dataProvider, 12) {
            /**
             * 
             */
            private static final long serialVersionUID = 1L;

            @Override
            protected void populateItem(final Item<User> item) {
                final User user = item.getModelObject();
                UserLink<User> userImageLink;
                item.add(userImageLink = new UserLink<User>("imagelink", item.getModel()));
                userImageLink.add(
                        new ImagePanel("user", user.getId(), ImageType.USER, user.getLastModified(), false, false));
                Link<User> name;
                item.add(name = new UserLink<User>("home", item.getModel()));
                name.add(new Label("username", item.getModelObject().getUserName()));

                item.add(new Label("city", user.getProfile().getCurrentCity().getValue()));
                item.add(new Label("sex", user.getProfile().getSex()));

            }

        };

        add(new PagingNavigator("paging", userList));
        add(userList);
    }

}