Search in sources :

Example 1 with Type

use of org.apache.openmeetings.db.entity.basic.Configuration.Type in project openmeetings by apache.

the class ConfigForm method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    add(new DropDownChoice<>("type", Arrays.asList(Type.values()), new IChoiceRenderer<Type>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getIdValue(Type rt, int index) {
            return rt.name();
        }

        @Override
        public Object getDisplayValue(Type rt) {
            return rt.name();
        }

        @Override
        public Type getObject(String id, IModel<? extends List<? extends Type>> choices) {
            for (Type rt : choices.getObject()) {
                if (rt.name().equals(id)) {
                    return rt;
                }
            }
            return null;
        }
    }).setLabel(Model.of(getString("45"))).add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            update(target);
        }
    }));
    add(new RequiredTextField<String>("key").setLabel(Model.of(getString("265"))).add(new IValidator<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public void validate(IValidatable<String> validatable) {
            Configuration c = cfgDao.forceGet(validatable.getValue());
            if (c != null && !c.isDeleted() && !c.getId().equals(ConfigForm.this.getModelObject().getId())) {
                validatable.error(new ValidationError(getString("error.cfg.exist")));
            }
        }
    }));
    add(valueS.setLabel(Model.of(getString("271"))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
    add(valueN.setLabel(Model.of(getString("271"))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
    add(valueB.setLabel(Model.of(getString("271"))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IModel(org.apache.wicket.model.IModel) Configuration(org.apache.openmeetings.db.entity.basic.Configuration) IValidatable(org.apache.wicket.validation.IValidatable) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Type(org.apache.openmeetings.db.entity.basic.Configuration.Type) IValidator(org.apache.wicket.validation.IValidator) List(java.util.List) ValidationError(org.apache.wicket.validation.ValidationError)

Aggregations

List (java.util.List)1 Configuration (org.apache.openmeetings.db.entity.basic.Configuration)1 Type (org.apache.openmeetings.db.entity.basic.Configuration.Type)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)1 IChoiceRenderer (org.apache.wicket.markup.html.form.IChoiceRenderer)1 IModel (org.apache.wicket.model.IModel)1 IValidatable (org.apache.wicket.validation.IValidatable)1 IValidator (org.apache.wicket.validation.IValidator)1 ValidationError (org.apache.wicket.validation.ValidationError)1