Example usage for org.apache.wicket.ajax.markup.html AjaxLink add

List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink add

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html AjaxLink add.

Prototype

public MarkupContainer add(final Component... children) 

Source Link

Document

Adds the child component(s) to this container.

Usage

From source file:org.sakaiproject.profile2.tool.pages.panels.MessageThreadsView.java

License:Educational Community License

public MessageThreadsView(final String id) {
    super(id);//from w w  w  .  j ava 2s. c  o m

    log.debug("MessageThreads()");

    //get current user
    final String currentUserUuid = sakaiProxy.getCurrentUserId();

    //heading
    /*
    Label heading = new Label("messageThreadListHeading", new ResourceModel("heading.messages"));
    add(heading);
    */

    //no messages label
    Label noMessagesLabel = new Label("noMessagesLabel");
    noMessagesLabel.setOutputMarkupPlaceholderTag(true);
    add(noMessagesLabel);

    //container which wraps list
    final WebMarkupContainer messageThreadListContainer = new WebMarkupContainer("messageThreadListContainer");
    messageThreadListContainer.setOutputMarkupId(true);

    //get our list of messages
    final MessageThreadsDataProvider provider = new MessageThreadsDataProvider(currentUserUuid);
    int numMessages = (int) provider.size();

    //message list
    DataView<MessageThread> messageThreadList = new DataView<MessageThread>("messageThreadList", provider) {
        private static final long serialVersionUID = 1L;

        protected void populateItem(final Item<MessageThread> item) {

            final MessageThread thread = (MessageThread) item.getDefaultModelObject();
            Message message = thread.getMostRecentMessage();
            String messageFromUuid = message.getFrom();

            //we need to know if this message has been read or not so we can style it accordingly
            //we only need this if we didn't send the message
            MessageParticipant participant = null;

            boolean messageOwner = false;
            if (StringUtils.equals(messageFromUuid, currentUserUuid)) {
                messageOwner = true;
            }
            if (!messageOwner) {
                participant = messagingLogic.getMessageParticipant(message.getId(), currentUserUuid);
            }

            //prefs and privacy
            ProfilePreferences prefs = preferencesLogic.getPreferencesRecordForUser(messageFromUuid);
            ProfilePrivacy privacy = privacyLogic.getPrivacyRecordForUser(messageFromUuid);

            //photo link
            AjaxLink<String> photoLink = new AjaxLink<String>("photoLink", new Model<String>(messageFromUuid)) {
                private static final long serialVersionUID = 1L;

                public void onClick(AjaxRequestTarget target) {
                    setResponsePage(new ViewProfile(getModelObject()));
                }

            };

            //photo
            ProfileImage messagePhoto = new ProfileImage("messagePhoto", new Model<String>(messageFromUuid));
            messagePhoto.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
            photoLink.add(messagePhoto);
            item.add(photoLink);

            //name link
            AjaxLink<String> messageFromLink = new AjaxLink<String>("messageFromLink",
                    new Model<String>(messageFromUuid)) {
                private static final long serialVersionUID = 1L;

                public void onClick(AjaxRequestTarget target) {
                    setResponsePage(new ViewProfile(getModelObject()));
                }

            };
            messageFromLink.add(new Label("messageFromName",
                    new Model<String>(sakaiProxy.getUserDisplayName(messageFromUuid))));
            item.add(messageFromLink);

            //date
            item.add(new Label("messageDate", ProfileUtils.convertDateToString(message.getDatePosted(),
                    ProfileConstants.MESSAGE_DISPLAY_DATE_FORMAT)));

            //subject link
            AjaxLink<MessageThread> messageSubjectLink = new AjaxLink<MessageThread>("messageSubjectLink",
                    new Model<MessageThread>(thread)) {
                private static final long serialVersionUID = 1L;

                public void onClick(AjaxRequestTarget target) {
                    //load messageview panel
                    //setResponsePage(new MyMessageView(id, currentUserUuid, getModelObject().getId(), getModelObject().getSubject()));

                    //load MyMessages with some params that will then load a diff tab panel and show this message panel.
                    setResponsePage(new MyMessages(thread.getId()));

                }

            };
            messageSubjectLink.add(new Label("messageSubject", new Model<String>(thread.getSubject())));
            item.add(messageSubjectLink);

            //message body
            item.add(new Label("messageBody", new Model<String>(StringUtils.abbreviate(message.getMessage(),
                    ProfileConstants.MESSAGE_PREVIEW_MAX_LENGTH))));

            //unread notice for accessibility, off unless its new.
            Label messageUnreadNotice = new Label("messageUnreadNotice",
                    new ResourceModel("accessibility.messages.unread"));
            messageUnreadNotice.setVisible(false);
            item.add(messageUnreadNotice);

            //highlight if new, also render accessibility notice
            if (!messageOwner && !participant.isRead()) {
                item.add(new AttributeAppender("class", true, new Model<String>("unread-message"), " "));
                messageUnreadNotice.setVisible(true);
            }

            item.setOutputMarkupId(true);
        }

    };
    messageThreadList.setOutputMarkupId(true);
    messageThreadList.setItemsPerPage(ProfileConstants.MAX_MESSAGES_PER_PAGE);
    messageThreadListContainer.add(messageThreadList);
    add(messageThreadListContainer);

    //pager
    AjaxPagingNavigator pager = new AjaxPagingNavigator("navigator", messageThreadList);
    add(pager);

    //initially, if no message threads to show, hide container and pager, set and show label
    if (numMessages == 0) {
        messageThreadListContainer.setVisible(false);
        pager.setVisible(false);

        noMessagesLabel.setDefaultModel(new ResourceModel("text.messages.none"));
        noMessagesLabel.setVisible(true);
    }

    //also, if num less than num required for pager, hide it
    if (numMessages <= ProfileConstants.MAX_MESSAGES_PER_PAGE) {
        pager.setVisible(false);
    }
}

From source file:org.sakaiproject.profile2.tool.pages.panels.MessageView.java

License:Educational Community License

/**
 * Does the actual rendering of the page
 * @param currentUserUuid/*  ww  w  . ja  v  a 2 s  .  c  om*/
 * @param threadId
 * @param threadSubject
 */
