Example usage for org.apache.wicket.markup.html.form Form setOutputMarkupId

List of usage examples for org.apache.wicket.markup.html.form Form setOutputMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form Form setOutputMarkupId.

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

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

License:Educational Community License

public MyInterestsEdit(final String id, final UserProfile userProfile) {
    super(id);//from   ww w .  ja v  a  2 s  .  c  o m

    log.debug("MyInterestsEdit()");

    //this panel
    final Component thisPanel = this;

    //get userId
    final String userId = userProfile.getUserUuid();

    //heading
    add(new Label("heading", new ResourceModel("heading.interests.edit")));

    //setup form      
    Form form = new Form("form", new Model(userProfile));
    form.setOutputMarkupId(true);

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

    //add warning message if superUser and not editing own profile
    Label editWarning = new Label("editWarning");
    editWarning.setVisible(false);
    if (sakaiProxy.isSuperUserAndProxiedToUser(userId)) {
        editWarning.setDefaultModel(new StringResourceModel("text.edit.other.warning", null,
                new Object[] { userProfile.getDisplayName() }));
        editWarning.setEscapeModelStrings(false);
        editWarning.setVisible(true);
    }
    form.add(editWarning);

    //We don't need to get the info from userProfile, we load it into the form with a property model
    //just make sure that the form element id's match those in the model

    //favourite books
    WebMarkupContainer booksContainer = new WebMarkupContainer("booksContainer");
    booksContainer.add(new Label("booksLabel", new ResourceModel("profile.favourite.books")));
    TextArea favouriteBooks = new TextArea("favouriteBooks", new PropertyModel(userProfile, "favouriteBooks"));
    favouriteBooks.setMarkupId("favouritebooksinput");
    favouriteBooks.setOutputMarkupId(true);
    booksContainer.add(favouriteBooks);
    form.add(booksContainer);

    //favourite tv shows
    WebMarkupContainer tvContainer = new WebMarkupContainer("tvContainer");
    tvContainer.add(new Label("tvLabel", new ResourceModel("profile.favourite.tv")));
    TextArea favouriteTvShows = new TextArea("favouriteTvShows",
            new PropertyModel(userProfile, "favouriteTvShows"));
    favouriteTvShows.setMarkupId("favouritetvinput");
    favouriteTvShows.setOutputMarkupId(true);
    tvContainer.add(favouriteTvShows);
    form.add(tvContainer);

    //favourite movies
    WebMarkupContainer moviesContainer = new WebMarkupContainer("moviesContainer");
    moviesContainer.add(new Label("moviesLabel", new ResourceModel("profile.favourite.movies")));
    TextArea favouriteMovies = new TextArea("favouriteMovies",
            new PropertyModel(userProfile, "favouriteMovies"));
    favouriteMovies.setMarkupId("favouritemoviesinput");
    favouriteMovies.setOutputMarkupId(true);
    moviesContainer.add(favouriteMovies);
    form.add(moviesContainer);

    //favourite quotes
    WebMarkupContainer quotesContainer = new WebMarkupContainer("quotesContainer");
    quotesContainer.add(new Label("quotesLabel", new ResourceModel("profile.favourite.quotes")));
    TextArea favouriteQuotes = new TextArea("favouriteQuotes",
            new PropertyModel(userProfile, "favouriteQuotes"));
    favouriteQuotes.setMarkupId("favouritequotesinput");
    favouriteQuotes.setOutputMarkupId(true);
    quotesContainer.add(favouriteQuotes);
    form.add(quotesContainer);

    //submit button
    AjaxFallbackButton submitButton = new AjaxFallbackButton("submit", new ResourceModel("button.save.changes"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            //save() form, show message, then load display panel
            if (save(form)) {

                //post update event
                sakaiProxy.postEvent(ProfileConstants.EVENT_PROFILE_INTERESTS_UPDATE, "/profile/" + userId,
                        true);

                //post to wall if enabled
                if (true == sakaiProxy.isWallEnabledGlobally()
                        && false == sakaiProxy.isSuperUserAndProxiedToUser(userId)) {
                    wallLogic.addNewEventToWall(ProfileConstants.EVENT_PROFILE_INTERESTS_UPDATE,
                            sakaiProxy.getCurrentUserId());
                }

                //repaint panel
                Component newPanel = new MyInterestsDisplay(id, userProfile);
                newPanel.setOutputMarkupId(true);
                thisPanel.replaceWith(newPanel);
                if (target != null) {
                    target.add(newPanel);
                    //resize iframe
                    target.appendJavaScript("setMainFrameHeight(window.name);");
                }

            } else {
                //String js = "alert('Failed to save information. Contact your system administrator.');";
                //target.prependJavascript(js);

                formFeedback.setDefaultModel(new ResourceModel("error.profile.save.interests.failed"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("save-failed-error")));
                target.add(formFeedback);
            }
        }

        //@Override
        //protected IAjaxCallDecorator getAjaxCallDecorator() {
        //   return CKEditorTextArea.getAjaxCallDecoratedToUpdateElementForAllEditorsOnPage();
        //}
    };
    form.add(submitButton);

    //cancel button
    AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            Component newPanel = new MyInterestsDisplay(id, userProfile);
            newPanel.setOutputMarkupId(true);
            thisPanel.replaceWith(newPanel);
            if (target != null) {
                target.add(newPanel);
                //resize iframe
                target.appendJavaScript("setMainFrameHeight(window.name);");
                //need a scrollTo action here, to scroll down the page to the section
            }

        }
    };
    cancelButton.setDefaultFormProcessing(false);
    form.add(cancelButton);

    //feedback stuff - make this a class and insance it with diff params
    //WebMarkupContainer formFeedback = new WebMarkupContainer("formFeedback");
    //formFeedback.add(new Label("feedbackMsg", "some message"));
    //formFeedback.add(new AjaxIndicator("feedbackImg"));
    //form.add(formFeedback);

    //add form to page
    add(form);

}

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

