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

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

Introduction

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

Prototype

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

Source Link

Usage

From source file:ch.bd.qv.quiz.panels.RadioQuestionPanel.java

License:Apache License

public RadioQuestionPanel(String inner, RadioQuestion bq) {
    super(inner, bq);
    this.radioQuestion = bq;
    RadioGroup<String> rg = new RadioGroup<>("radiogroup", input);
    rg.add(new ListView<String>("repeater", Lists.newArrayList(bq.getAnswerKeys())) {

        @Override//from   w  w w.j a  va2s .c om
        protected void populateItem(ListItem<String> item) {
            item.add(new Radio("radio", item.getModel()));
            item.add(new Label("radio_label", new ResourceModel(item.getModelObject())));
        }
    });
    rg.setRequired(true);
    add(rg);
}

From source file:com.cubeia.backoffice.web.user.UserReportPanel.java

License:Open Source License

public UserReportPanel(String id, final ModalWindow modal) {
    super(id);/*from   w  ww.j  a  v a 2 s  . c  o m*/

    Form<?> form = new Form<Void>("form");
    form.setOutputMarkupId(true);
    form.add(new AjaxSubmitLink("reportLink", form) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            String url = getRequest().getContextPath() + "reportbuilder/reports/users/?format=" + format;
            target.appendJavaScript("document.location = '" + url + "'");
            modal.close(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            // nothing to do here...
        }
    });

    RadioGroup<String> formatGroup = new RadioGroup<String>("formatGroup",
            new PropertyModel<String>(this, "format"));
    formatGroup.add(new Radio<String>("csv", Model.of("csv")));
    formatGroup.add(new Radio<String>("xls", Model.of("xls")));
    formatGroup.add(new Radio<String>("pdf", Model.of("pdf")));
    form.add(formatGroup);
    add(form);
}

From source file:com.cubeia.backoffice.web.wallet.TransactionList.java

License:Open Source License

/**
* Constructor that is invoked when page is invoked without a session.
* 
* @param parameters// w  ww.  ja  v  a 2s. c o m
*            Page parameters
*/
public TransactionList(final PageParameters parameters) {
    long accountIdParam = parameters.get(PARAM_ACCOUNT_ID).toLong(-1);
    long userIdParam = parameters.get("userId").toLong(-1);
    if (accountIdParam != -1) {
        setId1(accountIdParam);
        setId1ByUserId(false);
        setId1Direction(DEBIT_CREDIT.BOTH);
    } else if (userIdParam != -1) {
        setId1(userIdParam);
        setId1ByUserId(true);
        setId1Direction(DEBIT_CREDIT.BOTH);
    }

    Form<TransactionList> searchForm = new Form<TransactionList>("searchForm",
            new CompoundPropertyModel<TransactionList>(this));

    searchForm.add(new TextField<Long>("id1"));
    searchForm.add(new TextField<Long>("id2"));

    RadioGroup<Boolean> id1RadioGroup = new RadioGroup<Boolean>("id1Group",
            new PropertyModel<Boolean>(this, "id1ByUserId"));
    id1RadioGroup.add(new Radio<Boolean>("id1ByUser", new Model<Boolean>(Boolean.TRUE)));
    id1RadioGroup.add(new Radio<Boolean>("id1ByAccount", new Model<Boolean>(Boolean.FALSE)));
    searchForm.add(id1RadioGroup);

    RadioGroup<Boolean> id2RadioGroup = new RadioGroup<Boolean>("id2Group",
            new PropertyModel<Boolean>(this, "id2ByUserId"));
    id2RadioGroup.add(new Radio<Boolean>("id2ByUser", new Model<Boolean>(Boolean.TRUE)));
    id2RadioGroup.add(new Radio<Boolean>("id2ByAccount", new Model<Boolean>(Boolean.FALSE)));
    searchForm.add(id2RadioGroup);

    DateField startDatePicker = new DateField("startDate", new PropertyModel<Date>(this, "startDate"));
    searchForm.add(startDatePicker);
    DateField endDatePicker = new DateField("endDate", new PropertyModel<Date>(this, "endDate"));
    searchForm.add(endDatePicker);

    searchForm.add(new DropDownChoice<DEBIT_CREDIT>("id1Direction",
            new PropertyModel<DEBIT_CREDIT>(this, "id1Direction"), Arrays.asList(DEBIT_CREDIT.values())));
    searchForm.add(new DropDownChoice<DEBIT_CREDIT>("id2Direction",
            new PropertyModel<DEBIT_CREDIT>(this, "id2Direction"), Arrays.asList(DEBIT_CREDIT.values())));

    add(searchForm);
    add(new FeedbackPanel("feedback"));

    ISortableDataProvider<Transaction, String> dataProvider = new TxDataProvider();
    List<IColumn<Transaction, String>> columns = new ArrayList<IColumn<Transaction, String>>();

    columns.add(new PropertyColumn<Transaction, String>(Model.of("Tx Id"), TransactionsOrder.ID.name(), "id") {
        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<Transaction>> item, String componentId,
                IModel<Transaction> model) {
            Transaction tx = (Transaction) model.getObject();
            Long txId = tx.getId();
            PageParameters pageParams = new PageParameters();
            pageParams.set("transactionId", txId);
            item.add(new LabelLinkPanel(componentId, "" + txId, "transaction details for tx id " + txId,
                    TransactionInfo.class, pageParams));
        }
    });
    columns.add(new DatePropertyColumn<Transaction, String>(new Model<String>("Date"), "timestamp"));
    columns.add(new PropertyColumn<Transaction, String>(Model.of("Comment"), "comment"));
    columns.add(new TxEntryColumn(new Model<String>("Entries")));

    AjaxFallbackDefaultDataTable<Transaction, String> txTable = new AjaxFallbackDefaultDataTable<Transaction, String>(
            "txTable", columns, dataProvider, 20);
    add(txTable);
}