private void renderMyMessagesView(final String currentUserUuid, final String threadId,
        final String threadSubject) {

    //details container
    WebMarkupContainer messageDetailsContainer = new WebMarkupContainer("messageDetailsContainer");
    messageDetailsContainer.setOutputMarkupId(true);

    //thread subject
    Label threadSubjectLabel = new Label("threadSubject", new Model<String>(threadSubject));
    messageDetailsContainer.add(threadSubjectLabel);

    add(messageDetailsContainer);

    //list container
    messageListContainer = new WebMarkupContainer("messageListContainer");
    messageListContainer.setOutputMarkupId(true);

    //get our list of messages
    final MessagesDataProvider provider = new MessagesDataProvider(threadId);

    messageList = new DataView<Message>("messageList", provider) {
        private static final long serialVersionUID = 1L;

        protected void populateItem(final Item<Message> item) {

            final Message message = (Message) item.getDefaultModelObject();
            final String messageFromUuid = message.getFrom();

            //we need to know if this message has been read or not so we can style it accordingly
            //we only need this if we didn't send the message
            MessageParticipant participant = null;

            boolean messageOwner = false;
            if (StringUtils.equals(messageFromUuid, currentUserUuid)) {
                messageOwner = true;
            }
            if (!messageOwner) {
                participant = messagingLogic.getMessageParticipant(message.getId(), currentUserUuid);
            }

            //prefs and privacy
            ProfilePreferences prefs = preferencesLogic.getPreferencesRecordForUser(messageFromUuid);
            ProfilePrivacy privacy = privacyLogic.getPrivacyRecordForUser(messageFromUuid);

            //photo link
            AjaxLink<String> photoLink = new AjaxLink<String>("photoLink", new Model<String>(messageFromUuid)) {
                private static final long serialVersionUID = 1L;

                public void onClick(AjaxRequestTarget target) {
                    setResponsePage(new ViewProfile(getModelObject()));
                }

            };

            //photo
            /* disabled for now
            ProfileImage messagePhoto = new ProfileImage("messagePhoto", new Model<String>(messageFromUuid));
            messagePhoto.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
            photoLink.add(messagePhoto);
            */
            item.add(photoLink);

            //name link
            AjaxLink<String> messageFromLink = new AjaxLink<String>("messageFromLink",
                    new Model<String>(messageFromUuid)) {
                private static final long serialVersionUID = 1L;

                public void onClick(AjaxRequestTarget target) {
                    setResponsePage(new ViewProfile(getModelObject()));
                }

            };
            messageFromLink.add(new Label("messageFromName",
                    new Model<String>(sakaiProxy.getUserDisplayName(messageFromUuid))));
            item.add(messageFromLink);

            //date
            item.add(new Label("messageDate", ProfileUtils.convertDateToString(message.getDatePosted(),
                    ProfileConstants.MESSAGE_DISPLAY_DATE_FORMAT)));

            //message body
            item.add(new Label("messageBody", new Model<String>(message.getMessage())));

            //highlight if new, then mark it as read
            if (!messageOwner && !participant.isRead()) {
                item.add(new AttributeAppender("class", true, new Model<String>("unread-message"), " "));
                messagingLogic.toggleMessageRead(participant, true);

                //set param for first unread message in the thread
                if (!lastUnreadSet) {
                    lastUnreadSet = true;
                    item.add(new AttributeModifier("rel", true, new Model<String>("lastUnread")));
                }

            }

            item.setOutputMarkupId(true);

        }

    };
    messageList.setOutputMarkupId(true);
    messageListContainer.add(messageList);
    add(messageListContainer);

    //reply form
    StringModel stringModel = new StringModel();
    Form<StringModel> replyForm = new Form<StringModel>("replyForm", new Model<StringModel>(stringModel));

    //form feedback
    final Label formFeedback = new Label("formFeedback");
    formFeedback.setOutputMarkupPlaceholderTag(true);
    add(formFeedback);

    //reply field
    replyForm.add(new Label("replyLabel", new ResourceModel("message.reply")));
    final TextArea<StringModel> replyField = new TextArea<StringModel>("replyField",
            new PropertyModel<StringModel>(stringModel, "string"));
    replyField.setRequired(true);
    replyField.setOutputMarkupId(true);
    replyForm.add(replyField);

    //reply button
    IndicatingAjaxButton replyButton = new IndicatingAjaxButton("replyButton", replyForm) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {

            StringModel stringModel = (StringModel) form.getModelObject();
            String reply = stringModel.getString();

            //create a direct link to view this message thread
            //String messageLink = sakaiProxy.getDirectUrlToUserProfile(newMessage.getTo(), urlFor(MyMessageView.class, new PageParameters("thread=" + threadId)).toString());

            //send it, get Message back so we can add it to the list
            Message message = messagingLogic.replyToThread(threadId, reply, currentUserUuid);
            if (message != null) {
                //clear this field
                replyField.setModelObject(null);
                target.add(replyField);

                //create new item and add it to the list
                //do we need to register this with the listview?
                Component item = buildItem(message);
                target.prependJavaScript(String.format(
                        "var item=document.createElement('%s');item.id='%s';Wicket.$('%s').appendChild(item);",
                        "tr", item.getMarkupId(), messageListContainer.getMarkupId()));
                target.add(item);

                //repaint the list of messages in this thread
                //target.addComponent(messageListContainer);

                //resize
                target.appendJavaScript("setMainFrameHeight(window.name);");
            }

        }

        protected void onError(AjaxRequestTarget target, Form form) {

            //validate
            if (!replyField.isValid()) {
                formFeedback.setDefaultModel(new ResourceModel("error.message.required.body"));
            }
            formFeedback.add(new AttributeModifier("class", true, new Model<String>("alertMessage")));
            target.add(formFeedback);
        }
    };
    replyForm.add(replyButton);
    replyButton.setModel(new ResourceModel("button.message.send"));

    add(replyForm);

}

From source file:org.sakaiproject.profile2.tool.pages.panels.RequestedFriends.java

License:Educational Community License

