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

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

Introduction

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

Prototype

public Radio(final String id, final IModel<T> model, final RadioGroup<T> group) 

Source Link

Usage

From source file:com.evolveum.midpoint.web.page.admin.configuration.PageImportObject.java

License:Apache License

private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);//from w  w  w .ja  v a  2 s .  co m

    ImportOptionsPanel importOptions = new ImportOptionsPanel(ID_IMPORT_OPTIONS, model);
    mainForm.add(importOptions);

    final WebMarkupContainer input = new WebMarkupContainer(ID_INPUT);
    input.setOutputMarkupId(true);
    mainForm.add(input);

    final WebMarkupContainer buttonBar = new WebMarkupContainer(ID_BUTTON_BAR);
    buttonBar.setOutputMarkupId(true);
    mainForm.add(buttonBar);

    final IModel<Integer> groupModel = new Model<Integer>(INPUT_FILE);
    RadioGroup importRadioGroup = new RadioGroup(ID_IMPORT_RADIO_GROUP, groupModel);
    importRadioGroup.add(new AjaxFormChoiceComponentUpdatingBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(input);
            target.add(buttonBar);
        }
    });
    mainForm.add(importRadioGroup);

    Radio fileRadio = new Radio(ID_FILE_RADIO, new Model(INPUT_FILE), importRadioGroup);
    importRadioGroup.add(fileRadio);

    Radio xmlRadio = new Radio(ID_XML_RADIO, new Model(INPUT_XML), importRadioGroup);
    importRadioGroup.add(xmlRadio);

    WebMarkupContainer inputAce = new WebMarkupContainer(ID_INPUT_ACE);
    addVisibileForInputType(inputAce, INPUT_XML, groupModel);
    input.add(inputAce);

    AceEditor aceEditor = new AceEditor(ID_ACE_EDITOR, xmlEditorModel);
    aceEditor.setOutputMarkupId(true);
    inputAce.add(aceEditor);

    WebMarkupContainer inputFileLabel = new WebMarkupContainer(ID_INPUT_FILE_LABEL);
    addVisibileForInputType(inputFileLabel, INPUT_FILE, groupModel);
    input.add(inputFileLabel);

    WebMarkupContainer inputFile = new WebMarkupContainer(ID_INPUT_FILE);
    addVisibileForInputType(inputFile, INPUT_FILE, groupModel);
    input.add(inputFile);

    FileUploadField fileInput = new FileUploadField(ID_FILE_INPUT);
    inputFile.add(fileInput);

    initButtons(buttonBar, groupModel);
}

From source file:com.evolveum.midpoint.web.page.admin.reports.PageNewReport.java

License:Apache License

private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);//from   www  .j  av a2s .  co  m

    final WebMarkupContainer input = new WebMarkupContainer(ID_INPUT);
    input.setOutputMarkupId(true);
    mainForm.add(input);

    final WebMarkupContainer buttonBar = new WebMarkupContainer(ID_BUTTON_BAR);
    buttonBar.setOutputMarkupId(true);
    mainForm.add(buttonBar);

    final IModel<Integer> groupModel = new Model<Integer>(INPUT_FILE);
    RadioGroup importRadioGroup = new RadioGroup(ID_IMPORT_RADIO_GROUP, groupModel);
    importRadioGroup.add(new AjaxFormChoiceComponentUpdatingBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(input);
            target.add(buttonBar);
        }
    });
    mainForm.add(importRadioGroup);

    Radio fileRadio = new Radio(ID_FILE_RADIO, new Model(INPUT_FILE), importRadioGroup);
    importRadioGroup.add(fileRadio);

    Radio xmlRadio = new Radio(ID_XML_RADIO, new Model(INPUT_XML), importRadioGroup);
    importRadioGroup.add(xmlRadio);

    WebMarkupContainer inputAce = new WebMarkupContainer(ID_INPUT_ACE);
    addVisibileForInputType(inputAce, INPUT_XML, groupModel);
    input.add(inputAce);

    AceEditor aceEditor = new AceEditor(ID_ACE_EDITOR, xmlEditorModel);
    aceEditor.setOutputMarkupId(true);
    inputAce.add(aceEditor);

    WebMarkupContainer inputFileLabel = new WebMarkupContainer(ID_INPUT_FILE_LABEL);
    addVisibileForInputType(inputFileLabel, INPUT_FILE, groupModel);
    input.add(inputFileLabel);

    WebMarkupContainer inputFile = new WebMarkupContainer(ID_INPUT_FILE);
    addVisibileForInputType(inputFile, INPUT_FILE, groupModel);
    input.add(inputFile);

    FileUploadField fileInput = new FileUploadField(ID_FILE_INPUT);
    inputFile.add(fileInput);

    initButtons(buttonBar, groupModel);
}