From source file:com.cubeia.games.poker.admin.wicket.pages.wallet.TransactionList.java

License:Open Source License

/**
* Constructor that is invoked when page is invoked without a session.
* 
* @param parameters/* ww w  .jav  a  2  s  .co m*/
*            Page parameters
*/
public TransactionList(final PageParameters parameters) {
    super(parameters);
    long accountIdParam = parameters.get(PARAM_ACCOUNT_ID).toLong(-1);
    long userIdParam = parameters.get("userId").toLong(-1);
    if (accountIdParam != -1) {
        setId1(accountIdParam);
        setId1ByUserId(false);
        setId1Direction(DEBIT_CREDIT.BOTH);
    } else if (userIdParam != -1) {
        setId1(userIdParam);
        setId1ByUserId(true);
        setId1Direction(DEBIT_CREDIT.BOTH);
    }

    Form<TransactionList> searchForm = new Form<TransactionList>("searchForm",
            new CompoundPropertyModel<TransactionList>(this));

    searchForm.add(new TextField<Long>("id1"));
    searchForm.add(new TextField<Long>("id2"));

    RadioGroup<Boolean> id1RadioGroup = new RadioGroup<Boolean>("id1Group",
            new PropertyModel<Boolean>(this, "id1ByUserId"));
    id1RadioGroup.add(new Radio<Boolean>("id1ByUser", new Model<Boolean>(Boolean.TRUE)));
    id1RadioGroup.add(new Radio<Boolean>("id1ByAccount", new Model<Boolean>(Boolean.FALSE)));
    searchForm.add(id1RadioGroup);

    RadioGroup<Boolean> id2RadioGroup = new RadioGroup<Boolean>("id2Group",
            new PropertyModel<Boolean>(this, "id2ByUserId"));
    id2RadioGroup.add(new Radio<Boolean>("id2ByUser", new Model<Boolean>(Boolean.TRUE)));
    id2RadioGroup.add(new Radio<Boolean>("id2ByAccount", new Model<Boolean>(Boolean.FALSE)));
    searchForm.add(id2RadioGroup);

    DateField startDatePicker = new DateField("startDate", new PropertyModel<Date>(this, "startDate"));
    searchForm.add(startDatePicker);
    DateField endDatePicker = new DateField("endDate", new PropertyModel<Date>(this, "endDate"));
    searchForm.add(endDatePicker);

    searchForm.add(new DropDownChoice<DEBIT_CREDIT>("id1Direction",
            new PropertyModel<DEBIT_CREDIT>(this, "id1Direction"), Arrays.asList(DEBIT_CREDIT.values())));
    searchForm.add(new DropDownChoice<DEBIT_CREDIT>("id2Direction",
            new PropertyModel<DEBIT_CREDIT>(this, "id2Direction"), Arrays.asList(DEBIT_CREDIT.values())));

    add(searchForm);
    add(new FeedbackPanel("feedback"));

    ISortableDataProvider<Transaction, String> dataProvider = new TxDataProvider();
    List<IColumn<Transaction, String>> columns = new ArrayList<IColumn<Transaction, String>>();

    columns.add(new PropertyColumn<Transaction, String>(Model.of("Tx Id"), TransactionsOrder.ID.name(), "id") {
        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<Transaction>> item, String componentId,
                IModel<Transaction> model) {
            Transaction tx = (Transaction) model.getObject();
            Long txId = tx.getId();
            PageParameters pageParams = new PageParameters();
            pageParams.set("transactionId", txId);
            item.add(new LabelLinkPanel(componentId, "" + txId, "transaction details for tx id " + txId,
                    TransactionInfo.class, pageParams));
        }
    });
    columns.add(new DatePropertyColumn<Transaction, String>(new Model<String>("Date"), "timestamp"));
    columns.add(new PropertyColumn<Transaction, String>(Model.of("Comment"), "comment"));
    columns.add(new TxEntryColumn(new Model<String>("Entries")));

    AjaxFallbackDefaultDataTable<Transaction, String> txTable = new AjaxFallbackDefaultDataTable<Transaction, String>(
            "txTable", columns, dataProvider, 20);
    add(txTable);
}

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 va  2s  . c  om*/

    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 ww w .  ja  va  2s  . c o  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.gitblit.wicket.panels.AccessPolicyPanel.java