public RequestedFriends(final String id, final String userUuid) {
    super(id);/*  www .  j av a 2 s. c om*/

    log.debug("RequestedFriends()");

    final String currentUserUuid = sakaiProxy.getCurrentUserId();

    //setup model to store the actions in the modal windows
    final FriendAction friendActionModel = new FriendAction();

    //get our list of friend requests as an IDataProvider
    RequestedFriendsDataProvider provider = new RequestedFriendsDataProvider(userUuid);

    //init number of requests
    numRequestedFriends = (int) provider.size();

    //model so we can update the number of requests
    IModel<Integer> numRequestedFriendsModel = new Model<Integer>() {
        private static final long serialVersionUID = 1L;

        public Integer getObject() {
            return numRequestedFriends;
        }
    };

    //heading
    final WebMarkupContainer requestedFriendsHeading = new WebMarkupContainer("requestedFriendsHeading");
    requestedFriendsHeading
            .add(new Label("requestedFriendsLabel", new ResourceModel("heading.friend.requests")));
    requestedFriendsHeading.add(new Label("requestedFriendsNumber", numRequestedFriendsModel));
    requestedFriendsHeading.setOutputMarkupId(true);
    add(requestedFriendsHeading);

    //container which wraps list
    final WebMarkupContainer requestedFriendsContainer = new WebMarkupContainer("requestedFriendsContainer");
    requestedFriendsContainer.setOutputMarkupId(true);

    //connection window
    final ModalWindow connectionWindow = new ModalWindow("connectionWindow");

    //search results
    DataView<Person> requestedFriendsDataView = new DataView<Person>("connections", provider) {
        private static final long serialVersionUID = 1L;

        protected void populateItem(final Item<Person> item) {

            Person person = (Person) item.getDefaultModelObject();
            final String personUuid = person.getUuid();

            //get name
            String displayName = person.getDisplayName();

            //get other objects
            ProfilePrivacy privacy = person.getPrivacy();
            ProfilePreferences prefs = person.getPreferences();

            //image wrapper, links to profile
            Link<String> friendItem = new Link<String>("connectionPhotoWrap", new Model<String>(personUuid)) {
                private static final long serialVersionUID = 1L;

                public void onClick() {
                    setResponsePage(new ViewProfile(getModelObject()));
                }
            };

            //image
            ProfileImage connectionPhoto = new ProfileImage("connectionPhoto", new Model<String>(personUuid));
            connectionPhoto.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
            friendItem.add(connectionPhoto);

            item.add(friendItem);

            //name and link to profile
            Link<String> profileLink = new Link<String>("connectionLink", new Model<String>(personUuid)) {
                private static final long serialVersionUID = 1L;

                public void onClick() {
                    setResponsePage(new ViewProfile(getModelObject()));
                }
            };
            profileLink.add(new Label("connectionName", displayName));
            item.add(profileLink);

            //status component
            ProfileStatusRenderer status = new ProfileStatusRenderer("connectionStatus", person,
                    "connection-status-msg", "connection-status-date");
            status.setOutputMarkupId(true);
            item.add(status);

            //CONFIRM FRIEND LINK AND WINDOW

            WebMarkupContainer c1 = new WebMarkupContainer("confirmConnectionContainer");
            c1.setOutputMarkupId(true);

            final AjaxLink<String> confirmConnectionLink = new AjaxLink<String>("confirmConnectionLink",
                    new Model<String>(personUuid)) {
                private static final long serialVersionUID = 1L;

                public void onClick(AjaxRequestTarget target) {

                    //get this item, and set content for modalwindow
                    String personUuid = getModelObject();
                    connectionWindow.setContent(new ConfirmFriend(connectionWindow.getContentId(),
                            connectionWindow, friendActionModel, userUuid, personUuid));

                    //modalwindow handler 
                    connectionWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
                        private static final long serialVersionUID = 1L;

                        public void onClose(AjaxRequestTarget target) {
                            if (friendActionModel.isConfirmed()) {

                                //decrement number of requests
                                numRequestedFriends--;

                                //remove friend item from display
                                target.appendJavaScript("$('#" + item.getMarkupId() + "').slideUp();");

                                //update label
                                target.add(requestedFriendsHeading);

                                //get parent panel and repaint ConfirmedFriends panel via helper method in MyFriends 
                                findParent(MyFriends.class).updateConfirmedFriends(target, userUuid);

                                //if none left, hide everything
                                if (numRequestedFriends == 0) {
                                    target.appendJavaScript(
                                            "$('#" + requestedFriendsHeading.getMarkupId() + "').fadeOut();");
                                    target.appendJavaScript(
                                            "$('#" + requestedFriendsContainer.getMarkupId() + "').fadeOut();");
                                }
                            }
                        }
                    });

                    connectionWindow.show(target);
                    target.appendJavaScript("fixWindowVertical();");
                }
            };
            //ContextImage confirmConnectionIcon = new ContextImage("confirmConnectionIcon",new Model<String>(ProfileConstants.ACCEPT_IMG));
            //confirmConnectionLink.add(confirmConnectionIcon);
            confirmConnectionLink
                    .add(new AttributeModifier("title", true, new ResourceModel("link.title.confirmfriend")));
            confirmConnectionLink.add(new AttributeModifier("alt", true, new StringResourceModel(
                    "accessibility.connection.confirm", null, new Object[] { displayName })));
            confirmConnectionLink
                    .add(new Label("confirmConnectionLabel", new ResourceModel("link.friend.confirm"))
                            .setOutputMarkupId(true));
            c1.add(confirmConnectionLink);
            item.add(c1);

            //IGNORE FRIEND LINK AND WINDOW

            WebMarkupContainer c2 = new WebMarkupContainer("ignoreConnectionContainer");
            c2.setOutputMarkupId(true);

            final AjaxLink<String> ignoreConnectionLink = new AjaxLink<String>("ignoreConnectionLink",
                    new Model<String>(personUuid)) {
                private static final long serialVersionUID = 1L;

                public void onClick(AjaxRequestTarget target) {

                    //get this item, and set content for modalwindow
                    String personUuid = getModelObject();
                    connectionWindow.setContent(new IgnoreFriend(connectionWindow.getContentId(),
                            connectionWindow, friendActionModel, userUuid, personUuid));

                    //modalwindow handler 
                    connectionWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
                        private static final long serialVersionUID = 1L;

                        public void onClose(AjaxRequestTarget target) {
                            if (friendActionModel.isIgnored()) {

                                //decrement number of requests
                                numRequestedFriends--;

                                //remove friend item from display
                                target.appendJavaScript("$('#" + item.getMarkupId() + "').slideUp();");

                                //update label
                                target.add(requestedFriendsHeading);

                                //if none left, hide everything
                                if (numRequestedFriends == 0) {
                                    target.appendJavaScript(
                                            "$('#" + requestedFriendsHeading.getMarkupId() + "').fadeOut();");
                                    target.appendJavaScript(
                                            "$('#" + requestedFriendsContainer.getMarkupId() + "').fadeOut();");
                                }
                            }
                        }
                    });

                    connectionWindow.show(target);
                    target.appendJavaScript("fixWindowVertical();");
                }
            };
            //ContextImage ignoreConnectionIcon = new ContextImage("ignoreConnectionIcon",new Model<String>(ProfileConstants.CANCEL_IMG));
            //ignoreConnectionLink.add(ignoreConnectionIcon);
            ignoreConnectionLink
                    .add(new AttributeModifier("title", true, new ResourceModel("link.title.ignorefriend")));
            ignoreConnectionLink.add(new AttributeModifier("alt", true, new StringResourceModel(
                    "accessibility.connection.ignore", null, new Object[] { displayName })));
            ignoreConnectionLink.add(new Label("ignoreConnectionLabel", new ResourceModel("link.friend.ignore"))
                    .setOutputMarkupId(true));
            c2.add(ignoreConnectionLink);
            item.add(c2);

            WebMarkupContainer c3 = new WebMarkupContainer("viewFriendsContainer");
            c3.setOutputMarkupId(true);

            final AjaxLink<String> viewFriendsLink = new AjaxLink<String>("viewFriendsLink") {
                private static final long serialVersionUID = 1L;

                public void onClick(AjaxRequestTarget target) {
                    // always ViewFriends because a user isn't connected to himself
                    setResponsePage(new ViewFriends(personUuid));
                }
            };
            final Label viewFriendsLabel = new Label("viewFriendsLabel",
                    new ResourceModel("link.view.friends"));
            viewFriendsLink.add(viewFriendsLabel);

            //hide if not allowed
            if (!privacyLogic.isActionAllowed(userUuid, currentUserUuid,
                    PrivacyType.PRIVACY_OPTION_MYFRIENDS)) {
                viewFriendsLink.setEnabled(false);
                c3.setVisible(false);
            }
            viewFriendsLink.setOutputMarkupId(true);
            c3.add(viewFriendsLink);
            item.add(c3);

            WebMarkupContainer c4 = new WebMarkupContainer("emailContainer");
            c4.setOutputMarkupId(true);

            ExternalLink emailLink = new ExternalLink("emailLink", "mailto:" + person.getProfile().getEmail(),
                    new ResourceModel("profile.email").getObject());

            c4.add(emailLink);

            // friend=false
            if (StringUtils.isBlank(person.getProfile().getEmail())
                    || false == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid,
                            PrivacyType.PRIVACY_OPTION_CONTACTINFO)) {

                c4.setVisible(false);
            }
            item.add(c4);

            WebMarkupContainer c5 = new WebMarkupContainer("websiteContainer");
            c5.setOutputMarkupId(true);

            // TODO home page, university profile URL or academic/research URL (see PRFL-35)
            ExternalLink websiteLink = new ExternalLink("websiteLink", person.getProfile().getHomepage(),
                    new ResourceModel("profile.homepage").getObject()).setPopupSettings(new PopupSettings());

            c5.add(websiteLink);

            // friend=false
            if (StringUtils.isBlank(person.getProfile().getHomepage())
                    || false == privacyLogic.isActionAllowed(person.getUuid(), currentUserUuid,
                            PrivacyType.PRIVACY_OPTION_CONTACTINFO)) {

                c5.setVisible(false);
            }
            item.add(c5);

            // not a friend yet, so friend=false
            if (true == privacyLogic.isActionAllowed(person.getUuid(), sakaiProxy.getCurrentUserId(),
                    PrivacyType.PRIVACY_OPTION_BASICINFO)) {

                item.add(new Label("connectionSummary", StringUtils
                        .abbreviate(ProfileUtils.stripHtml(person.getProfile().getPersonalSummary()), 200)));
            } else {
                item.add(new Label("connectionSummary", ""));
            }

            item.setOutputMarkupId(true);
        }

    };
    requestedFriendsDataView.setOutputMarkupId(true);
    requestedFriendsContainer.add(requestedFriendsDataView);

    //add results container
    add(requestedFriendsContainer);

    //add window
    add(connectionWindow);

    //initially, if no requests, hide everything
    if (numRequestedFriends == 0) {
        this.setVisible(false);
    }

}

