| 1 17 package org.ajaxtags.xml; 18 19 import java.lang.reflect.InvocationTargetException ; 20 import java.util.Collection ; 21 22 import org.apache.commons.beanutils.BeanUtils; 23 24 32 public final class AjaxXmlBuilder extends AjaxValueListXmlBuilder { 33 34 43 public AjaxXmlBuilder addItem(String key, String value) { 44 return addItem(key, value, false); 45 } 46 47 56 public AjaxXmlBuilder addItemAsCData(String key, String value) { 57 return addItem(key, value, true); 58 } 59 60 71 public AjaxXmlBuilder addItems(Collection <?> collection, 72 String nameProperty, String valueProperty) 73 throws IllegalAccessException , InvocationTargetException , 74 NoSuchMethodException { 75 return addItems(collection, nameProperty, valueProperty, false); 76 } 77 78 89 public AjaxXmlBuilder addItem(String name, String value, boolean asCData) { 90 super.addItem(name, asCData, value); 91 return this; 92 } 93 94 106 public AjaxXmlBuilder addItems(Collection <?> collection, 107 String nameProperty, String valueProperty, boolean asCData) 108 throws IllegalAccessException , InvocationTargetException , 109 NoSuchMethodException { 110 for (Object element : collection) { 111 String name = BeanUtils.getProperty(element, nameProperty); 112 String value = BeanUtils.getProperty(element, valueProperty); 113 addItem(name, value, asCData); 114 } 115 return this; 116 } 117 118 } 119 | Popular Tags |