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

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

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form Radio 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:com.userweave.pages.components.twoColumnPanel.multiColumnRadioChoicePanel.RadioChoiceColumnPanel.java

License:Open Source License

public RadioChoiceColumnPanel(String id, IModel model, IChoiceRenderer renderer) {
    super(id);//w  w w  .  ja  va 2  s . c o m

    Radio radio = new Radio("radio", model);

    radio.setOutputMarkupId(true);

    add(radio);

    Label label = new Label("label", getLabel(this, model, renderer));

    label.add(new AttributeModifier("for", new Model<String>(radio.getMarkupId())));

    add(label);
}

From source file:de.alpharogroup.wicket.components.examples.radios.RadioGroupExamplePanel.java

License:Apache License

public RadioGroupExamplePanel(final String id, final IModel<Company> model) {
    super(id, model);
    // Radio buttons have to be part of a Form component.
    final Form<?> form = new Form<>("form");
    add(form);//from  ww  w  .ja  va  2 s.c om
    final RadioGroupModelBean<Company> radioGroupModel = new RadioGroupModelBean<>();
    setModel(model);
    // create list...
    final List<Company> comps = Arrays.asList(Company.builder().name("Ferrari").build(),
            Company.builder().name("Lamborgini").build(), Company.builder().name("Mazerati").build(),
            Company.builder().name("Porsche").build());
    // we can set the selected radio from the start or leave it blank...
    // radioGroupModel.setSelected(comps.get(0));
    radioGroupModel.setRadios(comps);

    final IModel<List<Company>> companies = new ListModel<Company>(comps);

    final RadioGroup<Company> group = new RadioGroup<Company>("group",
            new PropertyModel<Company>(radioGroupModel, "selected"));
    group.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            target.add(getFeedback());
            info("Selected Type : " + radioGroupModel.getSelected());
        }
    });
    form.add(group);
    // Construct a radio button and label for each company.
    group.add(new ListView<Company>("choice", companies) {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<Company> it) {
            final Radio<Company> radio = new Radio<Company>("radio", it.getModel(), group);
            radio.setOutputMarkupId(true);
            it.add(radio);
            it.add(ComponentFactory.newLabel("label", radio.getMarkupId(),
                    Model.of(it.getModelObject().getName())));
        }
    });
    final RadioGroupPanel<Company> radioGroupPanel = new RadioGroupPanel<Company>("radioGroupPanel",
            Model.of(radioGroupModel)) {
        /**
         * The serialVersionUID
         */
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            super.onUpdate(target);
            target.add(getFeedback());
            info("Selected Type : " + radioGroupModel.getSelected());
        }
    };
    add(radioGroupPanel);
}

From source file:de.alpharogroup.wicket.components.radio.RadioGroupPanel.java

License:Apache License

/**
 * Factory method for create the new {@link ListView} for the {@link Radio} objects. This method
 * is invoked in the constructor from the derived classes and can be overridden so users can
 * provide their own version of a new {@link ListView} for the {@link Radio} objects.
 *
 * @param id//from  w  w w  . j av a  2s  .  com
 *            the id
 * @param model
 *            the model
 * @return the new {@link ListView} for the {@link Radio} objects.
 */
protected ListView<T> newRadioListView(final String id, final IModel<RadioGroupModelBean<T>> model) {
    final ListView<T> radioListView = new ListView<T>("choice", model.getObject().getRadios()) {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        /**
         * {@inheritDoc}
         */
        @Override
        protected void populateItem(final ListItem<T> item) {
            final Radio<T> radio = new Radio<>("radio", item.getModel(), RadioGroupPanel.this.group);
            radio.setOutputMarkupId(true);
            item.add(radio);
            item.add(RadioGroupPanel.this.newLabel("label", radio.getMarkupId(), item.getModel()));
        }
    };
    radioListView.setOutputMarkupId(true);
    return radioListView;
}

From source file:net.dontdrinkandroot.extensions.wicket.component.jqueryui.JQueryUiAjaxRadioChoice.java

License:Apache License