From source file:com.premiumminds.wicket.crudifier.form.elements.EnumControlGroup.java

License:Open Source License

@Override
protected void onInitialize() {
    super.onInitialize();

    try {//from   w w  w  .j  av  a 2s .c  om
        Method method = getType().getMethod("values");
        @SuppressWarnings("unchecked")
        T[] values = (T[]) method.invoke(null);

        RepeatingView view = new RepeatingView("repeating");
        for (T value : values) {
            Radio<T> radio = new Radio<T>("input", Model.of(value), radioGroup) {
                private static final long serialVersionUID = 8903955236018583915L;

                @Override
                public String getValue() {
                    return getModel().getObject().name();
                }

                @Override
                protected boolean getStatelessHint() {
                    return true;
                }
            };
            radio.add(new Label("label", new StringResourceModel(getPropertyName() + "." + value.name(),
                    getResourceBase(), getModel(), value.name())));

            view.add(new WebMarkupContainer(view.newChildId()).add(radio));
        }

        radioGroup.add(view);

        add(new BootstrapControlGroupFeedback("controlGroup").add(radioGroup)
                .add(new Label("label", new StringResourceModel(getPropertyName() + ".label", getResourceBase(),
                        getModel(), getPropertyName()))));
    } catch (SecurityException e) {
        throw new RuntimeException(e);
    } catch (NoSuchMethodException e) {
        throw new RuntimeException(e);
    } catch (IllegalArgumentException e) {
        throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.forms.ScenarioForm.java

License:Apache License

public ScenarioForm(String id, final ModalWindow window) {
    super(id, new CompoundPropertyModel<Scenario>(new Scenario()));

    add(new Label("addScenarioHeader", ResourceUtils.getModel("pageTitle.addScenario")));

    final FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);//from  w  w  w. j a v  a  2s.c om
    add(feedback);

    setMultiPart(true);

    Person owner = getModel().getObject().getPerson();
    if (owner == null)
        owner = EEGDataBaseSession.get().getLoggedUser();

    getModel().getObject().setPerson(owner);

    List<ResearchGroup> choices = researchGroupFacade.getResearchGroupsWhereAbleToWriteInto(owner);
    if (choices == null || choices.isEmpty())
        choices = Arrays.asList(getModel().getObject().getResearchGroup());

    DropDownChoice<ResearchGroup> groups = new DropDownChoice<ResearchGroup>("researchGroup", choices,
            new ChoiceRenderer<ResearchGroup>("title"));
    groups.setRequired(true);

    TextField<String> title = new TextField<String>("title");
    title.setLabel(ResourceUtils.getModel("label.scenarioTitle"));
    title.setRequired(true);
    // title.add(new TitleExistsValidator());

    TextField<Integer> length = new TextField<Integer>("scenarioLength", Integer.class);
    length.setRequired(true);
    length.add(RangeValidator.minimum(0));

    TextArea<String> description = new TextArea<String>("description");
    description.setRequired(true);
    description.setLabel(ResourceUtils.getModel("label.scenarioDescription"));

    final WebMarkupContainer fileContainer = new WebMarkupContainer("contailer");
    fileContainer.setVisibilityAllowed(false);
    fileContainer.setOutputMarkupPlaceholderTag(true);

    /*
     * TODO file field for xml was not visible in old portal. I dont know why. So I hided it but its implemented and not tested.
     */
    // hidded line in old portal
    final DropDownChoice<ScenarioSchemas> schemaList = new DropDownChoice<ScenarioSchemas>("schemaList",
            new Model<ScenarioSchemas>(), scenariosFacade.getListOfScenarioSchemas(),
            new ChoiceRenderer<ScenarioSchemas>("schemaName", "schemaId"));
    schemaList.setOutputMarkupPlaceholderTag(true);
    schemaList.setRequired(true);
    schemaList.setLabel(ResourceUtils.getModel("label.scenarioSchema"));
    schemaList.setVisibilityAllowed(false);

    final FileUploadField file = new FileUploadField("file", new ListModel<FileUpload>());
    file.setOutputMarkupId(true);
    file.setLabel(ResourceUtils.getModel("description.fileType.dataFile"));
    file.setOutputMarkupPlaceholderTag(true);

    // hidded line in old portal
    final FileUploadField xmlfile = new FileUploadField("xmlfile", new ListModel<FileUpload>());
    xmlfile.setOutputMarkupId(true);
    xmlfile.setLabel(ResourceUtils.getModel("label.xmlDataFile"));
    xmlfile.setOutputMarkupPlaceholderTag(true);
    xmlfile.setVisibilityAllowed(false);

    // hidded line in old portal
    final RadioGroup<Boolean> schema = new RadioGroup<Boolean>("schema", new Model<Boolean>(Boolean.FALSE));
    schema.add(new Radio<Boolean>("noschema", new Model<Boolean>(Boolean.FALSE), schema));
    schema.add(new Radio<Boolean>("fromschema", new Model<Boolean>(Boolean.TRUE), schema));
    schema.setOutputMarkupPlaceholderTag(true);
    schema.setVisibilityAllowed(false);
    schema.add(new AjaxFormChoiceComponentUpdatingBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            schemaList.setVisibilityAllowed(schema.getModelObject());
            xmlfile.setRequired(!xmlfile.isRequired());

            target.add(xmlfile);
            target.add(schemaList);
        }
    });

    CheckBox privateCheck = new CheckBox("privateScenario");
    final CheckBox dataAvailable = new CheckBox("dataAvailable", new Model<Boolean>());
    dataAvailable.add(new AjaxFormComponentUpdatingBehavior("onChange") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {

            fileContainer.setVisibilityAllowed(dataAvailable.getModelObject());
            file.setRequired(!file.isRequired());
            target.add(fileContainer);
        }
    });

    fileContainer.add(file, xmlfile, schema, schemaList);

    add(groups, title, length, description, privateCheck, dataAvailable, fileContainer);

    add(new AjaxButton("submitForm", this) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

            FileUpload uploadedFile = file.getFileUpload();
            Scenario scenario = ScenarioForm.this.getModelObject();

            if (!scenariosFacade.canSaveTitle(scenario.getTitle(), scenario.getScenarioId())) {
                error(ResourceUtils.getString("error.titleAlreadyInDatabase"));
                target.add(feedback);
                return;
            } else {
                // loading non-XML scenario file
                if ((uploadedFile != null) && (!(uploadedFile.getSize() == 0))) {

                    String name = uploadedFile.getClientFileName();
                    // when uploading from localhost some browsers will specify the entire path, we strip it
                    // down to just the file name
                    name = Strings.lastPathComponent(name, '/');
                    name = Strings.lastPathComponent(name, '\\');

                    // File uploaded
                    String filename = name.replace(" ", "_");
                    scenario.setScenarioName(filename);

                    scenario.setMimetype(uploadedFile.getContentType());
                    try {
                        scenario.setFileContentStream(uploadedFile.getInputStream());
                    } catch (IOException e) {
                        log.error(e.getMessage(), e);
                        error("Error while saving data.");
                        target.add(feedback);
                    }
                }

                // Creating new
                scenariosFacade.create(scenario);

                /*
                 * clean up after upload file, and set model to null or will be problem with page serialization when redirect start - DON'T DELETE IT !
                 */
                ScenarioForm.this.setModelObject(null);

                window.close(target);
            }
        }

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

            target.add(feedback);
        }
    });

    add(new AjaxButton("closeForm", ResourceUtils.getModel("button.close")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            window.close(target);
        }
    }.setDefaultFormProcessing(false));

    setOutputMarkupId(true);
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.scenarios.form.ScenarioForm.java

