Examples of BeanWrapper


Examples of org.springframework.beans.BeanWrapper

        return true;
    }

    public void validate(Object target, Errors errors) {

        BeanWrapper beanWrapper = (target instanceof BeanWrapper) ? (BeanWrapper) target : new BeanWrapperImpl(target);

        if (getCustomPropertyEditors() != null) {
            for (Iterator iter = getCustomPropertyEditors().iterator(); iter.hasNext();) {
                CustomPropertyEditor customPropertyEditor = (CustomPropertyEditor) iter.next();

                if (customPropertyEditor.getRequiredType() == null) {
                    throw new IllegalArgumentException("[requiredType] is required on CustomPropertyEditor instances!");
                } else if (customPropertyEditor.getPropertyEditor() == null) {
                    throw new IllegalArgumentException(
                        "[propertyEditor] is required on CustomPropertyEditor instances!");
                }

                if (StringUtils.hasLength(customPropertyEditor.getPropertyPath())) {
                    beanWrapper.registerCustomEditor(customPropertyEditor.getRequiredType(),
                        customPropertyEditor.getPropertyPath(), customPropertyEditor.getPropertyEditor());
                } else {
                    beanWrapper.registerCustomEditor(customPropertyEditor.getRequiredType(),
                        customPropertyEditor.getPropertyEditor());
                }
            }
        }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

        return executeCallable((Callable<?>) callable, properties);
    }

    private ActionResult executeCallable(Callable<?> callable, Map<String, String> properties) {
        BeanWrapper beanWrapper = new BeanWrapperImpl(callable);
        PropertyValues propertyValues = new MutablePropertyValues(properties);

        try {
            beanWrapper.setPropertyValues(propertyValues, true, false);
        } catch (Exception e) {
            LOGGER.debug("Error while setting bean properties", e);
            return new ClassActionResult(e);
        }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

            private static final long serialVersionUID = -958724007591692537L;

            @Override
            protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
                final BeanWrapper wrapper = PropertyAccessorFactory
                        .forBeanPropertyAccess(ReportletConfModalPage.this.reportletConf);
                wrapper.setPropertyValue("name", name.getField().getInput());

                // Iterate over properties in order to find UserSearchPanel instances and manually update
                // this.reportletConf with select search criteria - this is needed because UserSearchPanel
                // does not comply with usual Wicket model paradigm.
                for (Iterator<Component> itor = ReportletConfModalPage.this.propView.visitChildren(); itor.hasNext();) {
                    Component component = itor.next();
                    if (component instanceof UserSearchPanel) {
                        // using component.getDefaultModelObjectAsString() to fetch field name (set above)
                        wrapper.setPropertyValue(component.getDefaultModelObjectAsString(),
                                ((UserSearchPanel) component).buildSearchCond());
                    }
                }

                ((ReportModalPage) pageRef.getPage())
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

                }
                if (field == null) {
                    return;
                }

                BeanWrapper wrapper = PropertyAccessorFactory
                        .forBeanPropertyAccess(ReportletConfModalPage.this.reportletConf);

                Panel panel;

                if (NodeCond.class.equals(field.getType())) {
                    panel = new UserSearchPanel("value", (NodeCond) wrapper.getPropertyValue(fieldName), false);
                    // This is needed in order to manually update this.reportletConf with search panel selections
                    panel.setDefaultModel(new Model<String>(fieldName));
                } else if (List.class.equals(field.getType())) {
                    if (wrapper.getPropertyValue(fieldName) == null) {
                        wrapper.setPropertyValue(fieldName, new ArrayList());
                    }

                    Class<?> listItemType = String.class;
                    if (field.getGenericType() instanceof ParameterizedType) {
                        listItemType =
                                (Class<?>) ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0];
                    }

                    FormAttributeField annotation = field.getAnnotation(FormAttributeField.class);

                    if (listItemType.equals(String.class) && annotation != null) {
                        List<String> choices;
                        switch (annotation.schema()) {
                            case UserSchema:
                                choices = schemaRestClient.getSchemaNames(AttributableType.USER);
                                break;

                            case UserDerivedSchema:
                                choices = schemaRestClient.getDerivedSchemaNames(AttributableType.USER);
                                break;

                            case UserVirtualSchema:
                                choices = schemaRestClient.getVirtualSchemaNames(AttributableType.USER);
                                break;

                            case RoleSchema:
                                choices = schemaRestClient.getSchemaNames(AttributableType.ROLE);
                                break;

                            case RoleDerivedSchema:
                                choices = schemaRestClient.getDerivedSchemaNames(AttributableType.ROLE);
                                break;

                            case RoleVirtualSchema:
                                choices = schemaRestClient.getVirtualSchemaNames(AttributableType.ROLE);
                                break;

                            case MembershipSchema:
                                choices = schemaRestClient.getSchemaNames(AttributableType.MEMBERSHIP);
                                break;

                            case MembershipDerivedSchema:
                                choices = schemaRestClient.getDerivedSchemaNames(AttributableType.MEMBERSHIP);
                                break;

                            case MembershipVirtualSchema:
                                choices = schemaRestClient.getVirtualSchemaNames(AttributableType.MEMBERSHIP);
                                break;

                            default:
                                choices = Collections.emptyList();
                        }

                        panel = new AjaxPalettePanel("value", new PropertyModel<List<String>>(
                                ReportletConfModalPage.this.reportletConf, fieldName), new ListModel<String>(choices),
                                true);
                    } else if (listItemType.isEnum()) {
                        panel = new CheckBoxMultipleChoiceFieldPanel("value", new PropertyModel(
                                ReportletConfModalPage.this.reportletConf, fieldName), new ListModel(Arrays
                                .asList(listItemType.getEnumConstants())));
                    } else {
                        if (((List) wrapper.getPropertyValue(fieldName)).isEmpty()) {
                            ((List) wrapper.getPropertyValue(fieldName)).add(null);
                        }

                        panel = new MultiValueSelectorPanel("value", new PropertyModel<List>(
                                ReportletConfModalPage.this.reportletConf, fieldName), buildSinglePanel(
                                field.getType(), fieldName, "panel"));
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

        if (parent != null) {
          /*
           * Invoke the method and return the list type thing (it can be an
           * Array, List, Set or Map)
           */
          BeanWrapper wrapper = new BeanWrapperImpl (parent);
 
          Object listTypeThing = wrapper.getPropertyValue( childCollectionProperty() );

            if (logger.isDebugEnabled()) {
                logger.debug(String.format("returning %s from getChildCollection(parent=%s)",listTypeThing, parent));
            }
            return listTypeThing;
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

     * @throws SecurityException
     * @throws Exception
     *             Some problem.
     */
    private void setChildCollectionIntoParentObject( Object parent, Object newCollection ) {
            BeanWrapper wrapper = new BeanWrapperImpl(parent);
            wrapper.setPropertyValue( this.childCollectionProperty, newCollection);
    }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

        /**
         * Iterate through children looking for child with id of id passed.
         */
        while(iterator.hasNext()){
            Object object = iterator.next();
            BeanWrapper wrapper = new BeanWrapperImpl(object);
            Long idPropertyValue = (Long) wrapper.getPropertyValue(this.idPropertyName);
            if (id.equals(idPropertyValue)) {
                child = (Serializable) object;
                break;
            }
        }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

        /**
         * Iterate through children looking for child with id of id passed.
         */
        while(iterator.hasNext()){
            Object object = iterator.next();
            BeanWrapper wrapper = new BeanWrapperImpl(object);
            String idPropertyValue = (String) wrapper.getPropertyValue(this.idPropertyName);
            if (id.equalsIgnoreCase(idPropertyValue)) {
                child = (Serializable) object;
                break;
            }
        }
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

    @SuppressWarnings("unchecked")
  protected Object initChildCollection( Object parent ) throws Exception {
      if (parent == null) {
        return null;
      }
        BeanWrapper wrapper = new BeanWrapperImpl (parent);
        Object childCollection=null;
        Class propertyType = wrapper.getPropertyType( this.childCollectionProperty );
        if (List.class.isAssignableFrom( propertyType )) {
            childCollection = new ArrayList();
        } else if (Set.class.isAssignableFrom( propertyType )) {
            childCollection = new HashSet();
        } else if (Map.class.isAssignableFrom( propertyType )) {
View Full Code Here

Examples of org.springframework.beans.BeanWrapper

    }
   
    /** Get the object id. */
    @SuppressWarnings("unchecked")
  private String getObjectParameterIdFromBagOrSet(Object object, Collection collection) {
        BeanWrapper wrapper = new BeanWrapperImpl(object);
        Object idValue =  wrapper.getPropertyValue(this.idPropertyName);

        if (idValue==null) {
            return "hc--" + object.hashCode();
        } else if (idValue instanceof String) {
            String strIdValue = (String) idValue;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.