Example usage for org.apache.wicket Component setOutputMarkupId

List of usage examples for org.apache.wicket Component setOutputMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket Component 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.MyStudentEdit.java

License:Educational Community License

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

    super(id);//from w w w .j a  v a2s .  c o  m

    //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.webical.web.components.ajax.menu.YUIContextMenuConfiguration.java

License:Open Source License

/**
 * @param triggerComponent the component that can trigger the menu (uses setOutputMarkupId(true) on this component)
 * @param menu the menu/* w w w.  j a  v a  2s  .  c  o m*/
 */
public YUIContextMenuConfiguration(Component triggerComponent, List<YUIContextMenuItem> menu) {
    super();
    this.triggerComponent = triggerComponent;
    triggerComponent.setOutputMarkupId(true);
    this.menu = menu;
}

From source file:org.wicketstuff.animator.MarkupIdModel.java

License:Apache License

/**
 * Use this method to add another component to the model.
 * /*from  www  .j av a  2 s . co m*/
 * @param component
 *            the component to be added.
 * @return this {@link MarkupIdModel} for fluent method calls.
 */
public MarkupIdModel add(Component component) {
    if (components == null) {
        components = new HashSet<Component>();
    }
    component.setOutputMarkupId(true);
    components.add(component);
    return this;
}

From source file:org.wicketstuff.animator.MarkupIdModel.java

License:Apache License

/**
 * Use this method to add more components to the model.
 * /* w  w w .  j  a v  a2 s .c om*/
 * @param components
 *            the components to be added.
 * @return this {@link MarkupIdModel} for fluent method calls.
 */
public MarkupIdModel add(Collection<? extends Component> components) {
    if (components == null) {
        components = new HashSet<Component>();
    }
    for (Component component : components) {
        component.setOutputMarkupId(true);
        add(component);
    }
    return this;
}

From source file:org.wicketstuff.calendar.markup.html.form.DatePicker.java

License:Apache License

/**
 * @see org.apache.wicket.behavior.AbstractBehavior#bind(org.apache.wicket.Component)
 *//* w  w  w . ja v  a  2  s  .  c om*/
public void bind(Component component) {
    checkComponentProvidesDateFormat(component);
    component.setOutputMarkupId(true);
    this.component = component;
}

From source file:org.wicketstuff.datatable_autocomplete.model.MarkupIDInStringModel.java

License:Apache License

/**
 * //from  w w w.  java2s  .c o  m
 */
public MarkupIDInStringModel(String template, Component target,
        Map<String, IModel<? extends Serializable>> templateArgMap) {
    super();
    this.template = template;
    this.target = target;
    this.templateArgMap = templateArgMap;

    target.setOutputMarkupId(true);

}

From source file:org.wicketstuff.datatable_autocomplete.panel.AbstractAutoCompleteDependencyProcessor.java

License:Apache License

/**
 * /*from www .j av  a 2  s . c  om*/
 */
public AbstractAutoCompleteDependencyProcessor(String[] names, Component[] components) {

    super();

    queryParameterToComponentMap = new LinkedHashMap<String, Component>();

    for (int i = 0; i < components.length; i++) {
        String parameter = names[i];
        Component component = components[i];

        // to guarantee that the markupid will be generated
        component.setOutputMarkupId(true);
        component.setOutputMarkupPlaceholderTag(true);

        queryParameterToComponentMap.put(parameter, component);

    }

}

From source file:org.wicketstuff.datetime.extensions.yui.calendar.DatePicker.java

License:Apache License

/**
 * {@inheritDoc}//from  w  w w .  j a v  a2  s . co m
 */
@Override
public void bind(final Component component) {
    this.component = component;
    checkComponentProvidesDateFormat(component);
    component.setOutputMarkupId(true);
}

From source file:org.wicketstuff.dojo11.dojofx.FxToggler.java

License:Apache License

protected void onBind() {
    Component component = getComponent();
    component.setOutputMarkupId(true);

    getTrigger().add(new AttributeAppender("class", true,
            new Model((_startShown ? FX_WIPER_SHOWN_CLASS : FX_WIPER_HIDDEN_CLASS)), " "));

    ToggleEvents e = getEvents();//from   w  ww  .  ja  v  a  2  s  .  c  o m

    super.onBind();
}

From source file:org.wicketstuff.extjs.behavior.ExtTabbedPanelBehavior.java

License:Apache License

@Override
public void beforeRender(Component component) {
    super.beforeRender(component);

    if (autoTagComponents) {
        ((MarkupContainer) component).visitChildren(MarkupContainer.class, new IVisitor() {

            public Object component(Component child) {
                if (child instanceof AbstractRepeater) {
                    return null;
                }//from ww w  . j  a v a  2s .  c  o  m
                child.setOutputMarkupId(true);
                child.add(new AttributeAppender("class", new Model("x-tab"), " ") {
                    @Override
                    public boolean isTemporary() {
                        return true;
                    }
                });

                return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
            }
        });
    }
}