License:Apache License

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

    AccessPolicy anonymousPolicy = new AccessPolicy(getString("gb.anonymousPolicy"),
            getString("gb.anonymousPolicyDescription"), "blank.png", AuthorizationControl.AUTHENTICATED,
            AccessRestrictionType.NONE);

    AccessPolicy authenticatedPushPolicy = new AccessPolicy(getString("gb.authenticatedPushPolicy"),
            getString("gb.authenticatedPushPolicyDescription"), "lock_go_16x16.png",
            AuthorizationControl.AUTHENTICATED, AccessRestrictionType.PUSH);

    AccessPolicy namedPushPolicy = new AccessPolicy(getString("gb.namedPushPolicy"),
            getString("gb.namedPushPolicyDescription"), "lock_go_16x16.png", AuthorizationControl.NAMED,
            AccessRestrictionType.PUSH);

    AccessPolicy clonePolicy = new AccessPolicy(getString("gb.clonePolicy"),
            getString("gb.clonePolicyDescription"), "lock_pull_16x16.png", AuthorizationControl.NAMED,
            AccessRestrictionType.CLONE);

    AccessPolicy viewPolicy = new AccessPolicy(getString("gb.viewPolicy"),
            getString("gb.viewPolicyDescription"), "shield_16x16.png", AuthorizationControl.NAMED,
            AccessRestrictionType.VIEW);

    List<AccessPolicy> policies = new ArrayList<AccessPolicy>();
    if (app().settings().getBoolean(Keys.git.allowAnonymousPushes, false)) {
        policies.add(anonymousPolicy);//from   w  w w . j  a va2s.  c o m
    }
    policies.add(authenticatedPushPolicy);
    policies.add(namedPushPolicy);
    policies.add(clonePolicy);
    policies.add(viewPolicy);

    AccessRestrictionType defaultRestriction = repository.accessRestriction;
    if (defaultRestriction == null) {
        defaultRestriction = AccessRestrictionType.fromName(app().settings()
                .getString(Keys.git.defaultAccessRestriction, AccessRestrictionType.PUSH.name()));
    }

    AuthorizationControl defaultControl = repository.authorizationControl;
    if (defaultControl == null) {
        defaultControl = AuthorizationControl.fromName(app().settings()
                .getString(Keys.git.defaultAuthorizationControl, AuthorizationControl.NAMED.name()));
    }

    AccessPolicy defaultPolicy = namedPushPolicy;
    for (AccessPolicy policy : policies) {
        if (policy.type == defaultRestriction && policy.control == defaultControl) {
            defaultPolicy = policy;
        }
    }

    policiesGroup = new RadioGroup<>("policiesGroup", new Model<AccessPolicy>(defaultPolicy));
    ListView<AccessPolicy> policiesList = new ListView<AccessPolicy>("policies", policies) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<AccessPolicy> item) {
            AccessPolicy p = item.getModelObject();
            item.add(new Radio<AccessPolicy>("radio", item.getModel()));
            item.add(WicketUtils.newImage("image", p.image));
            item.add(new Label("name", p.name));
            item.add(new Label("description", p.description));
        }
    };
    policiesGroup.add(policiesList);
    if (callback != null) {
        policiesGroup.add(callback);
        policiesGroup.setOutputMarkupId(true);
    }
    add(policiesGroup);

    if (app().settings().getBoolean(Keys.web.allowForking, true)) {
        Fragment fragment = new Fragment("allowForks", "allowForksFragment", AccessPolicyPanel.this);
        fragment.add(new BooleanOption("allowForks", getString("gb.allowForks"),
                getString("gb.allowForksDescription"), new PropertyModel<Boolean>(repository, "allowForks")));
        add(fragment);
    } else {
        add(new Label("allowForks").setVisible(false));
    }

    setOutputMarkupId(true);
}

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

License:Open Source License

public EnumControlGroup(String id, IModel<T> model) {
    super(id, model);

    radioGroup = new RadioGroup<T>("radioGroup", getModel());
}