From source file:org.sakaiproject.profile2.tool.pages.panels.WallItemPanel.java

License:Educational Community License

/**
 * Creates a new instance of <code>WallItemPanel</code>.
 * /*from w  ww  .java 2 s .c om*/
 * @param id
 * @param userUuid the id of the user whose wall this item panel is on.
 * @param wallItem
 * @param myWallPanel a reference to my wall panel for repainting.
 */
public WallItemPanel(String id, final String userUuid, final WallItem wallItem, final MyWallPanel myWallPanel) {
    super(id);

    setOutputMarkupId(true);

    // image wrapper, links to profile
    Link<String> wallItemPhoto = new Link<String>("wallItemPhotoWrap",
            new Model<String>(wallItem.getCreatorUuid())) {

        private static final long serialVersionUID = 1L;

        public void onClick() {
            setResponsePage(new ViewProfile(getModelObject()));
        }
    };

    // image
    ProfileImage photo = new ProfileImage("wallItemPhoto", new Model<String>(wallItem.getCreatorUuid()));
    photo.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
    wallItemPhoto.add(photo);

    add(wallItemPhoto);

    // name and link to profile
    Link<String> wallItemProfileLink = new Link<String>("wallItemProfileLink",
            new Model<String>(wallItem.getCreatorUuid())) {

        private static final long serialVersionUID = 1L;

        public void onClick() {
            setResponsePage(new ViewProfile(getModelObject()));
        }

    };
    wallItemProfileLink
            .add(new Label("wallItemName", sakaiProxy.getUserDisplayName(wallItem.getCreatorUuid())));
    add(wallItemProfileLink);

    add(new Label("wallItemDate",
            ProfileUtils.convertDateToString(wallItem.getDate(), ProfileConstants.WALL_DISPLAY_DATE_FORMAT)));

    // ACTIONS

    final ModalWindow wallItemActionWindow = new ModalWindow("wallItemActionWindow");
    add(wallItemActionWindow);

    final WallAction wallAction = new WallAction();
    // delete link
    final AjaxLink<WallItem> removeItemLink = new AjaxLink<WallItem>("removeWallItemLink",
            new Model<WallItem>(wallItem)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

            wallItemActionWindow.setContent(new RemoveWallItem(wallItemActionWindow.getContentId(),
                    wallItemActionWindow, wallAction, userUuid, this.getModelObject()));

            wallItemActionWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClose(AjaxRequestTarget target) {
                    if (wallAction.isItemRemoved()) {
                        myWallPanel.replaceSelf(target, userUuid);
                    }
                }
            });

            wallItemActionWindow.show(target);
            target.appendJavaScript("fixWindowVertical();");
        }
    };

    removeItemLink.add(new Label("removeWallItemLabel", new ResourceModel("link.wall.item.remove")));
    removeItemLink.add(new AttributeModifier("title", true, new ResourceModel("link.title.wall.remove")));

    // not visible when viewing another user's wall
    if (false == sakaiProxy.getCurrentUserId().equals(userUuid)) {
        removeItemLink.setVisible(false);
    }

    add(removeItemLink);

    // panel for posting a comment that slides up/down
    final WallItemPostCommentPanel postCommentPanel = new WallItemPostCommentPanel("wallItemPostCommentPanel",
            userUuid, wallItem, this, myWallPanel);
    postCommentPanel.setOutputMarkupPlaceholderTag(true);
    postCommentPanel.setVisible(false);
    add(postCommentPanel);

    final AjaxLink<WallItem> commentItemLink = new AjaxLink<WallItem>("commentWallItemLink",
            new Model<WallItem>(wallItem)) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {

            postCommentPanel.setVisible(true);
            target.add(postCommentPanel);
            target.appendJavaScript("$('#" + postCommentPanel.getMarkupId() + "').slideDown();");
        }
    };

    commentItemLink.add(new Label("commentWallItemLabel", new ResourceModel("link.wall.item.comment")));
    commentItemLink.add(new AttributeModifier("title", true, new StringResourceModel("link.title.wall.comment",
            null, new Object[] { sakaiProxy.getUserDisplayName(wallItem.getCreatorUuid()) })));

    add(commentItemLink);

    if (ProfileConstants.WALL_ITEM_TYPE_EVENT == wallItem.getType()) {
        add(new Label("wallItemText", new ResourceModel(wallItem.getText())));

    } else if (ProfileConstants.WALL_ITEM_TYPE_POST == wallItem.getType()) {
        add(new Label("wallItemText", ProfileUtils.processHtml(wallItem.getText()))
                .setEscapeModelStrings(false));

    } else if (ProfileConstants.WALL_ITEM_TYPE_STATUS == wallItem.getType()) {
        add(new Label("wallItemText", wallItem.getText()));

    }

    // COMMENTS

    ListView<WallItemComment> wallItemCommentsListView = new ListView<WallItemComment>("wallItemComments",
            wallItem.getComments()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<WallItemComment> item) {

            WallItemComment comment = (WallItemComment) item.getDefaultModelObject();

            item.add(new WallItemCommentPanel("wallItemCommentPanel", comment));
        }

    };
    wallItemCommentsListView.setOutputMarkupId(true);
    add(wallItemCommentsListView);

}

