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.cipango.ims.hss.web.gba.EditUssPage.java

License:Apache License

@SuppressWarnings("unchecked")
public EditUssPage(PageParameters pageParameters) {
    super(pageParameters);
    String sKey = pageParameters.getString("id");
    PrivateIdentity privateIdentity = null;
    if (sKey != null)
        _key = Long.decode(sKey);
    else {/*from   ww  w. j a v  a2  s.c o  m*/
        _privateIdKey = pageParameters.getString("privateId");
        privateIdentity = _privateIdentityDao.findById(_privateIdKey);
    }

    Uss uss = null;
    if (_key != null) {
        uss = _dao.findById(_key);
        if (uss == null) {
            error(MapVariableInterpolator.interpolate(getString(getPrefix() + ".error.notFound"),
                    new MicroMap("identity", _key)));
            _key = null;
        } else {
            privateIdentity = uss.getPrivateIdentity();
            _privateIdKey = privateIdentity.getIdentity();
        }
    }

    if (uss == null) {
        uss = new Uss();
    }

    DaoDetachableModel model = new DaoDetachableModel(uss);

    if (isAdding()) {
        _title = MapVariableInterpolator.interpolate(getString(getPrefix() + ".add.title"),
                new MicroMap("identity", _privateIdKey));
    } else {
        _title = getString(getPrefix() + ".edit.title", model);
    }

    Form form = new Form("form", new CompoundPropertyModel(model));
    add(form);

    form.add(new Label("title", String.valueOf(uss.getId())));
    form.add(new DropDownChoice("nafGroup", new LoadableDetachableModel() {
        @Override
        protected Object load() {
            return _nafGroupDao.getAllGroups();
        }
    }, new ChoiceRenderer<NafGroup>() {
        @Override
        public Object getDisplayValue(NafGroup nafGroup) {
            return nafGroup.getName();
        }

    }));

    DropDownChoice typeChoice = new DropDownChoice("type",
            Arrays.asList(new Integer[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }),
            new ChoiceRenderer<Integer>() {
                @Override
                public Object getDisplayValue(Integer type) {
                    return Uss.getTypeAsString(type);
                }

            });
    form.add(typeChoice);

    typeChoice.setRequired(true);
    typeChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            final Integer type = (Integer) getPage().get("form:type").getDefaultModelObject();
            DropDownChoice flagSelect = (DropDownChoice) getPage().get("form:flagSelect");
            Component flagInput = getPage().get("form:flagInput");

            Integer flag = getFlag2(flagInput, flagSelect);

            if (Uss.getDefinedFlagList(type) != null) {
                flagInput.setVisible(false);
                flagSelect.setChoiceRenderer(new ChoiceRenderer<Integer>() {
                    @Override
                    public Object getDisplayValue(Integer flag) {
                        return Uss.getFlagAsString(type, flag);
                    }

                });
                flagSelect.setChoices(Arrays.asList(Uss.getDefinedFlagList(type)));
                flagSelect.setVisible(true);
            } else {
                flagInput.setVisible(true);
                flagInput.setDefaultModelObject(flag);
                flagSelect.setVisible(false);
            }
            target.addComponent(flagInput);
            target.addComponent(flagSelect);
        }
    });

    final Integer type = uss.getType();

    Component flagInput = new TextField<Integer>("flagInput", new Model<Integer>(uss.getFlag()), Integer.class);
    form.add(flagInput);
    flagInput.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true);

    DropDownChoice<Integer> flagSelect = new DropDownChoice<Integer>("flagSelect",
            new Model<Integer>(uss.getFlag()), Collections.EMPTY_LIST);
    form.add(flagSelect);
    flagSelect.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true);

    if (Uss.getDefinedFlagList(type) != null) {
        flagSelect.setChoiceRenderer(new ChoiceRenderer<Integer>() {
            @Override
            public Object getDisplayValue(Integer flag) {
                return Uss.getFlagAsString(type, flag);
            }

        });
        flagSelect.setChoices(Arrays.asList(Uss.getDefinedFlagList(type)));
        flagInput.setVisible(false);
    } else {
        flagSelect.setVisible(false);
    }

    form.add(new Button("submit") {
        @Override
        public void onSubmit() {
            try {
                Uss uss = (Uss) getForm().getModelObject();

                if (_privateIdKey != null) {
                    PrivateIdentity privateIdentity = _privateIdentityDao.findById(_privateIdKey);
                    if (privateIdentity != null)
                        uss.setPrivateIdentity(privateIdentity);
                }
                uss.setFlag(getFlag2(getForm().get("flagInput"), getForm().get("flagSelect")));

                _dao.save(uss);

                getSession().info(getString("modification.success"));
                setResponsePage(UssBrowserPage.class,
                        new PageParameters("privateId=" + uss.getPrivateIdentity().getIdentity()));
            } catch (Exception e) {
                __log.debug("Failed to apply edit", e);
                getSession().error(getString("uss.error", getForm().getModel()));
            }
        }
    });

    form.add(new Button("cancel") {
        @Override
        public void onSubmit() {
            getSession().info(getString("modification.cancel"));
            setResponsePage(UssBrowserPage.class, new PageParameters("privateId=" + _privateIdKey));
        }
    }.setDefaultFormProcessing(false));

    form.add(new Button("delete") {
        @Override
        public void onSubmit() {
            Uss uss = _dao.findById(_key);
            setResponsePage(UssBrowserPage.class, new PageParameters("privateId=" + _privateIdKey));
            _dao.delete(uss);
            getSession().info(getString(getPrefix() + ".delete.done", new DaoDetachableModel(uss)));

        }
    }.setDefaultFormProcessing(false).setVisible(!isAdding()));

    if (privateIdentity != null) {
        setContextMenu(new ContextPanel(privateIdentity));
    }

}