License:Apache License

public ScenarioForm(String id, IModel<Scenario> model, final FeedbackPanel feedback) {

    super(id, new CompoundPropertyModel<Scenario>(model));

    setMultiPart(true);//from w w w  .  j a  v  a 2  s.  co  m

    Person owner = model.getObject().getPerson();
    if (owner == null) {
        owner = EEGDataBaseSession.get().getLoggedUser();
    }

    model.getObject().setPerson(owner);

    List<ResearchGroup> choices = researchGroupFacade.getResearchGroupsWhereAbleToWriteInto(owner);
    if (choices == null || choices.isEmpty()) {
        choices = Arrays.asList(model.getObject().getResearchGroup());
    }

    DropDownChoice<ResearchGroup> groups = new DropDownChoice<ResearchGroup>("researchGroup", choices,
            new ChoiceRenderer<ResearchGroup>("title"));
    groups.setRequired(true);

    TextField<String> title = new TextField<String>("title");
    title.setLabel(ResourceUtils.getModel("label.scenarioTitle"));
    title.setRequired(true);

    TextField<Integer> length = new TextField<Integer>("scenarioLength", Integer.class);
    length.setRequired(true);
    length.add(RangeValidator.minimum(0));

    TextArea<String> description = new TextArea<String>("description");
    description.setRequired(true);
    description.setLabel(ResourceUtils.getModel("label.scenarioDescription"));

    final WebMarkupContainer fileContainer = new WebMarkupContainer("contailer");
    fileContainer.setVisibilityAllowed(false);
    fileContainer.setOutputMarkupPlaceholderTag(true);

    /*
     * TODO file field for xml was not visible in old portal. I dont know why. So I hided it but its implemented and not tested.
     */
    // hidded line in old portal
    final DropDownChoice<ScenarioSchemas> schemaList = new DropDownChoice<ScenarioSchemas>("schemaList",
            new Model<ScenarioSchemas>(), scenariosFacade.getListOfScenarioSchemas(),
            new ChoiceRenderer<ScenarioSchemas>("schemaName", "schemaId"));
    schemaList.setOutputMarkupPlaceholderTag(true);
    schemaList.setRequired(true);
    schemaList.setLabel(ResourceUtils.getModel("label.scenarioSchema"));
    schemaList.setVisibilityAllowed(false);

    final FileUploadField file = new FileUploadField("file", new ListModel<FileUpload>());
    file.setOutputMarkupId(true);
    file.setLabel(ResourceUtils.getModel("description.fileType.dataFile"));
    file.setOutputMarkupPlaceholderTag(true);

    // hidded line in old portal
    final FileUploadField xmlfile = new FileUploadField("xmlfile", new ListModel<FileUpload>());
    xmlfile.setOutputMarkupId(true);
    xmlfile.setLabel(ResourceUtils.getModel("label.xmlDataFile"));
    xmlfile.setOutputMarkupPlaceholderTag(true);
    xmlfile.setVisibilityAllowed(false);

    // hidded line in old portal
    final RadioGroup<Boolean> schema = new RadioGroup<Boolean>("schema", new Model<Boolean>(Boolean.FALSE));
    schema.add(new Radio<Boolean>("noschema", new Model<Boolean>(Boolean.FALSE), schema));
    schema.add(new Radio<Boolean>("fromschema", new Model<Boolean>(Boolean.TRUE), schema));
    schema.setOutputMarkupPlaceholderTag(true);
    schema.setVisibilityAllowed(false);
    schema.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            schemaList.setVisibilityAllowed(schema.getModelObject());
            xmlfile.setRequired(!xmlfile.isRequired());

            target.add(xmlfile);
            target.add(schemaList);
        }
    });

    CheckBox privateCheck = new CheckBox("privateScenario");
    final CheckBox dataAvailable = new CheckBox("dataAvailable", new Model<Boolean>());
    dataAvailable.add(new AjaxFormComponentUpdatingBehavior("onChange") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {

            fileContainer.setVisibilityAllowed(dataAvailable.getModelObject());
            file.setRequired(!file.isRequired());
            target.add(fileContainer);
        }
    });

    SubmitLink submit = new SubmitLink("submit") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {

            FileUpload uploadedFile = file.getFileUpload();
            Scenario scenario = ScenarioForm.this.getModelObject();

            if (!scenariosFacade.canSaveTitle(scenario.getTitle(), scenario.getScenarioId())) {
                error(ResourceUtils.getString("error.titleAlreadyInDatabase"));
                return;
            } else {
                // loading non-XML scenario file
                if ((uploadedFile != null) && (!(uploadedFile.getSize() == 0))) {

                    String name = uploadedFile.getClientFileName();
                    // when uploading from localhost some browsers will specify the entire path, we strip it
                    // down to just the file name
                    name = Strings.lastPathComponent(name, '/');
                    name = Strings.lastPathComponent(name, '\\');

                    // File uploaded
                    String filename = name.replace(" ", "_");
                    scenario.setScenarioName(filename);

                    scenario.setMimetype(uploadedFile.getContentType());
                    try {
                        scenario.setFileContentStream(uploadedFile.getInputStream());
                    } catch (IOException e) {
                        log.error(e.getMessage(), e);
                    }
                }

                if (scenario.getScenarioId() > 0) {
                    // Editing existing
                    // scenarioTypeDao.update(scenarioType);
                    scenariosFacade.update(scenario);
                } else {
                    // Creating new
                    scenariosFacade.create(scenario);
                }
                /*
                 * clean up after upload file, and set model to null or will be problem with page serialization when redirect start - DON'T DELETE IT !
                 */
                ScenarioForm.this.setModelObject(null);

                setResponsePage(ScenarioDetailPage.class,
                        PageParametersUtils.getDefaultPageParameters(scenario.getScenarioId()));
            }

        }
    };

    fileContainer.add(file, xmlfile, schema, schemaList);

    add(groups, title, length, description, privateCheck, dataAvailable, submit, fileContainer);
}

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.j ava 2  s . co m*/
    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// www  .ja  v  a  2  s  .c  om
 *            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:jp.go.nict.langrid.management.web.view.page.admin.GridSettingsPage.java