License:Educational Community License

public MySocialNetworkingEdit(final String id, final UserProfile userProfile) {
    super(id);/* www .  j av  a2 s .  c o  m*/

    log.debug("MySocialNetworkingEdit()");

    // heading
    add(new Label("heading", new ResourceModel("heading.social.edit")));

    // setup form
    Form form = new Form("form", new Model(userProfile));
    form.setOutputMarkupId(true);

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

    // add warning message if superUser and not editing own profile
    Label editWarning = new Label("editWarning");
    editWarning.setVisible(false);
    if (sakaiProxy.isSuperUserAndProxiedToUser(userProfile.getUserUuid())) {
        editWarning.setDefaultModel(new StringResourceModel("text.edit.other.warning", null,
                new Object[] { userProfile.getDisplayName() }));
        editWarning.setEscapeModelStrings(false);
        editWarning.setVisible(true);
    }
    form.add(editWarning);

    //facebook
    WebMarkupContainer facebookContainer = new WebMarkupContainer("facebookContainer");
    facebookContainer
            .add(new Label("facebookLabel", new ResourceModel("profile.socialnetworking.facebook.edit")));
    final TextField<String> facebookUrl = new TextField<String>("facebookUrl",
            new PropertyModel<String>(userProfile, "socialInfo.facebookUrl")) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void convertInput() {
            validateUrl(this);
        }
    };
    facebookUrl.setMarkupId("facebookurlinput");
    facebookUrl.setOutputMarkupId(true);
    facebookUrl.add(new UrlValidator());
    facebookContainer.add(facebookUrl);
    facebookContainer.add(new IconWithClueTip("facebookToolTip", ProfileConstants.INFO_IMAGE,
            new ResourceModel("text.profile.facebook.tooltip")));

    //feedback
    final FeedbackLabel facebookUrlFeedback = new FeedbackLabel("facebookUrlFeedback", facebookUrl);
    facebookUrlFeedback.setOutputMarkupId(true);
    facebookUrlFeedback.setMarkupId("facebookUrlFeedback");
    facebookContainer.add(facebookUrlFeedback);
    facebookUrl.add(new ComponentVisualErrorBehaviour("onblur", facebookUrlFeedback));

    form.add(facebookContainer);

    //linkedin
    WebMarkupContainer linkedinContainer = new WebMarkupContainer("linkedinContainer");
    linkedinContainer
            .add(new Label("linkedinLabel", new ResourceModel("profile.socialnetworking.linkedin.edit")));
    final TextField<String> linkedinUrl = new TextField<String>("linkedinUrl",
            new PropertyModel<String>(userProfile, "socialInfo.linkedinUrl")) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void convertInput() {
            validateUrl(this);
        }
    };
    linkedinUrl.setMarkupId("linkedinurlinput");
    linkedinUrl.setOutputMarkupId(true);
    linkedinUrl.add(new UrlValidator());
    linkedinContainer.add(linkedinUrl);
    linkedinContainer.add(new IconWithClueTip("linkedinToolTip", ProfileConstants.INFO_IMAGE,
            new ResourceModel("text.profile.linkedin.tooltip")));

    //feedback
    final FeedbackLabel linkedinUrlFeedback = new FeedbackLabel("linkedinUrlFeedback", linkedinUrl);
    linkedinUrlFeedback.setMarkupId("linkedinUrlFeedback");
    linkedinUrlFeedback.setOutputMarkupId(true);
    linkedinContainer.add(linkedinUrlFeedback);
    linkedinUrl.add(new ComponentVisualErrorBehaviour("onblur", linkedinUrlFeedback));

    form.add(linkedinContainer);

    //myspace
    WebMarkupContainer myspaceContainer = new WebMarkupContainer("myspaceContainer");
    myspaceContainer.add(new Label("myspaceLabel", new ResourceModel("profile.socialnetworking.myspace.edit")));
    final TextField<String> myspaceUrl = new TextField<String>("myspaceUrl",
            new PropertyModel<String>(userProfile, "socialInfo.myspaceUrl")) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void convertInput() {
            validateUrl(this);
        }
    };
    myspaceUrl.setMarkupId("myspaceurlinput");
    myspaceUrl.setOutputMarkupId(true);
    myspaceUrl.add(new UrlValidator());
    myspaceContainer.add(myspaceUrl);
    myspaceContainer.add(new IconWithClueTip("myspaceToolTip", ProfileConstants.INFO_IMAGE,
            new ResourceModel("text.profile.myspace.tooltip")));

    //feedback
    final FeedbackLabel myspaceUrlFeedback = new FeedbackLabel("myspaceUrlFeedback", myspaceUrl);
    myspaceUrlFeedback.setMarkupId("myspaceUrlFeedback");
    myspaceUrlFeedback.setOutputMarkupId(true);
    myspaceContainer.add(myspaceUrlFeedback);
    myspaceUrl.add(new ComponentVisualErrorBehaviour("onblur", myspaceUrlFeedback));

    form.add(myspaceContainer);

    //twitter
    WebMarkupContainer twitterContainer = new WebMarkupContainer("twitterContainer");
    twitterContainer.add(new Label("twitterLabel", new ResourceModel("profile.socialnetworking.twitter.edit")));
    final TextField<String> twitterUrl = new TextField<String>("twitterUrl",
            new PropertyModel<String>(userProfile, "socialInfo.twitterUrl")) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void convertInput() {
            validateUrl(this);
        }
    };
    twitterUrl.setMarkupId("twitterurlinput");
    twitterUrl.setOutputMarkupId(true);
    twitterUrl.add(new UrlValidator());
    twitterContainer.add(twitterUrl);
    twitterContainer.add(new IconWithClueTip("twitterToolTip", ProfileConstants.INFO_IMAGE,
            new ResourceModel("text.profile.twitter.tooltip")));

    //feedback
    final FeedbackLabel twitterUrlFeedback = new FeedbackLabel("twitterUrlFeedback", twitterUrl);
    twitterUrlFeedback.setMarkupId("twitterUrlFeedback");
    twitterUrlFeedback.setOutputMarkupId(true);
    twitterContainer.add(twitterUrlFeedback);
    twitterUrl.add(new ComponentVisualErrorBehaviour("onblur", twitterUrlFeedback));

    form.add(twitterContainer);

    //skype
    WebMarkupContainer skypeContainer = new WebMarkupContainer("skypeContainer");
    skypeContainer.add(new Label("skypeLabel", new ResourceModel("profile.socialnetworking.skype.edit")));
    TextField skypeUsername = new TextField("skypeUsername",
            new PropertyModel(userProfile, "socialInfo.skypeUsername"));
    skypeUsername.setMarkupId("skypeusernameinput");
    skypeUsername.setOutputMarkupId(true);
    skypeContainer.add(skypeUsername);
    form.add(skypeContainer);

    //submit button
    AjaxFallbackButton submitButton = new AjaxFallbackButton("submit", new ResourceModel("button.save.changes"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {

            if (save(form)) {

                // post update event
                sakaiProxy.postEvent(ProfileConstants.EVENT_PROFILE_SOCIAL_NETWORKING_UPDATE,
                        "/profile/" + userProfile.getUserUuid(), true);

                //post to wall if enabled
                if (true == sakaiProxy.isWallEnabledGlobally()
                        && false == sakaiProxy.isSuperUserAndProxiedToUser(userProfile.getUserUuid())) {
                    wallLogic.addNewEventToWall(ProfileConstants.EVENT_PROFILE_SOCIAL_NETWORKING_UPDATE,
                            sakaiProxy.getCurrentUserId());
                }

                // repaint panel
                Component newPanel = new MySocialNetworkingDisplay(id, userProfile);
                newPanel.setOutputMarkupId(true);
                MySocialNetworkingEdit.this.replaceWith(newPanel);
                if (target != null) {
                    target.add(newPanel);
                    // resize iframe
                    target.appendJavaScript("setMainFrameHeight(window.name);");
                }

            } else {
                formFeedback.setDefaultModel(new ResourceModel("error.profile.save.business.failed"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("save-failed-error")));
                target.add(formFeedback);
            }
        }

        // This is called if the form validation fails, ie Javascript turned off, 
        //or we had preexisting invalid data before this fix was introduced
        protected void onError(AjaxRequestTarget target, Form form) {

            //check which item didn't validate and update the class and feedback model for that component
            if (!facebookUrl.isValid()) {
                facebookUrl.add(new AttributeAppender("class", new Model<String>("invalid"), " "));
                target.add(facebookUrl);
                target.add(facebookUrlFeedback);
            }
            if (!linkedinUrl.isValid()) {
                linkedinUrl.add(new AttributeAppender("class", new Model<String>("invalid"), " "));
                target.add(linkedinUrl);
                target.add(linkedinUrlFeedback);
            }
            if (!myspaceUrl.isValid()) {
                myspaceUrl.add(new AttributeAppender("class", new Model<String>("invalid"), " "));
                target.add(myspaceUrl);
                target.add(myspaceUrlFeedback);
            }
            if (!twitterUrl.isValid()) {
                twitterUrl.add(new AttributeAppender("class", new Model<String>("invalid"), " "));
                target.add(twitterUrl);
                target.add(twitterUrlFeedback);
            }
        }

    };
    form.add(submitButton);

    //cancel button
    AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"),
            form) {

        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {

            Component newPanel = new MySocialNetworkingDisplay(id, userProfile);
            newPanel.setOutputMarkupId(true);
            MySocialNetworkingEdit.this.replaceWith(newPanel);
            if (target != null) {
                target.add(newPanel);
                target.appendJavaScript("setMainFrameHeight(window.name);");
            }

        }

    };
    cancelButton.setDefaultFormProcessing(false);
    form.add(cancelButton);

    add(form);
}

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