From source file:org.cipango.ims.oam.util.HideableLink.java

License:Apache License

public HideableLink(String id, Component parent) {
    super(id);/*  ww  w  . j  ava 2 s  . c  o  m*/
    parent.setOutputMarkupId(true);
    _markupId = parent.getMarkupId();
    setOutputMarkupId(true);
}

From source file:org.cipango.littleims.pcscf.oam.browser.DebugSessionPanel.java

License:Apache License

@SuppressWarnings("unchecked")
public DebugSessionPanel(String id, final DebugSession debugSession) {
    super(id);// w  w  w .j a  v  a  2 s .  co m
    add(new Label("debugId", debugSession.getDebugId()));
    add(new Label("startTrigger", debugSession.getStartTriggerAsString()));
    add(new Label("stopTrigger", debugSession.getStoptTriggerAsString()));
    add(new HideableLink("hideLink", this));
    _debugId = debugSession.getDebugId();
    refreshLog();

    AjaxFallbackLink viewLink = new AjaxFallbackLink("viewLog") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            _viewLog = true;
            refreshLog();
            Component hideLink = getParent().get("hideLog");
            hideLink.setVisible(true);
            Component refresh = new Label("view", "Refresh log").setOutputMarkupId(true);
            replace(refresh);
            if (target != null) {
                target.addComponent(getParent().get("content"));
                target.addComponent(hideLink);
                target.addComponent(refresh);
            }
        }
    };
    add(viewLink);
    viewLink.setOutputMarkupId(true);
    viewLink.add(new Label("view", "View log").setOutputMarkupId(true));

    AjaxFallbackLink hideLink = new AjaxFallbackLink("hideLog") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            _viewLog = false;
            setVisible(false);
            Component refresh = new Label("view", "View log").setOutputMarkupId(true);
            ((WebMarkupContainer) getParent().get("viewLog")).replace(refresh);
            refreshLog();
            if (target != null) {
                target.addComponent(getParent().get("content"));
                target.addComponent(this);
                target.addComponent(refresh);
            }
        }
    };
    add(hideLink);
    hideLink.setVisible(false);
    hideLink.setOutputMarkupId(true);
    hideLink.setOutputMarkupPlaceholderTag(true);
}

From source file:org.dcm4chee.web.common.behaviours.FocusOnLoadBehaviour.java

License:LGPL

public void bind(Component component) {
    this.component = component;
    if (focusStrategy == null) {
        if (component instanceof FormComponent<?>) {
            focusStrategy = new EmptyFocusStrategy();
        } else if (component instanceof Form<?>) {
            focusStrategy = new FirstEmptyTextfieldFocusStrategy();
        }//  w w  w  .  ja  v a 2 s.  c o m
    }
    component.setOutputMarkupId(true);
}

From source file:org.dcm4chee.web.war.common.SelectAllCheckBox.java

License:LGPL

public SelectAllCheckBox addUpdateComponent(Component c) {
    c.setOutputMarkupId(true);
    updateComponents.add(c);
    return this;
}

From source file:org.dcm4chee.web.war.common.SelectAllLink.java

License:LGPL

public SelectAllLink addUpdateComponent(Component c) {
    c.setOutputMarkupId(true);
    updateComponents.add(c);
    return this;
}

From source file:org.dcm4chee.wizard.common.behavior.FocusOnLoadBehavior.java

License:LGPL

public void bind(Component component) {
    if (focusStrategy == null) {
        if (component instanceof FormComponent<?>) {
            focusStrategy = new EmptyFocusStrategy();
        } else if (component instanceof Form<?>) {
            focusStrategy = new FirstEmptyTextfieldFocusStrategy();
        }//from   w  w  w  .j  a  v a2s . c o m
    }
    component.setOutputMarkupId(true);
}