From source file:org.sakaiproject.profile2.tool.pages.ViewPictures.java

License:Educational Community License

private void populateGallery(Form galleryForm, final String userUuid) {

    IDataProvider dataProvider = new GalleryImageDataProvider(userUuid);

    long numImages = dataProvider.size();

    gridView = new GridView("rows", dataProvider) {

        private static final long serialVersionUID = 1L;

        @Override//from  w  ww.  java  2 s .co  m
        protected void populateItem(Item item) {

            final GalleryImage image = (GalleryImage) item.getModelObject();

            final GalleryImageRenderer galleryImageThumbnailRenderer = new GalleryImageRenderer(
                    "galleryImageThumbnailRenderer", image.getThumbnailResource());

            AjaxLink galleryImageLink = new AjaxLink("galleryItem") {

                public void onClick(AjaxRequestTarget target) {
                    setResponsePage(new ViewPicture(image));
                }

            };
            galleryImageLink.add(galleryImageThumbnailRenderer);

            item.add(galleryImageLink);
        }

        @Override
        protected void populateEmptyItem(Item item) {

            Link galleryImageLink = new Link("galleryItem") {
                @Override
                public void onClick() {

                }
            };

            galleryImageLink.add(new Label("galleryImageThumbnailRenderer"));
            item.add(galleryImageLink);
        }
    };

    gridView.setRows(3);
    gridView.setColumns(4);

    galleryForm.add(gridView);

    //pager
    if (numImages == 0) {
        galleryForm.add(new PagingNavigator("navigator", gridView).setVisible(false));
    } else if (numImages <= ProfileConstants.MAX_GALLERY_IMAGES_PER_PAGE) {
        galleryForm.add(new PagingNavigator("navigator", gridView).setVisible(false));
    } else {
        galleryForm.add(new PagingNavigator("navigator", gridView));
    }
}

From source file:org.sakaiproject.profile2.tool.pages.ViewProfile.java

License:Educational Community License

