Example usage for org.apache.wicket.markup.html.form DropDownChoice DropDownChoice

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

Introduction

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

Prototype

public DropDownChoice(final String id) 

Source Link

Document

Constructor.

Usage

From source file:au.org.theark.lims.web.component.barcodelabel.form.DetailForm.java

License:Open Source License

private void initBarcodeLabelTemplateDdc() {
    ChoiceRenderer<BarcodeLabel> choiceRenderer = new ChoiceRenderer<BarcodeLabel>("nameAndVersion",
            Constants.ID);/*from ww w.  j av  a  2  s .c o  m*/
    barcodeLabelTemplateDdc = new DropDownChoice<BarcodeLabel>("barcodeLabelTemplate") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onBeforeRender() {
            super.onBeforeRender();
            setVisible(isNew());
            List<BarcodeLabel> choices = iLimsAdminService.getBarcodeLabelTemplates();
            this.setChoices(choices);
        }
    };
    barcodeLabelTemplateDdc.setOutputMarkupPlaceholderTag(true);
    barcodeLabelTemplateDdc.setChoiceRenderer(choiceRenderer);

    barcodeLabelTemplateDdc.add(new AjaxFormComponentUpdatingBehavior("onChange") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            // Clone data from other BarcodeLabel
            if (barcodeLabelTemplateDdc.getModelObject() != null) {
                String labelPrefix = barcodeLabelTemplateDdc.getModelObject().getLabelPrefix();
                String labelSuffix = barcodeLabelTemplateDdc.getModelObject().getLabelSuffix();
                Long version = barcodeLabelTemplateDdc.getModelObject().getVersion();

                // Set default/required values
                containerForm.getModelObject().setLabelPrefix(labelPrefix);
                containerForm.getModelObject().setLabelSuffix(labelSuffix);
                containerForm.getModelObject().setVersion(version);

                exampleBarcodeDataFile.setModelObject(
                        iLimsAdminService.getBarcodeLabelTemplate(barcodeLabelTemplateDdc.getModelObject()));
                exampleBarcodeDataFile.setVisible(true);
                target.add(exampleBarcodeDataFile);

                nameTxtFld.setModelObject(barcodeLabelTemplateDdc.getModelObject().getName());
                target.add(nameTxtFld);

                versionTxtFld.setModelObject(version);
                target.add(versionTxtFld);
            }
        }
    });
}

From source file:ca.travelagency.invoice.items.ItemFormPanel.java

License:Apache License

private DropDownChoice<CommissionStatus> commissionStatusField(IModel<InvoiceItem> model) {
    DropDownChoice<CommissionStatus> commissionStatusField = new DropDownChoice<CommissionStatus>(
            InvoiceItem.Properties.commissionStatus.name());
    if (model.getObject().isCommissionVerified()) {
        commissionStatusField.setEnabled(false);
        commissionStatusField.setChoices(Lists.newArrayList(CommissionStatus.values()));
    } else {// w w w .  ja  v a2  s .  co m
        commissionStatusField.setChoices(Lists.newArrayList(CommissionStatus.NotVerified));
    }
    commissionStatusField.setLabel(new ResourceModel("itemCommissionStatus"));
    commissionStatusField.add(new FieldDecorator(), new AjaxOnBlurBehavior());
    return commissionStatusField;
}

From source file:com.tysanclan.site.projectewok.pages.forum.ForumThreadMovePage.java

License:Open Source License

public ForumThreadMovePage(ForumThread thread) {
    super("Move thread: " + thread.getTitle());

    final User u = getTysanSession() != null ? getTysanSession().getUser() : null;

    List<Forum> forums = forumService.getValidDestinationForums(thread.getForum(), u);

    final DropDownChoice<Forum> targetForum = new DropDownChoice<Forum>("target");
    targetForum.setChoices(forums);/*from  w w w.j a  v  a  2 s  .  c  o  m*/
    targetForum.setModel(ModelMaker.wrap(forums.get(0), true));
    targetForum.setChoiceRenderer(new IChoiceRenderer<Forum>() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(Forum object) {
            return object.getName();
        }

        @Override
        public String getIdValue(Forum object, int index) {
            return object.getId().toString();
        }

    });

    Form<ForumThread> form = new Form<ForumThread>("moveform", ModelMaker.wrap(thread)) {
        private static final long serialVersionUID = 1L;

        @SpringBean
        private ForumService service;

        /**
         * @see org.apache.wicket.markup.html.form.Form#onSubmit()
         */
        @Override
        protected void onSubmit() {
            if (!service.moveThread(getModelObject(), targetForum.getModelObject(), u)) {
                error("Unable to move thread: permission denied!");
                setResponsePage(new ForumThreadPage(getModelObject().getId(), 1, false));
            } else {
                setResponsePage(new ForumPage(targetForum.getModelObject()));
            }
        }

    };

    form.add(targetForum);

    form.add(new PostPanel("postpanel", thread.getPosts().get(0), false));

    form.add(new ThreadLink("no", thread));

    add(form);
}