public JQueryUiAjaxRadioChoice(String id, IModel<T> model, IModel<? extends List<T>> choices,
        IChoiceRenderer<? super T> renderer) {
    super(id, model);

    this.setOutputMarkupId(true);

    this.choices = choices;
    this.setChoiceRenderer(renderer);

    final RadioGroup<T> radioGroup = new RadioGroup<T>("radioGroup", model);
    this.add(radioGroup);

    final ListView<T> radioItemView = new ListView<T>("radioItem", choices) {

        private static final long serialVersionUID = 1L;

        @Override/*from w  w  w  .java2s.  c o  m*/
        protected void populateItem(final ListItem<T> item) {

            final Radio<T> radio = new Radio<T>("input", item.getModel(), radioGroup);
            radio.setOutputMarkupId(true);
            radio.add(new AjaxEventBehavior("onclick") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    JQueryUiAjaxRadioChoice.this.onSelectionChanged(item.getModelObject(), target);
                }
            });
            item.add(radio);

            final Label label = new Label("label", JQueryUiAjaxRadioChoice.this.getChoiceRenderer()
                    .getDisplayValue(item.getModel().getObject()).toString());
            label.add(new AttributeAppender("for", new Model<String>(radio.getMarkupId())));
            item.add(label);

            item.setRenderBodyOnly(true);
        }
    };
    radioGroup.add(radioItemView);
}

From source file:net.dontdrinkandroot.wicket.component.jqueryui.JQueryUiAjaxRadioChoice.java

License:Apache License

public JQueryUiAjaxRadioChoice(String id, IModel<T> model, IModel<? extends List<? extends T>> choices,
        IChoiceRenderer<? super T> renderer) {

    super(id, model);

    this.setOutputMarkupId(true);

    this.choices = choices;
    this.setChoiceRenderer(renderer);

    final RadioGroup<T> radioGroup = new RadioGroup<T>("radioGroup", model);
    this.add(radioGroup);

    ListView<T> radioItemView = new ListView<T>("radioItem", choices) {

        private static final long serialVersionUID = 1L;

        @Override/*from ww w  .j a  v a2s  .  co m*/
        protected void populateItem(final ListItem<T> item) {

            Radio<T> radio = new Radio<T>("input", item.getModel(), radioGroup);
            radio.setOutputMarkupId(true);
            radio.add(new AjaxEventBehavior("onclick") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {

                    JQueryUiAjaxRadioChoice.this.onSelectionChanged(item.getModelObject(), target);
                }
            });
            item.add(radio);

            Label label = new Label("label", JQueryUiAjaxRadioChoice.this.getChoiceRenderer()
                    .getDisplayValue(item.getModel().getObject()).toString());
            label.add(new AttributeAppender("for", new Model<String>(radio.getMarkupId())));
            item.add(label);

            item.setRenderBodyOnly(true);
        }

    };
    radioGroup.add(radioItemView);
}

From source file:net.kornr.swit.site.widget.AjaxImageRadio.java

License:Apache License

public AjaxImageRadio(String id, ResourceReference resourceReference, ValueMap resourceParameters, Form form,
        Radio radio) {
    super(id, resourceReference, resourceParameters);

    radio.setOutputMarkupId(true);
    m_radioId = radio.getMarkupId();/*from   w w  w  . ja  v  a2s  .c  o m*/

    this.add(new AjaxFormSubmitBehavior(form, "onclick") {
        @Override
        protected void onError(AjaxRequestTarget arg0) {
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            AjaxImageRadio.this.onSubmit(target);
        }

        @Override
        protected CharSequence getEventHandler() {
            String seq = "$('#" + m_radioId + "').attr('checked',true);";
            return seq + super.getEventHandler();
        }
    });
}

From source file:org.cast.cwm.data.component.StarPanel.java

License:Open Source License

/**
 * Constructor.  If the model object is null, this component will be invisible.
 * /*from   ww w . j a v a 2 s  .  c o m*/
 * TODO: This hiding behavior is not ideal or expected.  Only used because this is
 * both a viewer and editor.
 * 
 * @param id
 * @param model
 */