public ViewProfile(final String userUuid, final String tab) {

    log.debug("ViewProfile()");

    //setup model to store the actions in the modal windows
    final FriendAction friendActionModel = new FriendAction();

    //get current user info
    User currentUser = sakaiProxy.getUserQuietly(sakaiProxy.getCurrentUserId());
    final String currentUserId = currentUser.getId();
    String currentUserType = currentUser.getType();

    //double check, if somehow got to own ViewPage, redirect to MyProfile instead
    if (userUuid.equals(currentUserId)) {
        log.warn("ViewProfile: user " + userUuid + " accessed ViewProfile for self. Redirecting...");
        throw new RestartResponseException(new MyProfile());
    }//from   w w w.  j  a  v a 2 s .  c  om

    //check if super user, to grant editing rights to another user's profile
    if (sakaiProxy.isSuperUser()) {
        log.warn("ViewProfile: superUser " + currentUserId + " accessed ViewProfile for " + userUuid
                + ". Redirecting to allow edit.");
        throw new RestartResponseException(new MyProfile(userUuid));
    }

    //post view event
    sakaiProxy.postEvent(ProfileConstants.EVENT_PROFILE_VIEW_OTHER, "/profile/" + userUuid, false);

    /* DEPRECATED via PRFL-24 when privacy was relaxed
    if(!isProfileAllowed) {
       throw new ProfileIllegalAccessException("User: " + currentUserId + " is not allowed to view profile for: " + userUuid);
    }
    */

    //get some values from User
    User user = sakaiProxy.getUserQuietly(userUuid);
    String userDisplayName = user.getDisplayName();
    String userType = user.getType();

    //init
    final boolean friend;
    boolean friendRequestToThisPerson = false;
    boolean friendRequestFromThisPerson = false;

    //friend?
    friend = connectionsLogic.isUserXFriendOfUserY(userUuid, currentUserId);

    //if not friend, has a friend request already been made to this person?
    if (!friend) {
        friendRequestToThisPerson = connectionsLogic.isFriendRequestPending(currentUserId, userUuid);
    }

    //if not friend and no friend request to this person, has a friend request been made from this person to the current user?
    if (!friend && !friendRequestToThisPerson) {
        friendRequestFromThisPerson = connectionsLogic.isFriendRequestPending(userUuid, currentUserId);
    }

    //privacy checks
    final ProfilePrivacy privacy = privacyLogic.getPrivacyRecordForUser(userUuid);

    boolean isFriendsListVisible = privacyLogic.isActionAllowed(userUuid, currentUserId,
            PrivacyType.PRIVACY_OPTION_MYFRIENDS);
    boolean isKudosVisible = privacyLogic.isActionAllowed(userUuid, currentUserId,
            PrivacyType.PRIVACY_OPTION_MYKUDOS);
    boolean isGalleryVisible = privacyLogic.isActionAllowed(userUuid, currentUserId,
            PrivacyType.PRIVACY_OPTION_MYPICTURES);
    boolean isConnectionAllowed = sakaiProxy.isConnectionAllowedBetweenUserTypes(currentUserType, userType);
    boolean isOnlineStatusVisible = privacyLogic.isActionAllowed(userUuid, currentUserId,
            PrivacyType.PRIVACY_OPTION_ONLINESTATUS);

    final ProfilePreferences prefs = preferencesLogic.getPreferencesRecordForUser(userUuid);

    /* IMAGE */
    add(new ProfileImage("photo", new Model<String>(userUuid)));

    /* NAME */
    Label profileName = new Label("profileName", userDisplayName);
    add(profileName);

    /* ONLINE PRESENCE INDICATOR */
    if (sakaiProxy.isOnlineStatusEnabledGlobally() && prefs.isShowOnlineStatus() && isOnlineStatusVisible) {
        add(new OnlinePresenceIndicator("online", userUuid));
    } else {
        add(new EmptyPanel("online"));
    }

    /*STATUS PANEL */
    if (sakaiProxy.isProfileStatusEnabled()) {
        add(new ProfileStatusRenderer("status", userUuid, privacy, null, "tiny"));
    } else {
        add(new EmptyPanel("status"));
    }

    /* TABS */
    List<ITab> tabs = new ArrayList<ITab>();

    AjaxTabbedPanel tabbedPanel = new AjaxTabbedPanel("viewProfileTabs", tabs) {

        private static final long serialVersionUID = 1L;

        // overridden so we can add tooltips to tabs
        @Override
        protected WebMarkupContainer newLink(String linkId, final int index) {
            WebMarkupContainer link = super.newLink(linkId, index);

            if (ProfileConstants.TAB_INDEX_PROFILE == index) {
                link.add(new AttributeModifier("title", true, new ResourceModel("link.tab.profile.tooltip")));

            } else if (ProfileConstants.TAB_INDEX_WALL == index) {
                link.add(new AttributeModifier("title", true, new ResourceModel("link.tab.wall.tooltip")));
            }
            return link;
        }
    };

    CookieUtils utils = new CookieUtils();
    Cookie tabCookie = utils.getCookie(ProfileConstants.TAB_COOKIE);

    if (sakaiProxy.isProfileFieldsEnabled()) {
        tabs.add(new AbstractTab(new ResourceModel("link.tab.profile")) {

            private static final long serialVersionUID = 1L;

            @Override
            public Panel getPanel(String panelId) {

                setTabCookie(ProfileConstants.TAB_INDEX_PROFILE);
                return new ViewProfilePanel(panelId, userUuid, currentUserId, privacy, friend);
            }
        });
    }

    if (sakaiProxy.isWallEnabledGlobally()) {

        tabs.add(new AbstractTab(new ResourceModel("link.tab.wall")) {

            private static final long serialVersionUID = 1L;

            @Override
            public Panel getPanel(String panelId) {

                setTabCookie(ProfileConstants.TAB_INDEX_WALL);
                return new ViewWallPanel(panelId, userUuid);
            }
        });

        if (sakaiProxy.isWallDefaultProfilePage() && null == tabCookie) {

            tabbedPanel.setSelectedTab(ProfileConstants.TAB_INDEX_WALL);
        }
    }

    if (null != tab) {
        tabbedPanel.setSelectedTab(Integer.parseInt(tab));
    } else if (null != tabCookie) {
        try {
            tabbedPanel.setSelectedTab(Integer.parseInt(tabCookie.getValue()));
        } catch (IndexOutOfBoundsException e) {
            //do nothing. This will be thrown if the cookie contains a value > the number of tabs but thats ok.
        }
    }

    add(tabbedPanel);

    /* SIDELINKS */
    WebMarkupContainer sideLinks = new WebMarkupContainer("sideLinks");
    int visibleSideLinksCount = 0;

    WebMarkupContainer addFriendContainer = new WebMarkupContainer("addFriendContainer");

    //ADD FRIEND MODAL WINDOW
    final ModalWindow addFriendWindow = new ModalWindow("addFriendWindow");

    //FRIEND LINK/STATUS
    final AjaxLink<Void> addFriendLink = new AjaxLink<Void>("addFriendLink") {
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            addFriendWindow.show(target);
        }
    };

    final Label addFriendLabel = new Label("addFriendLabel");
    addFriendLink.add(addFriendLabel);

    addFriendContainer.add(addFriendLink);

    //setup link/label and windows
    if (friend) {
        addFriendLabel.setDefaultModel(new ResourceModel("text.friend.confirmed"));
        addFriendLink.add(new AttributeModifier("class", true,
                new Model<String>("instruction icon connection-confirmed")));
        addFriendLink.setEnabled(false);
    } else if (friendRequestToThisPerson) {
        addFriendLabel.setDefaultModel(new ResourceModel("text.friend.requested"));
        addFriendLink.add(
                new AttributeModifier("class", true, new Model<String>("instruction icon connection-request")));
        addFriendLink.setEnabled(false);
    } else if (friendRequestFromThisPerson) {
        //TODO (confirm pending friend request link)
        //could be done by setting the content off the addFriendWindow.
        //will need to rename some links to make more generic and set the onClick and setContent in here for link and window
        addFriendLabel.setDefaultModel(new ResourceModel("text.friend.pending"));
        addFriendLink.add(
                new AttributeModifier("class", true, new Model<String>("instruction icon connection-request")));
        addFriendLink.setEnabled(false);
    } else {
        addFriendLabel.setDefaultModel(
                new StringResourceModel("link.friend.add.name", null, new Object[] { user.getFirstName() }));
        addFriendWindow.setContent(new AddFriend(addFriendWindow.getContentId(), addFriendWindow,
                friendActionModel, currentUserId, userUuid));
    }
    sideLinks.add(addFriendContainer);

    //ADD FRIEND MODAL WINDOW HANDLER 
    addFriendWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        private static final long serialVersionUID = 1L;

        public void onClose(AjaxRequestTarget target) {
            if (friendActionModel.isRequested()) {
                //friend was successfully requested, update label and link
                addFriendLabel.setDefaultModel(new ResourceModel("text.friend.requested"));
                addFriendLink.add(new AttributeModifier("class", true,
                        new Model<String>("instruction icon connection-request")));
                addFriendLink.setEnabled(false);
                target.add(addFriendLink);
            }
        }
    });
    addFriendWindow.setVisible(sakaiProxy.isConnectionsEnabledGlobally());
    add(addFriendWindow);

    //hide connection link if not allowed
    if (!isConnectionAllowed && !sakaiProxy.isConnectionsEnabledGlobally()) {
        addFriendContainer.setVisible(false);
    } else {
        visibleSideLinksCount++;
    }

    //hide entire list if no links to show
    if (visibleSideLinksCount == 0) {
        sideLinks.setVisible(false);
    }

    add(sideLinks);

    /* KUDOS PANEL */
    if (sakaiProxy.isMyKudosEnabledGlobally() && isKudosVisible) {
        add(new AjaxLazyLoadPanel("myKudos") {
            private static final long serialVersionUID = 1L;

            @Override
            public Component getLazyLoadComponent(String markupId) {
                if (prefs.isShowKudos()) {

                    int score = kudosLogic.getKudos(userUuid);
                    if (score > 0) {
                        return new KudosPanel(markupId, userUuid, currentUserId, score);
                    }
                }
                return new EmptyPanel(markupId);
            }
        });
    } else {
        add(new EmptyPanel("myKudos").setVisible(false));
    }

    /* FRIENDS FEED PANEL */
    if (sakaiProxy.isConnectionsEnabledGlobally() && isFriendsListVisible) {
        add(new AjaxLazyLoadPanel("friendsFeed") {
            private static final long serialVersionUID = 1L;

            @Override
            public Component getLazyLoadComponent(String markupId) {
                return new FriendsFeed(markupId, userUuid, currentUserId);
            }

        });
    } else {
        add(new EmptyPanel("friendsFeed").setVisible(false));
    }

    /* GALLERY FEED PANEL */
    if (sakaiProxy.isProfileGalleryEnabledGlobally() && isGalleryVisible && prefs.isShowGalleryFeed()) {
        add(new AjaxLazyLoadPanel("galleryFeed") {
            private static final long serialVersionUID = 1L;

            @Override
            public Component getLazyLoadComponent(String markupId) {
                return new GalleryFeed(markupId, userUuid, currentUserId).setOutputMarkupId(true);
            }
        });
    } else {
        add(new EmptyPanel("galleryFeed").setVisible(false));
    }
}

