Package org.apache.wicket.model

Examples of org.apache.wicket.model.Model


                    } else if (field.getType().equals(boolean.class) || field.getType().equals(Boolean.class)) {
                        item.add(new AjaxCheckBoxPanel("check", field.getName(), new PropertyModel(policy,
                                field.getName())));

                        item.add(new Label("field", new Model(null)));
                    } else if (Collection.class.isAssignableFrom(field.getType())) {
                        if (field.getSchemaList() != null) {
                            final List<String> values = new ArrayList<String>();
                            if (field.getName().charAt(0) == 'r') {
                                values.addAll(roleSchemas.getObject());

                                if (field.getSchemaList().extended()) {
                                    values.add("name");
                                }
                            } else {
                                values.addAll(userSchemas.getObject());

                                if (field.getSchemaList().extended()) {
                                    values.add("id");
                                    values.add("username");
                                }
                            }

                            Collection collection =
                                    (Collection) propDesc.getReadMethod().invoke(policy, new Object[]{});

                            if (collection == null) {
                                collection = new ArrayList();
                                propDesc.getWriteMethod().invoke(policy, collection);
                            }

                            component = new AjaxPalettePanel("field", new PropertyModel(policy, field.getName()),
                                    new ListModel<String>(values));
                            item.add(component);

                            item.add(getActivationControl(component,
                                    !collection.isEmpty(), new ArrayList<String>(), new ArrayList<String>()));
                        } else {
                            final FieldPanel panel = new AjaxTextFieldPanel("panel", field.getName(),
                                    new Model<String>(null));
                            panel.setRequired(true);

                            component = new MultiValueSelectorPanel<String>("field",
                                    new PropertyModel(policy, field.getName()), panel);

                            item.add(component);

                            final List<String> reinitializedValue = new ArrayList<String>();

                            reinitializedValue.add("");

                            item.add(getActivationControl(component,
                                    !((Collection) propDesc.getReadMethod().invoke(policy, new Object[]{})).isEmpty(),
                                    new ArrayList<String>(), (Serializable) reinitializedValue));
                        }
                    } else if (field.getType().equals(int.class) || field.getType().equals(Integer.class)) {
                        component = new AjaxTextFieldPanel("field", field.getName(),
                                new PropertyModel(policy, field.getName()));

                        item.add(component);

                        item.add(getActivationControl(component,
                                (Integer) propDesc.getReadMethod().invoke(policy, new Object[]{}) > 0, 0, 0));
                    } else {
                        item.add(new AjaxCheckBoxPanel("check", field.getName(), new Model()));
                        item.add(new Label("field", new Model(null)));
                    }
                } catch (Exception e) {
                    LOG.error("Error retrieving policy fields", e);
                }
            }
View Full Code Here


    }

    private <T extends Serializable> AjaxCheckBoxPanel getActivationControl(final AbstractFieldPanel panel,
            final Boolean checked, final T defaultModelObject, final T reinitializedValue) {

        final AjaxCheckBoxPanel check = new AjaxCheckBoxPanel("check", "check", new Model(checked));

        panel.setEnabled(checked);

        check.getField().add(new AjaxFormComponentUpdatingBehavior("onchange") {
View Full Code Here

    public Login(final PageParameters parameters) {
        super(parameters);

        form = new Form("login");

        userIdField = new TextField("userId", new Model());
        userIdField.setMarkupId("userId");
        form.add(userIdField);

        passwordField = new PasswordTextField("password", new Model());
        passwordField.setMarkupId("password");
        form.add(passwordField);

        languageSelect = new LocaleDropDown("language");
View Full Code Here

        propertiesContainer = new WebMarkupContainer("container");
        propertiesContainer.setOutputMarkupId(true);
        form.add(propertiesContainer);

        name = new AjaxTextFieldPanel("name", "name", this.reportletConf == null
                ? new Model()
                : new PropertyModel<String>(this.reportletConf, "name"));
        name.setOutputMarkupId(true);
        name.addRequiredLabel();
        form.add(name);
View Full Code Here

                FieldPanel field;
                switch (prop.getType()) {
                    case Boolean:
                        field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(),
                                new Model(Boolean.valueOf(prop.getValue()))).setChoices(Arrays.asList(
                                new String[]{"Yes", "No"}));
                        break;

                    case Date:
                        SimpleDateFormat df = StringUtils.isNotBlank(prop.getDatePattern())
                                ? new SimpleDateFormat(prop.getDatePattern())
                                : new SimpleDateFormat();
                        Date parsedDate = null;
                        if (StringUtils.isNotBlank(prop.getValue())) {
                            try {
                                parsedDate = df.parse(prop.getValue());
                            } catch (ParseException e) {
                                LOG.error("Unparsable date: {}", prop.getValue(), e);
                            }
                        }

                        field = new DateTimeFieldPanel("value", label.getDefaultModelObjectAsString(),
                                new Model(parsedDate), df.toLocalizedPattern());
                        break;

                    case Enum:
                        MapChoiceRenderer<String, String> enumCR =
                                new MapChoiceRenderer<String, String>(prop.getEnumValues());

                        field = new AjaxDropDownChoicePanel("value", label.getDefaultModelObjectAsString(),
                                new Model(prop.getValue())).setChoiceRenderer(enumCR).setChoices(new Model() {

                            private static final long serialVersionUID = -858521070366432018L;

                            @Override
                            public Serializable getObject() {
                                return new ArrayList(prop.getEnumValues().keySet());
                            }
                        });
                        break;

                    case Long:
                        field = new AjaxNumberFieldPanel("value", label.getDefaultModelObjectAsString(),
                                new Model(Long.valueOf(prop.getValue())), Long.class);
                        break;

                    case String:
                    default:
                        field = new AjaxTextFieldPanel("value", PARENT_PATH, new Model(prop.getValue()));
                        break;
                }

                field.setReadOnly(!prop.isWritable());
                if (prop.isRequired()) {
View Full Code Here

     *
     * @param item item to attach.
     * @return updated FieldPanel object.
     */
    public FieldPanel setNewModel(final ListItem<T> item) {
        setNewModel(new Model() {

            private static final long serialVersionUID = 6799404673615637845L;

            @Override
            public Serializable getObject() {
View Full Code Here

        });
        return this;
    }

    public FieldPanel setNewModel(final List<Serializable> list) {
        setNewModel(new Model() {

            private static final long serialVersionUID = 1088212074765051906L;

            @Override
            public Serializable getObject() {
View Full Code Here

    @Override
    public FieldPanel clone() {
        final FieldPanel panel;
        try {
            panel = this.getClass().getConstructor(new Class[]{String.class, String.class, IModel.class})
                    .newInstance(id, name, new Model(null));
        } catch (Exception e) {
            LOG.error("Error cloning field panel", e);
            return null;
        }
View Full Code Here

    public AjaxCheckBoxPanel(final String id, final String name, final IModel<Boolean> model) {

        super(id, name, model);

        field = new CheckBox("checkboxField", model);
        add(field.setLabel(new Model(name)).setOutputMarkupId(true));

        if (!isReadOnly()) {
            field.add(new AjaxFormComponentUpdatingBehavior("onchange") {

                private static final long serialVersionUID = -1107858522700306810L;
View Full Code Here

        return this;
    }

    @Override
    public FieldPanel<Boolean> setNewModel(final List<Serializable> list) {
        setNewModel(new Model() {

            private static final long serialVersionUID = 527651414610325237L;

            @Override
            public Serializable getObject() {
View Full Code Here

TOP

Related Classes of org.apache.wicket.model.Model

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.