Package org.springframework.beans

Examples of org.springframework.beans.BeanWrapper


    public static Collection<?> filterByNotValue(String propertyName, Object value,
            Collection<?> collection) {
        List<Object> list = new ArrayList<Object>(collection.size());
        for (Object o : collection) {
            BeanWrapper bw = new BeanWrapperImpl(o);
            Object propertyValue = bw.getPropertyValue(propertyName);
            if (!propertyValue.equals(value)) {
                list.add(o);
            }
        }
        return list;
View Full Code Here


    public static int countTrue(String propertyName, Collection<?> collection) {

        int count=0;
        for (Object o : collection) {
            BeanWrapper bw = new BeanWrapperImpl(o);
            Boolean propertyValue = (Boolean)bw.getPropertyValue(propertyName);
            if (Boolean.TRUE.equals(propertyValue)) {
                count++;
            }
        }
        return count;
View Full Code Here

    public static int countFalse(String propertyName, Collection<?> collection) {

        int count=0;
        for (Object o : collection) {
            BeanWrapper bw = new BeanWrapperImpl(o);
            Boolean propertyValue = (Boolean)bw.getPropertyValue(propertyName);
            if (Boolean.FALSE.equals(propertyValue)) {
                count++;
            }
        }
        return count;
View Full Code Here

        /* If the sourceProperty is found,
           * then get the current value of the source property from the selected row. */
        if ((sourcePropertyName != null) && !"".equals(sourcePropertyName)) {
            debug(logger, "select() found source property: sourcePropertyName=%s", sourcePropertyName);
            BeanWrapper valueWrapper = new BeanWrapperImpl(valueBean);
            valueProperty = valueWrapper.getPropertyValue(this.sourcePropertyName);
            debug(logger, "select(): this value was selected from sourcePropertyName : valueProperty = %s", valueProperty);
        }
        return valueProperty;
    }
View Full Code Here

  public void process() {
    List<Row> availableTags = getRows();
    List<T> tagsToProcess = new ArrayList<T>();
    for (Row row : availableTags) {
      T tag = (T) row.getObject();
      BeanWrapper child = new BeanWrapperImpl(tag);
      BeanWrapper parent = getParent();
      tagsToProcess.add(tag);
      PK parentId = (PK) getParentId(parent);
 
      if (row.isSelected()) {
        child.setPropertyValue(targetProperty, parentId);
View Full Code Here

        String pref = (String)suggest;
        if (isDataCached()) {
          pref = pref.toUpperCase();
          if (cacheKey != null && pref.startsWith(cacheKey)) {
            List<S> tmp = new ArrayList<S>(cachedData.size());
                BeanWrapper entityProp = null;
            for (S s : cachedData) {
                    if (entityProp == null) {
                      entityProp = new BeanWrapperImpl(s);
                    }
                    else {
                      entityProp.setWrappedInstance(s);
                    }                   
                    Object beanPropertyValue = entityProp.getPropertyValue(propertyName);
                    if (beanPropertyValue != null) {
                      String ucValue = beanPropertyValue.toString().toUpperCase();
                      if (ucValue.startsWith(pref)) {
                        tmp.add(s);
                      }
View Full Code Here

  /**
   * Local helper method to lookup the many to one object and then associate it with the event's entity
   * @param event
   */
  protected void handleCreateUpdate(CrudEvent event) {
        BeanWrapper entity = new BeanWrapperImpl( event.getEntity() );
        Object newValue = null;
        if ((value != null) && !"".equals(value)) {
          List<?> list = getListExact(value);
          if (list.size()==1) {
            newValue = list.get(0);
          } else {
            StringBuilder msg = new StringBuilder();
            msg.append("Unable to match '");
            msg.append(fieldName);
            msg.append("' to selection '");
            msg.append(value);
            msg.append("'.");
            throw new IllegalArgumentException(msg.toString());
          }
        }
        entity.setPropertyValue(fieldName, newValue);
  }
View Full Code Here

   * Employee.specialty.name
   *
   * @param event
   */
  private void handleReadEvent(CrudEvent event) {
        BeanWrapper entity = new BeanWrapperImpl( event.getEntity() );
        Object fieldValue = entity.getPropertyValue(fieldName);
       
      this.value = null;
     
        if (fieldValue != null) {
          BeanWrapper entityProp = new BeanWrapperImpl(fieldValue);
            this.value = (String) entityProp.getPropertyValue(propertyName);
        }
  }
View Full Code Here

    /**
     * This method gets called when the user clicks on an item in the listing.
     */
  public void process() {
        /* retrieve the item selected and wrap it in a bean wrapper. */
        BeanWrapper child = new BeanWrapperImpl(clickedItem);

        if (!toParent) {
            /* Set the selected id into child. */
            child.setPropertyValue(super.targetProperty, getParentId());
        } else {
            getParent().setPropertyValue(super.targetProperty, child.getPropertyValue(super.sourceProperty));
        }

        /* Unselect whatever was selected. */
        if (!toParent) {
            Set<T> unselectedChildren = getSelectedChildren();
            for (T unSelect : unselectedChildren) {
                BeanWrapper unChild = new BeanWrapperImpl(unSelect);
                unChild.setPropertyValue(super.targetProperty, null);
            }
            /* Merge the changes with the database. */
            updateChildren(unselectedChildren);
        } else {
            //
View Full Code Here

    protected Set<T> getSelectedChildren() {

        /* If we are setting the id in the child, let's do that here. */
        if (!toParent) {
            BeanWrapper parent = getParent();
            PK parentId = getParentId(parent);
            if (parentId == null) {
                return Collections.emptySet();
            }

View Full Code Here

TOP

Related Classes of org.springframework.beans.BeanWrapper

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.