License:Educational Community License

public MyStaffEdit(final String id, final UserProfile userProfile) {
    super(id);//from  ww  w .  j  a  v  a 2  s.c  o m

    log.debug("MyStaffEdit()");

    //this panel
    final Component thisPanel = this;

    //get userId
    final String userId = userProfile.getUserUuid();

    //heading
    add(new Label("heading", new ResourceModel("heading.staff.edit")));

    //setup form      
    Form form = new Form("form", new Model(userProfile));
    form.setOutputMarkupId(true);

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

    //add warning message if superUser and not editing own profile
    Label editWarning = new Label("editWarning");
    editWarning.setVisible(false);
    if (sakaiProxy.isSuperUserAndProxiedToUser(userId)) {
        editWarning.setDefaultModel(new StringResourceModel("text.edit.other.warning", null,
                new Object[] { userProfile.getDisplayName() }));
        editWarning.setEscapeModelStrings(false);
        editWarning.setVisible(true);
    }
    form.add(editWarning);

    //We don't need to get the info from userProfile, we load it into the form with a property model
    //just make sure that the form element id's match those in the model

    //position
    WebMarkupContainer positionContainer = new WebMarkupContainer("positionContainer");
    positionContainer.add(new Label("positionLabel", new ResourceModel("profile.position")));
    TextField position = new TextField("position", new PropertyModel(userProfile, "position"));
    position.setMarkupId("positioninput");
    position.setOutputMarkupId(true);
    positionContainer.add(position);
    form.add(positionContainer);

    //department
    WebMarkupContainer departmentContainer = new WebMarkupContainer("departmentContainer");
    departmentContainer.add(new Label("departmentLabel", new ResourceModel("profile.department")));
    TextField department = new TextField("department", new PropertyModel(userProfile, "department"));
    department.setMarkupId("departmentinput");
    department.setOutputMarkupId(true);
    departmentContainer.add(department);
    form.add(departmentContainer);

    //school
    WebMarkupContainer schoolContainer = new WebMarkupContainer("schoolContainer");
    schoolContainer.add(new Label("schoolLabel", new ResourceModel("profile.school")));
    TextField school = new TextField("school", new PropertyModel(userProfile, "school"));
    school.setMarkupId("schoolinput");
    school.setOutputMarkupId(true);
    schoolContainer.add(school);
    form.add(schoolContainer);

    //room
    WebMarkupContainer roomContainer = new WebMarkupContainer("roomContainer");
    roomContainer.add(new Label("roomLabel", new ResourceModel("profile.room")));
    TextField room = new TextField("room", new PropertyModel(userProfile, "room"));
    room.setMarkupId("roominput");
    room.setOutputMarkupId(true);
    roomContainer.add(room);
    form.add(roomContainer);

    //staffprofile
    WebMarkupContainer staffProfileContainer = new WebMarkupContainer("staffProfileContainer");
    staffProfileContainer.add(new Label("staffProfileLabel", new ResourceModel("profile.staffprofile")));
    TextArea staffProfile = new TextArea("staffProfile", new PropertyModel(userProfile, "staffProfile"));
    staffProfile.setMarkupId("staffprofileinput");
    staffProfile.setOutputMarkupId(true);
    staffProfileContainer.add(staffProfile);
    form.add(staffProfileContainer);

    //university profile URL
    WebMarkupContainer universityProfileUrlContainer = new WebMarkupContainer("universityProfileUrlContainer");
    universityProfileUrlContainer
            .add(new Label("universityProfileUrlLabel", new ResourceModel("profile.universityprofileurl")));
    TextField universityProfileUrl = new TextField("universityProfileUrl",
            new PropertyModel(userProfile, "universityProfileUrl")) {
        private static final long serialVersionUID = 1L;

        // add http:// if missing
        @Override
        protected void convertInput() {
            String input = getInput();

            if (StringUtils.isNotBlank(input)
                    && !(input.startsWith("http://") || input.startsWith("https://"))) {
                setConvertedInput("http://" + input);
            } else {
                setConvertedInput(StringUtils.isBlank(input) ? null : input);
            }
        }
    };
    universityProfileUrl.setMarkupId("universityprofileurlinput");
    universityProfileUrl.setOutputMarkupId(true);
    universityProfileUrl.add(new UrlValidator());
    universityProfileUrlContainer.add(universityProfileUrl);

    final FeedbackLabel universityProfileUrlFeedback = new FeedbackLabel("universityProfileUrlFeedback",
            universityProfileUrl);
    universityProfileUrlFeedback.setMarkupId("universityProfileUrlFeedback");
    universityProfileUrlFeedback.setOutputMarkupId(true);
    universityProfileUrlContainer.add(universityProfileUrlFeedback);
    universityProfileUrl.add(new ComponentVisualErrorBehaviour("onblur", universityProfileUrlFeedback));

    form.add(universityProfileUrlContainer);

    //academic/research profile URL
    WebMarkupContainer academicProfileUrlContainer = new WebMarkupContainer("academicProfileUrlContainer");
    academicProfileUrlContainer
            .add(new Label("academicProfileUrlLabel", new ResourceModel("profile.academicprofileurl")));
    TextField academicProfileUrl = new TextField("academicProfileUrl",
            new PropertyModel(userProfile, "academicProfileUrl")) {
        private static final long serialVersionUID = 1L;

        // add http:// if missing
        @Override
        protected void convertInput() {
            String input = getInput();

            if (StringUtils.isNotBlank(input)
                    && !(input.startsWith("http://") || input.startsWith("https://"))) {
                setConvertedInput("http://" + input);
            } else {
                setConvertedInput(StringUtils.isBlank(input) ? null : input);
            }
        }
    };
    academicProfileUrl.setMarkupId("academicprofileurlinput");
    academicProfileUrl.setOutputMarkupId(true);
    academicProfileUrl.add(new UrlValidator());
    academicProfileUrlContainer.add(academicProfileUrl);

    final FeedbackLabel academicProfileUrlFeedback = new FeedbackLabel("academicProfileUrlFeedback",
            academicProfileUrl);
    academicProfileUrlFeedback.setMarkupId("academicProfileUrlFeedback");
    academicProfileUrlFeedback.setOutputMarkupId(true);
    academicProfileUrlContainer.add(academicProfileUrlFeedback);
    academicProfileUrl.add(new ComponentVisualErrorBehaviour("onblur", academicProfileUrlFeedback));

    form.add(academicProfileUrlContainer);

    //publications
    WebMarkupContainer publicationsContainer = new WebMarkupContainer("publicationsContainer");
    publicationsContainer.add(new Label("publicationsLabel", new ResourceModel("profile.publications")));
    TextArea publications = new TextArea("publications", new PropertyModel(userProfile, "publications"));
    publications.setMarkupId("publicationsinput");
    publications.setOutputMarkupId(true);
    publicationsContainer.add(publications);

    form.add(publicationsContainer);

    //submit button
    AjaxFallbackButton submitButton = new AjaxFallbackButton("submit", new ResourceModel("button.save.changes"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            //save() form, show message, then load display panel
            if (save(form)) {

                //post update event
                sakaiProxy.postEvent(ProfileConstants.EVENT_PROFILE_STAFF_UPDATE, "/profile/" + userId, true);

                //post to wall if enabled
                if (true == sakaiProxy.isWallEnabledGlobally()
                        && false == sakaiProxy.isSuperUserAndProxiedToUser(userProfile.getUserUuid())) {
                    wallLogic.addNewEventToWall(ProfileConstants.EVENT_PROFILE_STAFF_UPDATE,
                            sakaiProxy.getCurrentUserId());
                }

                //repaint panel
                Component newPanel = new MyStaffDisplay(id, userProfile);
                newPanel.setOutputMarkupId(true);
                thisPanel.replaceWith(newPanel);
                if (target != null) {
                    target.add(newPanel);
                    //resize iframe
                    target.appendJavaScript("setMainFrameHeight(window.name);");
                }

            } else {
                //String js = "alert('Failed to save information. Contact your system administrator.');";
                //target.prependJavascript(js);

                formFeedback.setDefaultModel(new ResourceModel("error.profile.save.academic.failed"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("save-failed-error")));
                target.add(formFeedback);
            }
        }

        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            AjaxCallListener myAjaxCallListener = new AjaxCallListener() {
                @Override
                public CharSequence getBeforeHandler(Component component) {
                    return "doUpdateCK()";
                }
            };
            attributes.getAjaxCallListeners().add(myAjaxCallListener);
        }

    };
    form.add(submitButton);

    //cancel button
    AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            Component newPanel = new MyStaffDisplay(id, userProfile);
            newPanel.setOutputMarkupId(true);
            thisPanel.replaceWith(newPanel);
            if (target != null) {
                target.add(newPanel);
                //resize iframe
                target.appendJavaScript("setMainFrameHeight(window.name);");
                //need a scrollTo action here, to scroll down the page to the section
            }

        }
    };
    cancelButton.setDefaultFormProcessing(false);
    form.add(cancelButton);

    //add form to page
    add(form);

}

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