From source file:com.socialsite.authentication.SignUpPage.java

License:Open Source License

public SignUpPage() {

    // sign up form
    final Form<Object> form = new Form<Object>("signupform");
    add(form);// w w  w .  j  a va  2s  .  com

    final TextField<String> username = new RequiredTextField<String>("username",
            new PropertyModel<String>(this, "userName"));
    username.add(StringValidator.maximumLength(16));

    form.add(username);

    final TextField<String> emailTextField = new RequiredTextField<String>("email",
            new PropertyModel<String>(this, "email"));
    emailTextField.add(EmailAddressValidator.getInstance());

    form.add(emailTextField);

    final PasswordTextField passwordTextField = new PasswordTextField("password",
            new PropertyModel<String>(this, "password"));
    passwordTextField.setRequired(true);
    passwordTextField.add(StringValidator.lengthBetween(6, 16));

    form.add(passwordTextField);

    final PasswordTextField rePasswordTextField = new PasswordTextField("re-password",
            new PropertyModel<String>(this, "rePassword"));
    rePasswordTextField.setRequired(true);
    rePasswordTextField.add(StringValidator.lengthBetween(6, 16));

    form.add(rePasswordTextField);

    final RadioGroup<UserType> userGroup = new RadioGroup<UserType>("usertype",
            new PropertyModel<UserType>(this, "userType"));

    userGroup.add(new Radio<UserType>("student", new Model<UserType>(UserType.STUDENT)));
    userGroup.add(new Radio<UserType>("staff", new Model<UserType>(UserType.STAFF)));
    userGroup.add(new Radio<UserType>("admin", new Model<UserType>(UserType.ADMIN)));
    form.add(userGroup);

    form.add(new TextField<String>("university", new PropertyModel<String>(this, "universityName")));

    SubmitLink signUp;
    form.add(signUp = new SubmitLink("signup") {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {

            if (!password.equals(rePassword)) {
                error("passwords should be same");
                return;
            }

            // creates a user
            try {
                User user = null;

                switch (userType) {
                case STUDENT:
                    user = new Student(userName, password);
                    break;
                case STAFF:
                    user = new Staff(userName, password);
                    break;
                case ADMIN:
                    if (universityName != null && !universityName.equals("")) {
                        user = new Admin(userName, password);
                        userDao.save(user);
                        new UniversityActivator((Admin) user, universityName).create();
                        // final InfoMsg message = new InfoMsg();
                        // message.getUsers().add(user);
                        // message.setMessage("Your request for adding new University is being processed");
                        // messageDao.save(message);
                    } else {
                        error("University Name required");
                        return;
                    }

                    break;
                default:
                    error("Unknown error occured ");
                    return;
                }

                userDao.save(user);

                final Profile p = new Profile();
                p.setUser(user);
                user.setProfile(p);
                p.setEmail(email);
                // set the default image for the profile
                new DefaultImage().forUser(p);
                profileDao.save(p);

                final SocialSiteSession session = SocialSiteSession.get();
                session.setSessionUser(new SessionUser(user.getId(), SocialSiteRoles.ownerRole));
                session.setUserId(user.getId());
                setResponsePage(new HomePage());

            } catch (final ConstraintViolationException ex) {
                // updates the feedback panel
                error("username already exists");
                // target.addComponent(feedback);
                return;
            }
        }
    });
    // submit the form on return key
    form.setDefaultButton(signUp);

    // feedback panel
    feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    add(feedback);
}

From source file:com.userweave.module.methoden.questionnaire.page.survey.singleratingpanel.SingleRatingPanel.java

License:Open Source License

/**
 * Initializes this component./*ww  w  .j  a v a 2 s  . co m*/
 * 
 * @param numberOfRatingSteps
 * @param showNoAnswerOption
 * @param ratingModel
 */
private void init(Integer numberOfRatingSteps, final boolean showNoAnswerOption,
        final IModel<Integer> ratingModel) {
    group = new RadioGroup<Integer>("group", new Model<Integer>() {
        private static final long serialVersionUID = 1L;

        @Override
        public Integer getObject() {
            return ratingModel.getObject();
        }

        @Override
        public void setObject(Integer object) {
            ratingModel.setObject(object);
        }
    });

    super.add(group);

    choices = new RepeatingView("choices");
    group.add(choices);

    if (containerForNoAnswerOption != null) {
        group.add(containerForNoAnswerOption);
        containerForNoAnswerOption.setVisible(showNoAnswerOption);
        String id = Integer.toString(numberOfRatingSteps);
        containerForNoAnswerOption.add(createRadioChoice(id, INDEX_OF_NOANSWER_OPTION));
    }
}