public StarPanel(String id, IModel<Response> model) {
    super(id, model);

    setOutputMarkupId(true);
    add(AttributeModifier.append("class", "starPanel"));

    if (model == null || model.getObject() == null) {
        setVisible(false);
        return;
    }

    if (!model.getObject().getType().equals(typeRegistry.getResponseType("STAR_RATING")))
        throw new IllegalArgumentException(
                "A Star Rating panel must be attached to a ResponseType.STAR_RATING.");

    Form<Response> form = new Form<Response>("starForm", getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            responseService.saveStarRating(getModel(), Integer.valueOf(radioGroup.getValue()).intValue());
        }
    };

    add(form);

    radioGroup = new RadioGroup<Integer>("radioGroup", new Model<Integer>()); // Model set in onBeforeRender()
    form.add(radioGroup);

    // TODO: This markup is not the best for accessibility.  The label should come after the radio, not wrap it.  However
    // changing would take a lot of work in the javascript.
    RepeatingView rv = new RepeatingView("radioRepeatingView");
    radioGroup.add(rv);
    for (int i = 1; i <= numStars; i++) {
        WebMarkupContainer item = new WebMarkupContainer(rv.newChildId());
        rv.add(item);

        Radio<Integer> radio = new Radio<Integer>("radio", new Model<Integer>(i));
        radio.setOutputMarkupId(true);

        Label label = new Label("label", i == 1 ? i + " Star" : i + " Stars");
        label.setRenderBodyOnly(true);
        item.add(AttributeModifier.replace("for", radio.getMarkupId()));
        item.add(radio);
        item.add(label);
    }

    form.add(new DisablingIndicatingAjaxButton("submitButton") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            onSave(target);
            target.add(StarPanel.this);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            onError(target, form);
        }

        @Override
        protected Collection<? extends Component> getComponents() {
            return Arrays.asList(StarPanel.this);
        }

    });
}

From source file:org.odlabs.wiquery.ui.button.ButtonRadioSet.java

License:Open Source License

/**
 * Constructor/*from w w  w .  j  a v a2s . co  m*/
 * 
 * @param id
 *            Wicket identifier
 * @param radios
 *            List of radios
 */
public ButtonRadioSet(String id, IModel<? extends List<ButtonElement<T>>> radios, IModel<T> model) {
    super(id);

    radioGroup = new RadioGroup<T>("buttonRadioSetGroup", model) {
        private static final long serialVersionUID = 8265281439115476364L;

        @Override
        protected void onSelectionChanged(T newSelection) {
            ButtonRadioSet.this.onSelectionChanged(newSelection);
        }
    };
    radioGroup.setOutputMarkupId(true);
    radioGroup.setRenderBodyOnly(false);
    add(radioGroup);

    ListView<? extends ButtonElement<T>> view = new ListView<ButtonElement<T>>("buttonRadioSetView", radios) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<ButtonElement<T>> item) {
            ButtonElement<T> buttonElement = item.getModelObject();

            Radio<T> radio = newRadio("buttonRadio", buttonElement.getModel(), radioGroup);
            radio.setLabel(buttonElement.getLabel());
            radio.setOutputMarkupId(true);

            SimpleFormComponentLabel label = new SimpleFormComponentLabel("buttonRadioLabel", radio);

            item.add(radio);
            item.add(label);
        }
    };
    radioGroup.add(view);
}

From source file:org.projectforge.web.wicket.flowlayout.RadioGroupPanel.java

License:Open Source License

public Radio<T> add(final Model<T> model, final String labelString, final String tooltip) {
    final WebMarkupContainer cont = new WebMarkupContainer(repeater.newChildId());
    repeater.add(cont);/*from w  w  w.j av a  2  s.  c  om*/
    final Radio<T> radio = new Radio<T>("radio", model, radioGroup);
    if (autosubmit == true) {
        radio.add(AttributeModifier.replace("onchange", "javascript:submit();"));
    }
    cont.add(radio);
    final Label label = new Label("label", labelString);
    label.add(AttributeModifier.replace("for", radio.setOutputMarkupId(true).getMarkupId()));
    cont.add(label);
    if (tooltip != null) {
        WicketUtils.addTooltip(label, tooltip);
    }
    return radio;
}

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

License:Educational Community License