From source file:org.efaps.ui.wicket.behaviors.dojo.AbstractDojoBehavior.java

License:Apache License

/**
 * All components using dojo must render the id of the component.
 *
 * @see org.apache.wicket.behavior.AbstractBehavior#beforeRender(org.apache.wicket.Component)
 * @param _component component//from   w  w w . j ava2 s  .com
 */
@Override
public void beforeRender(final Component _component) {
    super.beforeRender(_component);
    _component.setOutputMarkupId(true);
}

From source file:org.efaps.ui.wicket.components.picker.AjaxPickerLink.java

License:Apache License

/**
 * @param _wicketId         wicket id of this component
 * @param _model            model for this component
 * @param _targetComponent  component used as the target for this Picker
 *///from  ww w .ja  v  a 2 s  .c o  m
public AjaxPickerLink(final String _wicketId, final IModel<IPickable> _model,
        final Component _targetComponent) {
    super(_wicketId, _model);
    _targetComponent.setOutputMarkupId(true);
    add(new AjaxOpenPickerBehavior(_targetComponent.getMarkupId(true)));

}

From source file:org.efaps.ui.wicket.components.table.row.RowPanel.java

License:Apache License

/**
 * @param _wicketId wicket id for this component
 * @param _model model for this component
 * @param _tablePanel tablepanel this row is in
 * @param _updateListMenu must the listmenu be updated
 * @param _idx index of the current row//from w ww  . jav  a  2 s  . c o m
 * @throws EFapsException on error
 *
 */
public RowPanel(final String _wicketId, final IModel<UIRow> _model, final TablePanel _tablePanel,
        final boolean _updateListMenu, final int _idx) throws EFapsException {
    super(_wicketId, _model);
    final UIRow uirow = (UIRow) super.getDefaultModelObject();

    final UITable uiTable = (UITable) _tablePanel.getDefaultModelObject();
    int i = uiTable.getTableId();

    final RepeatingView cellRepeater = new RepeatingView("cellRepeater");
    add(cellRepeater);

    boolean firstCell = false;
    if (uiTable.isShowCheckBoxes()) {
        final CheckBoxField checkbox = new CheckBoxField(cellRepeater.newChildId(), uirow.getInstanceKey());
        checkbox.setOutputMarkupId(true);
        checkbox.add(AttributeModifier.append("class", "eFapsTableCheckBoxCell eFapsTableCellClear"));
        cellRepeater.add(checkbox);
        i++;
        firstCell = true;
    }
    if (uiTable.isEditable()) {
        final AjaxAddRemoveRowPanel remove = new AjaxAddRemoveRowPanel(cellRepeater.newChildId(),
                Model.of(uiTable), this);
        remove.setOutputMarkupId(true);
        remove.add(AttributeModifier.append("class", "eFapsTableRemoveRowCell eFapsTableCellClear"));
        cellRepeater.add(remove);
        i++;
        firstCell = true;
    }

    for (final IFilterable filterable : uirow.getCells()) {
        Component cell = null;
        boolean fixedWidth = false;
        if (filterable instanceof AbstractUIField) {
            fixedWidth = ((AbstractUIField) filterable).getFieldConfiguration().isFixedWidth();
            cell = new FieldPanel(cellRepeater.newChildId(), Model.of((AbstractUIField) filterable));
        }
        cell.setOutputMarkupId(true);
        if (fixedWidth) {
            if (firstCell) {
                firstCell = false;
                cell.add(AttributeModifier.append("class",
                        "eFapsTableFirstCell eFapsTableCell" + " eFapsCellFixedWidth" + i));
            } else {
                cell.add(AttributeModifier.append("class", "eFapsTableCell eFapsCellFixedWidth" + i));
            }
        } else {
            if (firstCell) {
                firstCell = false;
                cell.add(AttributeModifier.append("class",
                        "eFapsTableFirstCell eFapsTableCell" + " eFapsCellWidth" + i));
            } else {
                cell.add(AttributeModifier.append("class", "eFapsTableCell eFapsCellWidth" + i));
            }
        }
        if (cellRepeater.size() < 1) {
            cell.add(AttributeModifier.append("class", "eFapsTableCellClear"));
        }
        cellRepeater.add(cell);
        i++;
    }

    final RepeatingView hiddenRepeater = new RepeatingView("hiddenRepeater");
    this.add(hiddenRepeater);
    for (final IHidden hidden : uirow.getHidden()) {
        if (!hidden.isAdded()) {
            hiddenRepeater.add(hidden.getComponent(hiddenRepeater.newChildId()));
            hidden.setAdded(true);
        }
    }
    this.add(new RowId("rowId", Model.of((AbstractInstanceObject) uirow)));
}