Package org.springframework.beans

Examples of org.springframework.beans.BeanWrapperImpl


    @Override
    public void doTag() throws JspException {
        if (entity != null) {
            try {
                JspContext context = getJspContext();
                Object val = new BeanWrapperImpl(entity).getPropertyValue(path);
                if (logger.isDebugEnabled()) logger.debug("Obtained value [" + path + "] for bean [" + entity + "]: " + val);
                if ((val != null) && encrypt) {
                    Cipherer cipher = (Cipherer) context.getAttribute(Cipherer.CIPHERER, 2);
                    val = cipher.encrypt(val.toString());
                }
View Full Code Here


    public void setProperty(String property) {
        this.property = property;
    }

    private Class<?> getType(Class<?> clazz, String path) throws BeansException, InstantiationException, IllegalAccessException {
      return new BeanWrapperImpl(clazz.newInstance()).getPropertyType(path);
    }
View Full Code Here

    @RemoteMethod
    @SuppressWarnings("unchecked")
    public List<ValuePair<String, String>> fetchReferences(Class<?> clazz, String path, String query, int count, int number) throws Exception {
        Assert.isEncrypted(decipherer, path);
        DomainEntity parent = (DomainEntity) ClassUtils.instantiateClass(clazz);
        Selectable entity = (Selectable) ClassUtils.instantiateClass(new BeanWrapperImpl(parent).getPropertyType(decipherer.decrypt(path)));
        if (entity == null) entity = (Selectable) parent;
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("query", query + "%");
        List<ValuePair<String, String>> result = new ArrayList<ValuePair<String, String>>(number);
        for (Object[] o : dao.executeQuery(entity.selectableQuery(), count, number, parameters))
View Full Code Here

    public boolean update(Class entityClass, UpdateDataDTO[] data) throws Exception {
        Assert.notNull(entityClass);
        for (UpdateDataDTO dto : data) {
            Assert.isEncrypted(decipherer, dto.getPrimaryKey());
            DomainEntity o = dao.find(entityClass, new UUID(decipherer.decrypt(dto.getPrimaryKey())));
            BeanWrapper w = new BeanWrapperImpl(o);
            w.setPropertyValue(dto.getPath(), dto.getValue());
            dao.update(o);
        }
        return true;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    protected Errors doValidation(Class clazz, String path, Object value) throws Exception {
        DomainEntity object = (DomainEntity) ClassUtils.instantiateClass(clazz);
        object.initialize(contextHolder);
        BeanWrapper validatable = new BeanWrapperImpl(object);
        validatable.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), false));
        validatable.setPropertyValue(path, value);
        Errors errors = new BeanPropertyBindingResult(object, "target");
        validator.validate(object, errors);
        return errors;
    }
View Full Code Here

    private String property;

    @Override public void doTag() throws JspException {
        Boolean exists = Boolean.TRUE;
        try {
            new BeanWrapperImpl(entity).getPropertyValue(path);
        } catch (Exception ex) {
            exists = Boolean.FALSE;
        }
        if (logger.isDebugEnabled()) logger.debug("Property [" + path + "] of [" + entity + "] " + (exists ? "does not exist" : "exists"));
        getJspContext().setAttribute(property, exists);
View Full Code Here

    @RemoteMethod
    public boolean update(Class clazz, UpdateDataDTO[] data) throws Exception {
        for (UpdateDataDTO dto : data) {
            UserImpl user = dao.findUser(dto.getPrimaryKey());
            BeanWrapper w = new BeanWrapperImpl(user);
            w.setPropertyValue(dto.getPath(), dto.getValue());
            dao.createUser(user);
        }
        return true;
    }
View Full Code Here

      Assert.isTrue(position >= 0);
      try {
            Class<?> type = clazz;
            String[] parts = path.split("\\.");
            for (int index = 0; index < parts.length - 1; index++)
                type = new BeanWrapperImpl(type.newInstance()).getPropertyType(parts[index]);
            Field field = getField(type, parts[parts.length - 1]);
            Class<?> enumType = field.getType();
            return enumType.isEnum() && (position < enumType.getEnumConstants().length) ? enumType.getEnumConstants()[position] : null;
      } catch (Exception ex) {
            throw new IWebMvcException("Could not get enum value from [" + clazz.getName() + "] with position [" + position + "]", ex);
View Full Code Here

   
    public static final String SHIPPEDFROM_FIELD = "shippedFrom";
    public static final String SHIPPEDTO_FIELD = "shippedTo";

    public static Class getPropertyType(Object obj, String prop) {
        return (new BeanWrapperImpl(obj)).getPropertyType(prop);
    }
View Full Code Here

    public static Class getPropertyType(Object obj, String prop) {
        return (new BeanWrapperImpl(obj)).getPropertyType(prop);
    }

    public static Object getPropertyValue(Object obj, String prop) {
        return (new BeanWrapperImpl(obj)).getPropertyValue(prop);
    }
View Full Code Here

TOP

Related Classes of org.springframework.beans.BeanWrapperImpl

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.