License:Educational Community License

public MyStatusPanel(String id, UserProfile userProfile) {
    super(id);//  w  ww . ja va 2 s . c om

    log.debug("MyStatusPanel()");

    //get info
    final String displayName = userProfile.getDisplayName();
    final String userId = userProfile.getUserUuid();

    //if superUser and proxied, can't update
    boolean editable = true;
    if (sakaiProxy.isSuperUserAndProxiedToUser(userId)) {
        editable = false;
    }

    //name
    Label profileName = new Label("profileName", displayName);
    add(profileName);

    //status component
    status = new ProfileStatusRenderer("status", userId, null, "tiny") {
        @Override
        public boolean isVisible() {
            return this.hasStatusSet() && sakaiProxy.isProfileStatusEnabled();
        }
    };
    status.setOutputMarkupId(true);
    add(status);

    //clear link
    final AjaxFallbackLink clearLink = new AjaxFallbackLink("clearLink") {
        private static final long serialVersionUID = 1L;

        public void onClick(AjaxRequestTarget target) {
            //clear status, hide and repaint
            if (statusLogic.clearUserStatus(userId)) {
                status.setVisible(false); //hide status
                this.setVisible(false); //hide clear link
                target.add(status);
                target.add(this);
            }
        }

        @Override
        public boolean isVisible() {
            return status.isVisible(); //if there is text to show
        }
    };
    clearLink.setOutputMarkupPlaceholderTag(true);
    clearLink.add(new Label("clearLabel", new ResourceModel("link.status.clear")));

    add(clearLink);

    WebMarkupContainer statusFormContainer = new WebMarkupContainer("statusFormContainer") {
        @Override
        public boolean isVisible() {
            return sakaiProxy.isProfileStatusEnabled();
        }
    };

    //setup SimpleText object to back the single form field 
    StringModel stringModel = new StringModel();

    //status form
    Form form = new Form("form", new Model(stringModel));
    form.setOutputMarkupId(true);

    //status field
    final TextField statusField = new TextField("message", new PropertyModel(stringModel, "string"));
    statusField.setMarkupId("messageinput");
    statusField.setOutputMarkupId(true);
    statusField.setOutputMarkupPlaceholderTag(true);
    statusField.add(new StatusFieldCounterBehaviour());
    form.add(statusField);

    //link the status textfield field with the focus/blur function via this dynamic js 
    //also link with counter
    //add(new StatusFieldCounterBehaviour());

    //submit button
    IndicatingAjaxButton submitButton = new IndicatingAjaxButton("submit", form) {

        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {

            //get the backing model
            StringModel stringModel = (StringModel) form.getModelObject();

            //get userId from sakaiProxy
            String userId = sakaiProxy.getCurrentUserId();

            //get the status. if its the default text, do not update, although we should clear the model
            String statusMessage = StringUtils.trim(stringModel.getString());
            if (StringUtils.isBlank(statusMessage) || StringUtils.equals(statusMessage, defaultStatus)) {
                log.warn("Status for userId: " + userId
                        + " was not updated because they didn't enter anything.");
                return;
            }

            //save status from userProfile
            if (statusLogic.setUserStatus(userId, statusMessage)) {
                log.info("Saved status for: " + userId);

                //post update event
                sakaiProxy.postEvent(ProfileConstants.EVENT_STATUS_UPDATE, "/profile/" + userId, true);

                //update twitter
                externalIntegrationLogic.sendMessageToTwitter(userId, statusMessage);

                // post to walls if wall enabled
                if (true == sakaiProxy.isWallEnabledGlobally()) {
                    wallLogic.addNewStatusToWall(statusMessage, sakaiProxy.getCurrentUserId());
                }

                //repaint status component
                ProfileStatusRenderer newStatus = new ProfileStatusRenderer("status", userId, null, "tiny");
                newStatus.setOutputMarkupId(true);
                status.replaceWith(newStatus);
                newStatus.setVisible(true);

                //also show the clear link
                clearLink.setVisible(true);

                if (target != null) {
                    target.add(newStatus);
                    target.add(clearLink);
                    status = newStatus; //update reference

                    //reset the field
                    target.appendJavaScript(
                            "autoFill('#" + statusField.getMarkupId() + "', '" + defaultStatus + "');");

                    //reset the counter
                    target.appendJavaScript("countChars('#" + statusField.getMarkupId() + "');");

                }

            } else {
                log.error("Couldn't save status for: " + userId);
                String js = "alert('Failed to save status. If the problem persists, contact your system administrator.');";
                target.prependJavaScript(js);
            }

        }
    };
    submitButton.setModel(new ResourceModel("button.sayit"));
    form.add(submitButton);

    //add form to container
    statusFormContainer.add(form);

    //if not editable, hide the entire form
    if (!editable) {
        statusFormContainer.setVisible(false);
    }

    add(statusFormContainer);

}

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