public MyPreferences() {

    log.debug("MyPreferences()");

    disableLink(preferencesLink);/*www  . j a  v a 2 s.c o m*/

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

    //get the prefs record for this user from the database, or a default if none exists yet
    profilePreferences = preferencesLogic.getPreferencesRecordForUser(userUuid, false);

    //if null, throw exception
    if (profilePreferences == null) {
        throw new ProfilePreferencesNotDefinedException("Couldn't retrieve preferences record for " + userUuid);
    }

    //get email address for this user
    String emailAddress = sakaiProxy.getUserEmail(userUuid);
    //if no email, set a message into it fo display
    if (emailAddress == null || emailAddress.length() == 0) {
        emailAddress = new ResourceModel("preferences.email.none").getObject();
    }

    Label heading = new Label("heading", new ResourceModel("heading.preferences"));
    add(heading);

    //feedback for form submit action
    final Label formFeedback = new Label("formFeedback");
    formFeedback.setOutputMarkupPlaceholderTag(true);
    final String formFeedbackId = formFeedback.getMarkupId();
    add(formFeedback);

    //create model
    CompoundPropertyModel<ProfilePreferences> preferencesModel = new CompoundPropertyModel<ProfilePreferences>(
            profilePreferences);

    //setup form      
    Form<ProfilePreferences> form = new Form<ProfilePreferences>("form", preferencesModel);
    form.setOutputMarkupId(true);

    //EMAIL SECTION

    //email settings
    form.add(new Label("emailSectionHeading", new ResourceModel("heading.section.email")));
    form.add(new Label("emailSectionText",
            new StringResourceModel("preferences.email.message", null, new Object[] { emailAddress }))
                    .setEscapeModelStrings(false));

    //on/off labels
    form.add(new Label("prefOn", new ResourceModel("preference.option.on")));
    form.add(new Label("prefOff", new ResourceModel("preference.option.off")));

    //request emails
    final RadioGroup<Boolean> emailRequests = new RadioGroup<Boolean>("requestEmailEnabled",
            new PropertyModel<Boolean>(preferencesModel, "requestEmailEnabled"));
    Radio requestsOn = new Radio<Boolean>("requestsOn", new Model<Boolean>(Boolean.valueOf(true)));
    requestsOn.setMarkupId("requestsoninput");
    requestsOn.setOutputMarkupId(true);
    emailRequests.add(requestsOn);
    Radio requestsOff = new Radio<Boolean>("requestsOff", new Model<Boolean>(Boolean.valueOf(false)));
    requestsOff.setMarkupId("requestsoffinput");
    requestsOff.setOutputMarkupId(true);
    emailRequests.add(requestsOff);
    emailRequests.add(new Label("requestsLabel", new ResourceModel("preferences.email.requests")));
    form.add(emailRequests);

    //updater
    emailRequests.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });

    //visibility for request emails
    emailRequests.setVisible(sakaiProxy.isConnectionsEnabledGlobally());

    //confirm emails
    final RadioGroup<Boolean> emailConfirms = new RadioGroup<Boolean>("confirmEmailEnabled",
            new PropertyModel<Boolean>(preferencesModel, "confirmEmailEnabled"));
    Radio confirmsOn = new Radio<Boolean>("confirmsOn", new Model<Boolean>(Boolean.valueOf(true)));
    confirmsOn.setMarkupId("confirmsoninput");
    confirmsOn.setOutputMarkupId(true);
    emailConfirms.add(confirmsOn);
    Radio confirmsOff = new Radio<Boolean>("confirmsOff", new Model<Boolean>(Boolean.valueOf(false)));
    confirmsOff.setMarkupId("confirmsoffinput");
    confirmsOff.setOutputMarkupId(true);
    emailConfirms.add(confirmsOff);
    emailConfirms.add(new Label("confirmsLabel", new ResourceModel("preferences.email.confirms")));
    form.add(emailConfirms);

    //updater
    emailConfirms.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });

    //visibility for confirm emails
    emailConfirms.setVisible(sakaiProxy.isConnectionsEnabledGlobally());

    //new message emails
    final RadioGroup<Boolean> emailNewMessage = new RadioGroup<Boolean>("messageNewEmailEnabled",
            new PropertyModel<Boolean>(preferencesModel, "messageNewEmailEnabled"));
    Radio messageNewOn = new Radio<Boolean>("messageNewOn", new Model<Boolean>(Boolean.valueOf(true)));
    messageNewOn.setMarkupId("messagenewoninput");
    messageNewOn.setOutputMarkupId(true);
    emailNewMessage.add(messageNewOn);
    Radio messageNewOff = new Radio<Boolean>("messageNewOff", new Model<Boolean>(Boolean.valueOf(false)));
    messageNewOff.setMarkupId("messagenewoffinput");
    messageNewOff.setOutputMarkupId(true);
    emailNewMessage.add(messageNewOff);
    emailNewMessage.add(new Label("messageNewLabel", new ResourceModel("preferences.email.message.new")));
    form.add(emailNewMessage);

    //updater
    emailNewMessage.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });

    emailNewMessage.setVisible(sakaiProxy.isMessagingEnabledGlobally());

    //message reply emails
    final RadioGroup<Boolean> emailReplyMessage = new RadioGroup<Boolean>("messageReplyEmailEnabled",
            new PropertyModel<Boolean>(preferencesModel, "messageReplyEmailEnabled"));
    Radio messageReplyOn = new Radio<Boolean>("messageReplyOn", new Model<Boolean>(Boolean.valueOf(true)));
    messageReplyOn.setMarkupId("messagereplyoninput");
    messageNewOn.setOutputMarkupId(true);
    emailReplyMessage.add(messageReplyOn);
    Radio messageReplyOff = new Radio<Boolean>("messageReplyOff", new Model<Boolean>(Boolean.valueOf(false)));
    messageReplyOff.setMarkupId("messagereplyoffinput");
    messageNewOff.setOutputMarkupId(true);
    emailReplyMessage.add(messageReplyOff);
    emailReplyMessage.add(new Label("messageReplyLabel", new ResourceModel("preferences.email.message.reply")));
    form.add(emailReplyMessage);

    //updater
    emailReplyMessage.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });

    emailReplyMessage.setVisible(sakaiProxy.isMessagingEnabledGlobally());

    // new wall item notification emails
    final RadioGroup<Boolean> wallItemNew = new RadioGroup<Boolean>("wallItemNewEmailEnabled",
            new PropertyModel<Boolean>(preferencesModel, "wallItemNewEmailEnabled"));
    Radio wallItemNewOn = new Radio<Boolean>("wallItemNewOn", new Model<Boolean>(Boolean.valueOf(true)));
    wallItemNewOn.setMarkupId("wallitemnewoninput");
    wallItemNewOn.setOutputMarkupId(true);
    wallItemNew.add(wallItemNewOn);
    Radio wallItemNewOff = new Radio<Boolean>("wallItemNewOff", new Model<Boolean>(Boolean.valueOf(false)));
    wallItemNewOff.setMarkupId("wallitemnewoffinput");
    wallItemNewOff.setOutputMarkupId(true);
    wallItemNew.add(wallItemNewOff);
    wallItemNew.add(new Label("wallItemNewLabel", new ResourceModel("preferences.email.wall.new")));
    form.add(wallItemNew);

    //updater
    wallItemNew.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });

    //visibility for wall items
    wallItemNew.setVisible(sakaiProxy.isWallEnabledGlobally());

    // added to new worksite emails
    final RadioGroup<Boolean> worksiteNew = new RadioGroup<Boolean>("worksiteNewEmailEnabled",
            new PropertyModel<Boolean>(preferencesModel, "worksiteNewEmailEnabled"));
    Radio worksiteNewOn = new Radio<Boolean>("worksiteNewOn", new Model<Boolean>(Boolean.valueOf(true)));
    worksiteNewOn.setMarkupId("worksitenewoninput");
    worksiteNewOn.setOutputMarkupId(true);
    worksiteNew.add(worksiteNewOn);
    Radio worksiteNewOff = new Radio<Boolean>("worksiteNewOff", new Model<Boolean>(Boolean.valueOf(false)));
    worksiteNewOff.setMarkupId("worksitenewoffinput");
    worksiteNewOff.setOutputMarkupId(true);
    worksiteNew.add(worksiteNewOff);
    worksiteNew.add(new Label("worksiteNewLabel", new ResourceModel("preferences.email.worksite.new")));
    form.add(worksiteNew);

    //updater
    worksiteNew.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });

    // TWITTER SECTION

    //headings
    WebMarkupContainer twitterSectionHeadingContainer = new WebMarkupContainer(
            "twitterSectionHeadingContainer");
    twitterSectionHeadingContainer
            .add(new Label("twitterSectionHeading", new ResourceModel("heading.section.twitter")));
    twitterSectionHeadingContainer
            .add(new Label("twitterSectionText", new ResourceModel("preferences.twitter.message")));
    form.add(twitterSectionHeadingContainer);

    //panel
    if (sakaiProxy.isTwitterIntegrationEnabledGlobally()) {
        form.add(new AjaxLazyLoadPanel("twitterPanel") {
            private static final long serialVersionUID = 1L;

            @Override
            public Component getLazyLoadComponent(String markupId) {
                return new TwitterPrefsPane(markupId, userUuid);
            }
        });
    } else {
        form.add(new EmptyPanel("twitterPanel"));
        twitterSectionHeadingContainer.setVisible(false);
    }

    // IMAGE SECTION
    //only one of these can be selected at a time
    WebMarkupContainer is = new WebMarkupContainer("imageSettingsContainer");
    is.setOutputMarkupId(true);

    // headings
    is.add(new Label("imageSettingsHeading", new ResourceModel("heading.section.image")));
    is.add(new Label("imageSettingsText", new ResourceModel("preferences.image.message")));

    officialImageEnabled = sakaiProxy.isUsingOfficialImageButAlternateSelectionEnabled();
    gravatarEnabled = sakaiProxy.isGravatarImageEnabledGlobally();

    //official image
    //checkbox
    WebMarkupContainer officialImageContainer = new WebMarkupContainer("officialImageContainer");
    officialImageContainer
            .add(new Label("officialImageLabel", new ResourceModel("preferences.image.official")));
    officialImage = new CheckBox("officialImage",
            new PropertyModel<Boolean>(preferencesModel, "useOfficialImage"));
    officialImage.setMarkupId("officialimageinput");
    officialImage.setOutputMarkupId(true);
    officialImageContainer.add(officialImage);

    //updater
    officialImage.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {

            //set gravatar to false since we can't have both active
            gravatarImage.setModelObject(false);
            if (gravatarEnabled) {
                target.add(gravatarImage);
            }
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });
    is.add(officialImageContainer);

    //if using official images but alternate choice isn't allowed, hide this section
    if (!officialImageEnabled) {
        profilePreferences.setUseOfficialImage(false); //set the model false to clear data as well (doesnt really need to do this but we do it to keep things in sync)
        officialImageContainer.setVisible(false);
    }

    //gravatar
    //checkbox
    WebMarkupContainer gravatarContainer = new WebMarkupContainer("gravatarContainer");
    gravatarContainer.add(new Label("gravatarLabel", new ResourceModel("preferences.image.gravatar")));
    gravatarImage = new CheckBox("gravatarImage", new PropertyModel<Boolean>(preferencesModel, "useGravatar"));
    gravatarImage.setMarkupId("gravatarimageinput");
    gravatarImage.setOutputMarkupId(true);
    gravatarContainer.add(gravatarImage);

    //updater
    gravatarImage.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {

            //set gravatar to false since we can't have both active
            officialImage.setModelObject(false);
            if (officialImageEnabled) {
                target.add(officialImage);
            }
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });
    is.add(gravatarContainer);

    //if gravatar's are disabled, hide this section
    if (!gravatarEnabled) {
        profilePreferences.setUseGravatar(false); //set the model false to clear data as well (doesnt really need to do this but we do it to keep things in sync)
        gravatarContainer.setVisible(false);
    }

    //if official image disabled and gravatar disabled, hide the entire container
    if (!officialImageEnabled && !gravatarEnabled) {
        is.setVisible(false);
    }

    form.add(is);

    // WIDGET SECTION
    WebMarkupContainer ws = new WebMarkupContainer("widgetSettingsContainer");
    ws.setOutputMarkupId(true);
    int visibleWidgetCount = 0;

    //widget settings
    ws.add(new Label("widgetSettingsHeading", new ResourceModel("heading.section.widget")));
    ws.add(new Label("widgetSettingsText", new ResourceModel("preferences.widget.message")));

    //kudos
    WebMarkupContainer kudosContainer = new WebMarkupContainer("kudosContainer");
    kudosContainer.add(new Label("kudosLabel", new ResourceModel("preferences.widget.kudos")));
    CheckBox kudosSetting = new CheckBox("kudosSetting",
            new PropertyModel<Boolean>(preferencesModel, "showKudos"));
    kudosSetting.setMarkupId("kudosinput");
    kudosSetting.setOutputMarkupId(true);
    kudosContainer.add(kudosSetting);
    //tooltip
    kudosContainer.add(new IconWithClueTip("kudosToolTip", ProfileConstants.INFO_IMAGE,
            new ResourceModel("preferences.widget.kudos.tooltip")));

    //updater
    kudosSetting.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });
    ws.add(kudosContainer);
    if (sakaiProxy.isMyKudosEnabledGlobally()) {
        visibleWidgetCount++;
    } else {
        kudosContainer.setVisible(false);
    }

    //gallery feed
    WebMarkupContainer galleryFeedContainer = new WebMarkupContainer("galleryFeedContainer");
    galleryFeedContainer.add(new Label("galleryFeedLabel", new ResourceModel("preferences.widget.gallery")));
    CheckBox galleryFeedSetting = new CheckBox("galleryFeedSetting",
            new PropertyModel<Boolean>(preferencesModel, "showGalleryFeed"));
    galleryFeedSetting.setMarkupId("galleryfeedsettinginput");
    galleryFeedSetting.setOutputMarkupId(true);
    galleryFeedContainer.add(galleryFeedSetting);
    //tooltip
    galleryFeedContainer.add(new IconWithClueTip("galleryFeedToolTip", ProfileConstants.INFO_IMAGE,
            new ResourceModel("preferences.widget.gallery.tooltip")));

    //updater
    galleryFeedSetting.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });
    ws.add(galleryFeedContainer);
    if (sakaiProxy.isProfileGalleryEnabledGlobally()) {
        visibleWidgetCount++;
    } else {
        galleryFeedContainer.setVisible(false);
    }

    //online status
    WebMarkupContainer onlineStatusContainer = new WebMarkupContainer("onlineStatusContainer");
    onlineStatusContainer
            .add(new Label("onlineStatusLabel", new ResourceModel("preferences.widget.onlinestatus")));
    CheckBox onlineStatusSetting = new CheckBox("onlineStatusSetting",
            new PropertyModel<Boolean>(preferencesModel, "showOnlineStatus"));
    onlineStatusSetting.setMarkupId("onlinestatussettinginput");
    onlineStatusSetting.setOutputMarkupId(true);
    onlineStatusContainer.add(onlineStatusSetting);
    //tooltip
    onlineStatusContainer.add(new IconWithClueTip("onlineStatusToolTip", ProfileConstants.INFO_IMAGE,
            new ResourceModel("preferences.widget.onlinestatus.tooltip")));

    //updater
    onlineStatusSetting.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = 1L;

        protected void onUpdate(AjaxRequestTarget target) {
            target.appendJavaScript("$('#" + formFeedbackId + "').fadeOut();");
        }
    });
    ws.add(onlineStatusContainer);

    if (sakaiProxy.isOnlineStatusEnabledGlobally()) {
        visibleWidgetCount++;
    } else {
        onlineStatusContainer.setVisible(false);
    }

    // Hide widget container if nothing to show
    if (visibleWidgetCount == 0) {
        ws.setVisible(false);
    }

    form.add(ws);

    //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
            ProfilePreferences profilePreferences = (ProfilePreferences) form.getModelObject();

            formFeedback.setDefaultModel(new ResourceModel("success.preferences.save.ok"));
            formFeedback.add(new AttributeModifier("class", true, new Model<String>("success")));

            //save
            if (preferencesLogic.savePreferencesRecord(profilePreferences)) {
                formFeedback.setDefaultModel(new ResourceModel("success.preferences.save.ok"));
                formFeedback.add(new AttributeModifier("class", true, new Model<String>("success")));

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

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

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

            //PRFL-775 - set focus to feedback message so it is announced to screenreaders
            target.appendJavaScript("$('#" + formFeedbackId + "').focus();");

            target.add(formFeedback);
        }

    };
    submitButton.setModel(new ResourceModel("button.save.settings"));
    submitButton.setDefaultFormProcessing(false);
    form.add(submitButton);

    add(form);

}