License:Open Source License

/**
 * //from   w w  w. j a v a2s .com
 * 
 */
public GridSettingsPage() {
    AbstractForm<String> form = new AbstractForm<String>("form", getSelfGridId()) {
        @Override
        protected void addComponents(String initialParameter) throws ServiceManagerException {
            GridService service = ServiceFactory.getInstance().getGridService();

            rg = new RadioGroup<Boolean>("radioGroup", new Model<Boolean>(service.isCommercialUse()));
            add(rg);
            Radio<Boolean> permit = new Radio<Boolean>("permit", new Model<Boolean>(true), rg);
            Radio<Boolean> prohibit = new Radio<Boolean>("prohibit", new Model<Boolean>(false), rg);
            rg.add(permit);
            rg.add(prohibit);

            add(autoApprove = new CheckBox("autoApprove", new Model<Boolean>(service.isAutoApproveEnabled())));

            limits = new RepeatingView("limits");
            add(wmc = new WebMarkupContainer("limitsContainer"));
            wmc.add(limits);
            wmc.setOutputMarkupId(true);
            add(day);

            int expired = service.getPasswordExpiredDay();

            day.setModelObject(expired);
            add(submit = new AjaxNonSubmitLink("more") {
                @Override
                protected void onSubmit(AjaxRequestTarget target, Form form) {
                    Iterator it = limits.iterator();
                    while (it.hasNext()) {
                        AccessLimitFieldPanel alc = (AccessLimitFieldPanel) it.next();
                        alc.setPeriodValueByInput();
                        alc.setCountByInput();
                    }
                    moreClicked();
                    target.addComponent(wmc);
                }

                private static final long serialVersionUID = 1L;
            });
            submit.setDefaultFormProcessing(false);

            add(clear = new AjaxNonSubmitLink("clear") {
                @Override
                protected void onSubmit(AjaxRequestTarget target, Form form) {
                    limits.removeAll();
                    moreClicked();
                    target.addComponent(wmc);
                }

                private static final long serialVersionUID = 1L;
            });
            clear.setDefaultFormProcessing(false);

            add(new Button("set") {
                @Override
                public void onSubmit() {
                    try {
                        ServiceFactory.getInstance().getGridService().setCommercialUse(rg.getModelObject());
                        if (autoApprove.getConvertedInput() == Boolean.TRUE) {
                            ServiceFactory.getInstance().getGridService().setAutoApproveEnabled(true);
                        } else {
                            ServiceFactory.getInstance().getGridService().setAutoApproveEnabled(false);
                        }
                        OveruseLimitControlService service = ServiceFactory.getInstance()
                                .getOveruseLimitControlService(getSelfGridId(), getSessionUserId());
                        service.clearAll();
                        Iterator it = limits.iterator();
                        while (it.hasNext()) {
                            AccessLimitFieldPanel alfp = (AccessLimitFieldPanel) it.next();
                            Integer lc = alfp.getCount().getConvertedInput();
                            if (lc == null) {
                                continue;
                            }
                            if (alfp.getType().getSelectedType().equals(LimitType.CAPACITY)) {
                                lc *= transferredSizeScale;
                            }
                            AccessLimitControlModel model = new AccessLimitControlModel();
                            model.setLimitCount(lc);
                            model.setLimitType(alfp.getType().getSelectedType());
                            model.setPeriod(alfp.getPeriod().getSelectedPeriod());
                            service.add(model);
                            LogWriter
                                    .writeInfo(getSessionUserId(),
                                            "Accesse limit of service to all has been changed to \""
                                                    + alfp.getCount().getConvertedInput()
                                                    + (alfp.getType().getSelectedType()
                                                            .equals(LimitType.FREQUENCY) ? "hits" : "KB")
                                                    + "/" + alfp.getPeriod().getSelectedString() + "\"",
                                            getPage().getClass());
                        }
                        ServiceFactory.getInstance().getGridService()
                                .setPasswordExpiredDay(day.getConvertedInput());
                        LogWriter.writeInfo(getSessionUserId(),
                                "Period for changing password has been changed to \""
                                        + day.getModelObject() == null ? "-" : day.getModelObject() + "\" days",
                                getPage().getClass());
                    } catch (ServiceManagerException e) {
                        doErrorProcess(e);
                    }
                }

                private static final long serialVersionUID = 1L;
            });
        }

        @Override
        protected void setResultPage(String resultParameter) {
            setResponsePage(new GridSettingsResultPage(day.getModelObject(), limits));
        }

        private static final long serialVersionUID = 1L;
    };
    form.add(new AccessLimitValidator(limits));
    add(form);
    loadLimits();
}

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  ww . j  a v  a2  s. 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/*ww  w  . j  av  a2  s .c  o 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);
}