License:Educational Community License

public MyStudentEdit(final String id, final UserProfile userProfile) {

    super(id);// www  .ja  v a2s .  com

    //heading
    add(new Label("heading", new ResourceModel("heading.student.edit")));

    //setup form
    Form form = new Form("form", new Model(userProfile));
    form.setOutputMarkupId(true);

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

    //add warning message if superUser and not editing own profile
    Label editWarning = new Label("editWarning");
    editWarning.setVisible(false);
    if (sakaiProxy.isSuperUserAndProxiedToUser(userProfile.getUserUuid())) {
        editWarning.setDefaultModel(new StringResourceModel("text.edit.other.warning", null,
                new Object[] { userProfile.getDisplayName() }));
        editWarning.setEscapeModelStrings(false);
        editWarning.setVisible(true);
    }
    form.add(editWarning);

    //course
    WebMarkupContainer courseContainer = new WebMarkupContainer("courseContainer");
    courseContainer.add(new Label("courseLabel", new ResourceModel("profile.course")));
    TextField course = new TextField("course", new PropertyModel(userProfile, "course"));
    course.setMarkupId("courseinput");
    course.setOutputMarkupId(true);
    courseContainer.add(course);
    form.add(courseContainer);

    //subjects
    WebMarkupContainer subjectsContainer = new WebMarkupContainer("subjectsContainer");
    subjectsContainer.add(new Label("subjectsLabel", new ResourceModel("profile.subjects")));
    TextField subjects = new TextField("subjects", new PropertyModel(userProfile, "subjects"));
    subjects.setMarkupId("subjectsinput");
    subjects.setOutputMarkupId(true);
    subjectsContainer.add(subjects);
    form.add(subjectsContainer);

    //submit button
    AjaxFallbackButton submitButton = new AjaxFallbackButton("submit", new ResourceModel("button.save.changes"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            // save() form, show message, then load display panel
            if (save(form)) {

                // post update event
                sakaiProxy.postEvent(ProfileConstants.EVENT_PROFILE_STUDENT_UPDATE,
                        "/profile/" + userProfile.getUserUuid(), true);

                //post to wall if enabled
                if (true == sakaiProxy.isWallEnabledGlobally()
                        && false == sakaiProxy.isSuperUserAndProxiedToUser(userProfile.getUserUuid())) {
                    wallLogic.addNewEventToWall(ProfileConstants.EVENT_PROFILE_STUDENT_UPDATE,
                            sakaiProxy.getCurrentUserId());
                }

                // repaint panel
                Component newPanel = new MyStudentDisplay(id, userProfile);
                newPanel.setOutputMarkupId(true);
                MyStudentEdit.this.replaceWith(newPanel);
                if (target != null) {
                    target.add(newPanel);
                    // resize iframe
                    target.appendJavaScript("setMainFrameHeight(window.name);");
                }

            } else {
                // String js =
                // "alert('Failed to save information. Contact your system administrator.');";
                // target.prependJavascript(js);

                formFeedback.setDefaultModel(new ResourceModel("error.profile.save.academic.failed"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("save-failed-error")));
                target.add(formFeedback);
            }
        }
    };
    form.add(submitButton);

    //cancel button
    AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form form) {
            Component newPanel = new MyStudentDisplay(id, userProfile);
            newPanel.setOutputMarkupId(true);
            MyStudentEdit.this.replaceWith(newPanel);
            if (target != null) {
                target.add(newPanel);
                //resize iframe
                target.appendJavaScript("setMainFrameHeight(window.name);");
                //need a scrollTo action here, to scroll down the page to the section
            }

        }
    };
    cancelButton.setDefaultFormProcessing(false);
    form.add(cancelButton);

    //add form to page
    add(form);
}

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