From source file:org.sakaiproject.wicket.markup.html.link.AjaxIconLink.java

License:Educational Community License

private AjaxLink newLink(String baseId, final ResourceReference icon) {
    AjaxLink actionLink = new AjaxLink(baseId) {

        private static final long serialVersionUID = 1L;

        @Override//from  w  ww . j  av a2 s  . c o m
        public void onClick(AjaxRequestTarget target) {
            AjaxIconLink.this.onClick(target);
        }

    };

    // Add the passed icon 
    if (icon != null) {
        String iconId = new StringBuilder().append(baseId).append("Icon").toString();
        Image iconImage = new Image(iconId) {
            private static final long serialVersionUID = 1L;

            protected ResourceReference getImageResourceReference() {
                return icon;
            }
        };

        actionLink.add(iconImage);
    }

    return actionLink;
}

From source file:org.syncope.console.pages.BasePage.java

License:Apache License

private void pageSetup() {
    ((SyncopeApplication) getApplication()).setupNavigationPane(this, xmlRolesReader, true, version);

    feedbackPanel = new FeedbackPanel("feedback");
    feedbackPanel.setOutputMarkupId(true);
    add(feedbackPanel);/*  ww w. j  av  a 2 s .  c om*/

    final String kind = getClass().getSimpleName().toLowerCase();
    final BookmarkablePageLink kindLink = (BookmarkablePageLink) get(kind);
    if (kindLink != null) {
        kindLink.add(new Behavior() {

            private static final long serialVersionUID = 1469628524240283489L;

            @Override
            public void onComponentTag(final Component component, final ComponentTag tag) {

                tag.put("class", kind);
            }
        });

        Component kindIcon = kindLink.get(0);
        if (kindIcon != null) {
            kindIcon.add(new Behavior() {

                private static final long serialVersionUID = 1469628524240283489L;

                @Override
                public void onComponentTag(final Component component, final ComponentTag tag) {

                    tag.put("src",
                            "../.." + SyncopeApplication.IMG_PREFIX + kind + SyncopeApplication.IMG_SUFFIX);
                }
            });
        }
    }

    // Modal window for editing user profile
    final ModalWindow editProfileModalWin = new ModalWindow("editProfileModal");
    editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editProfileModalWin.setInitialHeight(EDIT_PROFILE_WIN_HEIGHT);
    editProfileModalWin.setInitialWidth(EDIT_PROFILE_WIN_WIDTH);
    editProfileModalWin.setCookieName("edit-profile-modal");
    add(editProfileModalWin);

    add(new Label("username", SyncopeSession.get().getUserId()));

    Fragment editProfileFrag;
    if ("admin".equals(SyncopeSession.get().getUserId())) {
        editProfileFrag = new Fragment("editProfile", "adminEmptyFrag", this);
    } else {
        final UserTO userTO = SyncopeSession.get().isAuthenticated() ? profileRestClient.readProfile()
                : new UserTO();

        editProfileFrag = new Fragment("editProfile", "editProfileFrag", this);

        AjaxLink editProfileLink = new IndicatingAjaxLink("link") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {

                    @Override
                    public Page createPage() {
                        return new UserRequestModalPage(BasePage.this.getPageReference(), editProfileModalWin,
                                userTO);
                    }
                });

                editProfileModalWin.show(target);
            }
        };
        editProfileLink.add(new Label("linkTitle", getString("editProfile")));

        Panel panel = new LinkPanel("editProfile", new ResourceModel("editProfile"));
        panel.add(editProfileLink);
        editProfileFrag.add(panel);
    }
    add(editProfileFrag);
}

From source file:org.syncope.console.pages.Login.java

License:Apache License

public Login(final PageParameters parameters) {
    super(parameters);

    form = new Form("login");

    userIdField = new TextField("userId", new Model());
    userIdField.setMarkupId("userId");
    form.add(userIdField);/*from   www  . ja  va2s.  co  m*/

    passwordField = new PasswordTextField("password", new Model());
    passwordField.setMarkupId("password");
    form.add(passwordField);

    languageSelect = new LocaleDropDown("language",
            Arrays.asList(new Locale[] { Locale.ENGLISH, Locale.ITALIAN }));

    form.add(languageSelect);

    Button submitButton = new Button("submit", new Model(getString("submit"))) {

        private static final long serialVersionUID = 429178684321093953L;

        @Override
        public void onSubmit() {
            String[] entitlements = authenticate(userIdField.getRawInput(), passwordField.getRawInput());

            if (entitlements == null) {
                error(getString("login-error"));
            } else {
                SyncopeSession.get().setUserId(userIdField.getRawInput());
                SyncopeSession.get().setEntitlements(entitlements);
                SyncopeSession.get().setCoreVersion(getCoreVersion());

                setResponsePage(WelcomePage.class, parameters);
            }
        }
    };

    submitButton.setDefaultFormProcessing(false);
    form.add(submitButton);

    add(form);
    add(new FeedbackPanel("feedback"));

    // Modal window for self registration
    final ModalWindow editProfileModalWin = new ModalWindow("selfRegModal");
    editProfileModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editProfileModalWin.setInitialHeight(SELF_REG_WIN_HEIGHT);
    editProfileModalWin.setInitialWidth(SELF_REG_WIN_WIDTH);
    editProfileModalWin.setCookieName("self-reg-modal");
    add(editProfileModalWin);

    Fragment selfRegFrag;
    if (isSelfRegistrationAllowed()) {
        selfRegFrag = new Fragment("selfRegistration", "selfRegAllowed", this);

        AjaxLink selfRegLink = new IndicatingAjaxLink("link") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {
                editProfileModalWin.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return new UserRequestModalPage(Login.this.getPageReference(), editProfileModalWin,
                                new UserTO());
                    }
                });

                editProfileModalWin.show(target);
            }
        };
        selfRegLink.add(new Label("linkTitle", getString("selfRegistration")));

        Panel panel = new LinkPanel("selfRegistration", new ResourceModel("selfRegistration"));
        panel.add(selfRegLink);
        selfRegFrag.add(panel);
    } else {
        selfRegFrag = new Fragment("selfRegistration", "selfRegNotAllowed", this);
    }
    add(selfRegFrag);
}

From source file:org.syncope.console.pages.panels.ResultSetPanel.java

License:Apache License

public <T extends AbstractAttributableTO> ResultSetPanel(final String id, final boolean filtered,
        final NodeCond searchCond, final PageReference callerRef) {
    super(id);/*from  w w w . j a va2s. co m*/

    setOutputMarkupId(true);

    page = (BasePage) callerRef.getPage();

    this.filtered = filtered;
    this.filter = searchCond;
    this.feedbackPanel = page.getFeedbackPanel();

    editmodal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    editmodal.setInitialHeight(EDIT_MODAL_WIN_HEIGHT);
    editmodal.setInitialWidth(EDIT_MODAL_WIN_WIDTH);
    editmodal.setCookieName("edit-modal");
    add(editmodal);

    displaymodal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    displaymodal.setInitialHeight(DISPLAYATTRS_MODAL_WIN_HEIGHT);
    displaymodal.setInitialWidth(DISPLAYATTRS_MODAL_WIN_WIDTH);
    displaymodal.setCookieName("display-modal");
    add(displaymodal);

    statusmodal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    statusmodal.setInitialHeight(STATUS_MODAL_WIN_HEIGHT);
    statusmodal.setInitialWidth(STATUS_MODAL_WIN_WIDTH);
    statusmodal.setCookieName("status-modal");
    add(statusmodal);

    // Container for user search result
    container = new WebMarkupContainer("container");
    container.setOutputMarkupId(true);
    add(container);

    // ---------------------------
    // Result table initialization
    // ---------------------------
    // preferences and container must be not null to use it ...
    updateResultTable(false);
    // ---------------------------

    // ---------------------------
    // Link to select schemas/columns to be shown
    // ---------------------------
    AjaxLink displayAttrsLink = new IndicatingAjaxLink("displayAttrsLink") {

        private static final long serialVersionUID = -7978723352517770644L;

        @Override
        public void onClick(final AjaxRequestTarget target) {

            displaymodal.setPageCreator(new ModalWindow.PageCreator() {

                private static final long serialVersionUID = -7834632442532690940L;

                @Override
                public Page createPage() {
                    return new DisplayAttributesModalPage(page.getPageReference(), displaymodal);
                }
            });

            displaymodal.show(target);
        }
    };

    // Add class to specify relative position of the link.
    // Position depends on result pages number.
    displayAttrsLink.add(new Behavior() {

        private static final long serialVersionUID = 1469628524240283489L;

        @Override
        public void onComponentTag(final Component component, final ComponentTag tag) {

            if (resultTable.getRowCount() > rows) {
                tag.remove("class");
                tag.put("class", "settingsPosMultiPage");
            } else {
                tag.remove("class");
                tag.put("class", "settingsPos");
            }
        }
    });

    MetaDataRoleAuthorizationStrategy.authorize(displayAttrsLink, ENABLE,
            xmlRolesReader.getAllAllowedRoles("Users", "changeView"));

    container.add(displayAttrsLink);
    // ---------------------------

    // ---------------------------
    // Rows-per-page selector
    // ---------------------------
    final Form paginatorForm = new Form("paginator");
    container.add(paginatorForm);

    final DropDownChoice<Integer> rowsChooser = new DropDownChoice<Integer>("rowsChooser",
            new PropertyModel(this, "rows"), preferences.getPaginatorChoices());

    rowsChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            preferences.set(getRequest(), getResponse(), Constants.PREF_USERS_PAGINATOR_ROWS,
                    String.valueOf(rows));

            final EventDataWrapper data = new EventDataWrapper();
            data.setTarget(target);

            send(getParent(), Broadcast.BREADTH, data);
        }
    });
    paginatorForm.add(rowsChooser);
    // ---------------------------

    setWindowClosedReloadCallback(statusmodal);
    setWindowClosedReloadCallback(editmodal);
    setWindowClosedReloadCallback(displaymodal);
}