License:Educational Community License

private void renderWallPanel(final String userUuid) {

    setOutputMarkupId(true);//from w ww .ja  v  a 2s .  co  m

    // container which wraps list
    final WebMarkupContainer wallItemsContainer = new WebMarkupContainer("wallItemsContainer");

    wallItemsContainer.setOutputMarkupId(true);
    add(wallItemsContainer);

    WallItem wallItem = new WallItem();
    wallItem.setUserUuid(userUuid);
    // always post to my wall as current user, to ensure super users cannot
    // make posts as other users
    wallItem.setCreatorUuid(sakaiProxy.getCurrentUserId());
    wallItem.setType(ProfileConstants.WALL_ITEM_TYPE_POST);

    // form for posting to my wall
    Form<WallItem> form = new Form<WallItem>("myWallPostForm", new Model<WallItem>(wallItem));
    form.setOutputMarkupId(true);
    add(form);

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

    final FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    form.add(feedback);

    int[] filteredErrorLevels = new int[] { FeedbackMessage.ERROR };
    feedback.setFilter(new ErrorLevelsFeedbackMessageFilter(filteredErrorLevels));

    // container for posting to my wall
    WebMarkupContainer myWallPostContainer = new WebMarkupContainer("myWallPostContainer");
    final TextArea myWallPost = new TextArea("myWallPost", new PropertyModel<String>(wallItem, "text"));
    myWallPost.setMarkupId("wallpostinput");
    myWallPost.setOutputMarkupId(true);

    myWallPostContainer.add(myWallPost);

    form.add(myWallPostContainer);

    IndicatingAjaxButton submitButton = new IndicatingAjaxButton("myWallPostSubmit", form) {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("unchecked")
        protected void onSubmit(AjaxRequestTarget target, Form form) {

            if (myWallPost.getValue().equals("")) {
                formFeedback.setDefaultModel(new ResourceModel("error.wall.post.empty"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("alertMessage")));
                target.add(formFeedback);
                return;
            }

            if (false == save(form, userUuid)) {
                formFeedback.setDefaultModel(new ResourceModel("error.wall.post.failed"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("alertMessage")));
                target.add(formFeedback);
            } else {

                replaceSelf(target, userUuid);
            }
        }

        //@Override
        //protected IAjaxCallDecorator getAjaxCallDecorator() {
        //   return CKEditorTextArea.getAjaxCallDecoratedToUpdateElementForAllEditorsOnPage();
        //}
    };
    submitButton.setModel(new ResourceModel("button.wall.post"));
    myWallPostContainer.add(submitButton);

    WallItemDataProvider provider = new WallItemDataProvider(userUuid);

    // if no wall items, display a message
    if (0 == provider.size()) {
        add(new Label("wallInformationMessage", new ResourceModel("text.wall.no.items")));
    } else {
        // blank label when there are items to display
        add(new Label("wallInformationMessage"));
    }

    final DataView<WallItem> wallItemsDataView = new DataView<WallItem>("wallItems", provider) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(Item<WallItem> item) {

            WallItem wallItem = (WallItem) item.getDefaultModelObject();

            // pass reference to MyWallPanel for updating when posts are removed
            item.add(new WallItemPanel("wallItemPanel", userUuid, wallItem, MyWallPanel.this));
        }
    };

    wallItemsDataView.setOutputMarkupId(true);

    if (provider.size() <= ProfileConstants.MAX_WALL_ITEMS_PER_PAGE) {
        wallItemsContainer.add(new AjaxPagingNavigator("navigator", wallItemsDataView).setVisible(false));
    } else {
        wallItemsContainer.add(new AjaxPagingNavigator("navigator", wallItemsDataView));
    }

    wallItemsDataView.setItemsPerPage(ProfileConstants.MAX_WALL_ITEMS_PER_PAGE);

    wallItemsContainer.add(wallItemsDataView);
}

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

License:Educational Community License

public ViewWallPanel(String panelId, final String userUuid) {

    super(panelId);

    setOutputMarkupId(true);//from   www  .j a va  2s .c  o m

    final String currentUserId = sakaiProxy.getCurrentUserId();

    // container which wraps list
    final WebMarkupContainer wallItemsContainer = new WebMarkupContainer("wallItemsContainer");

    wallItemsContainer.setOutputMarkupId(true);
    add(wallItemsContainer);

    WallItem wallItem = new WallItem();
    wallItem.setUserUuid(userUuid);
    // always post to my wall as current user, to ensure super users cannot
    // make posts as other users
    wallItem.setCreatorUuid(sakaiProxy.getCurrentUserId());
    wallItem.setType(ProfileConstants.WALL_ITEM_TYPE_POST);

    // form for posting to my wall
    Form<WallItem> form = new Form<WallItem>("viewWallPostForm", new Model<WallItem>(wallItem));
    form.setOutputMarkupId(true);
    add(form);

    if (false == privacyLogic.isActionAllowed(userUuid, sakaiProxy.getCurrentUserId(),
            PrivacyType.PRIVACY_OPTION_MYWALL)) {
        form.setEnabled(false);
        form.setVisible(false);
    }

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

    final FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    form.add(feedback);

    int[] filteredErrorLevels = new int[] { FeedbackMessage.ERROR };
    feedback.setFilter(new ErrorLevelsFeedbackMessageFilter(filteredErrorLevels));

    // container for posting to my wall
    WebMarkupContainer viewWallPostContainer = new WebMarkupContainer("viewWallPostContainer");
    final TextArea myWallPost = new TextArea("viewWallPost", new PropertyModel<String>(wallItem, "text"));

    viewWallPostContainer.add(myWallPost);

    form.add(viewWallPostContainer);

    IndicatingAjaxButton submitButton = new IndicatingAjaxButton("viewWallPostSubmit", form) {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("unchecked")
        protected void onSubmit(AjaxRequestTarget target, Form form) {

            if (myWallPost.getValue().equals("")) {
                formFeedback.setDefaultModel(new ResourceModel("error.wall.post.empty"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("alertMessage")));
                target.add(formFeedback);
                return;
            }

            if (false == save(form, userUuid)) {
                formFeedback.setDefaultModel(new ResourceModel("error.wall.post.failed"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("alertMessage")));
                target.add(formFeedback);
            } else {
                ViewWallPanel newPanel = new ViewWallPanel(ViewWallPanel.this.getId(), userUuid);
                newPanel.setOutputMarkupId(true);
                ViewWallPanel.this.replaceWith(newPanel);
                if (null != target) {
                    target.add(newPanel);
                    target.appendJavaScript("setMainFrameHeight(window.name);");
                }
            }
        }

        //@Override
        //protected IAjaxCallDecorator getAjaxCallDecorator() {
        //   return CKEditorTextArea.getAjaxCallDecoratedToUpdateElementForAllEditorsOnPage();
        //}
    };
    submitButton.setModel(new ResourceModel("button.wall.post"));
    viewWallPostContainer.add(submitButton);

    // note: privacy check is handled by the logic component
    WallItemDataProvider provider = new WallItemDataProvider(userUuid);

    // if no wall items, display a message
    if (0 == provider.size()) {
        if (privacyLogic.isActionAllowed(userUuid, currentUserId, PrivacyType.PRIVACY_OPTION_MYWALL)) {

            // this user has no items on their wall
            add(new Label("wallInformationMessage",
                    new StringResourceModel("text.view.wall.nothing", null,
                            new Object[] { sakaiProxy.getUserDisplayName(userUuid) }))
                                    .setEscapeModelStrings(false));
        } else {
            // wall privacy is set to connections
            add(new Label("wallInformationMessage",
                    new StringResourceModel("text.view.wall.restricted", null,
                            new Object[] { sakaiProxy.getUserDisplayName(userUuid) }))
                                    .setEscapeModelStrings(false));
        }
    } else {
        // blank label when there are items to display
        add(new Label("wallInformationMessage"));
    }

    DataView<WallItem> wallItemsDataView = new DataView<WallItem>("wallItems", provider) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(Item<WallItem> item) {

            WallItem wallItem = (WallItem) item.getDefaultModelObject();
            item.add(new WallItemPanel("wallItemPanel", userUuid, wallItem));

            if (ProfileConstants.WALL_ITEM_TYPE_STATUS == wallItem.getType()) {
                // only show if a super user or non-super user is permitted
                if (!sakaiProxy.isSuperUser() && !privacyLogic.isActionAllowed(wallItem.getCreatorUuid(),
                        currentUserId, PrivacyType.PRIVACY_OPTION_MYSTATUS)) {

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

    wallItemsDataView.setOutputMarkupId(true);

    if (provider.size() <= ProfileConstants.MAX_WALL_ITEMS_PER_PAGE) {
        wallItemsContainer.add(new AjaxPagingNavigator("navigator", wallItemsDataView).setVisible(false));
    } else {
        wallItemsContainer.add(new AjaxPagingNavigator("navigator", wallItemsDataView));
    }

    wallItemsDataView.setItemsPerPage(ProfileConstants.MAX_WALL_ITEMS_PER_PAGE);

    wallItemsContainer.add(wallItemsDataView);
}

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

License:Educational Community License

public WallItemPostCommentPanel(String id, final String userUuid, final WallItem wallItem,
        final WallItemPanel wallItemPanel, final MyWallPanel myWallPanel) {

    super(id);/*  w  ww  . j  a  va 2  s  .c  o m*/

    String commentString = "";
    IModel<String> commentModel = new Model<String>(commentString);
    Form<String> form = new Form<String>("form", commentModel);
    form.setOutputMarkupId(true);
    add(form);

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

    WebMarkupContainer commentContainer = new WebMarkupContainer("commentContainer");
    final TextArea<String> commentTextArea = new TextArea<String>("comment", commentModel);

    commentContainer.add(commentTextArea);

    form.add(commentContainer);

    IndicatingAjaxButton submitButton = new IndicatingAjaxButton("submit",
            new ResourceModel("button.wall.comment"), form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

            // don't allow empty posts
            if (null == form.getModelObject()) {
                formFeedback.setVisible(true);
                formFeedback.setDefaultModel(new ResourceModel("error.wall.comment.empty"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("alertMessage")));
                target.add(formFeedback);
                return;
            }

            // create and add comment to wall item
            WallItemComment wallItemComment = new WallItemComment();
            // always post as current user
            wallItemComment.setCreatorUuid(sakaiProxy.getCurrentUserId());
            wallItemComment.setDate(new Date());
            wallItemComment.setText(form.getModelObject().toString());
            wallItemComment.setWallItem(wallItem);
            wallItem.addComment(wallItemComment);

            // update wall item
            if (false == wallLogic.addNewCommentToWallItem(wallItemComment)) {
                formFeedback.setVisible(true);
                formFeedback.setDefaultModel(new ResourceModel("error.wall.comment.failed"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("alertMessage")));
                target.add(formFeedback);
                return;
            }

            // replace wall item panel now comment has been added
            WallItemPanel newPanel = new WallItemPanel(wallItemPanel.getId(), userUuid, wallItem, myWallPanel);
            newPanel.setOutputMarkupId(true);
            wallItemPanel.replaceWith(newPanel);
            if (null != target) {
                target.add(newPanel);
                target.appendJavaScript("setMainFrameHeight(window.name);");
            }
        }
    };
    //submitButton.add(new FocusOnLoadBehaviour());

    AttributeModifier accessibilityLabel = new AttributeModifier("title", true,
            new StringResourceModel("accessibility.wall.comment", null,
                    new Object[] { sakaiProxy.getUserDisplayName(wallItem.getCreatorUuid()) }));

    submitButton.add(accessibilityLabel);
    form.add(submitButton);

    AjaxFallbackButton cancelButton = new AjaxFallbackButton("cancel", new ResourceModel("button.cancel"),
            form) {
        private static final long serialVersionUID = 1L;

        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            commentTextArea.clearInput();
            formFeedback.setVisible(false);
            target.appendJavaScript("$('#" + WallItemPostCommentPanel.this.getMarkupId() + "').slideUp();");
        }
    };

    cancelButton.setDefaultFormProcessing(false);
    form.add(cancelButton);
}

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

License:Educational Community License

public ViewPicture(GalleryImage galleryImage) {
    configureFeedback();/*from  w w w .  jav a2 s .  co  m*/

    Label galleryImageHeading = new Label("galleryImageHeading",
            new Model<String>(galleryImage.getDisplayName()));
    add(galleryImageHeading);

    Form galleryImageForm = new Form("galleryImageForm");
    galleryImageForm.setOutputMarkupId(true);
    add(galleryImageForm);

    GalleryImageRenderer galleryImageRenderer = new GalleryImageRenderer("galleryImageRenderer",
            galleryImage.getMainResource());
    galleryImageForm.add(galleryImageRenderer);
}

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

License:Educational Community License

private void createGalleryForm(final String userUuid) {

    Label galleryHeading = new Label("galleryHeading", new StringResourceModel("heading.pictures.view.pictures",
            null, new Object[] { sakaiProxy.getUserDisplayName(userUuid) }));

    add(galleryHeading);/*  ww  w  . j av a2s .c o  m*/

    Form galleryForm = new Form("galleryForm") {

        private static final long serialVersionUID = 1L;
    };
    galleryForm.setOutputMarkupId(true);

    populateGallery(galleryForm, userUuid);

    add(galleryForm);
}