List of usage examples for org.apache.commons.beanutils BasicDynaClass newInstance
public DynaBean newInstance() throws IllegalAccessException, InstantiationException
From source file:org.agnitas.web.UserFormEditAction.java
public List<DynaBean> getUserFromList(HttpServletRequest request) throws IllegalAccessException, InstantiationException { ApplicationContext aContext = getWebApplicationContext(); JdbcTemplate aTemplate = new JdbcTemplate((DataSource) aContext.getBean("dataSource")); String sqlStatement = "SELECT form_id, formname, description FROM userform_tbl WHERE company_id=" + AgnUtils.getCompanyID(request) + " ORDER BY formname"; List<Map> tmpList = aTemplate.queryForList(sqlStatement); DynaProperty[] properties = new DynaProperty[] { new DynaProperty("formid", Long.class), new DynaProperty("formname", String.class), new DynaProperty("description", String.class) }; if (AgnUtils.isOracleDB()) { properties = new DynaProperty[] { new DynaProperty("formid", BigDecimal.class), new DynaProperty("formname", String.class), new DynaProperty("description", String.class) }; }//ww w . j a va2 s . c o m BasicDynaClass dynaClass = new BasicDynaClass("userform", null, properties); List<DynaBean> result = new ArrayList<DynaBean>(); for (Map row : tmpList) { DynaBean newBean = dynaClass.newInstance(); newBean.set("formid", row.get("FORM_ID")); newBean.set("formname", row.get("FORMNAME")); newBean.set("description", row.get("DESCRIPTION")); result.add(newBean); } return result; }
From source file:org.catechis.Transformer.java
public static DynaBean getWordTestBean(int number_of_words_to_test) { DynaProperty[] properties = new DynaProperty[number_of_words_to_test]; {/*from w w w .ja v a 2 s . c o m*/ int count = 0; while (count < number_of_words_to_test) { properties[count] = new DynaProperty("feild" + count, String.class); count++; } } ; BasicDynaClass word_test_class = new BasicDynaClass("word_test", BasicDynaBean.class, properties); DynaBean word_test = new BasicDynaBean(word_test_class); try { word_test = word_test_class.newInstance(); int count = 0; while (count < number_of_words_to_test) { word_test.set("feild" + count, ""); count++; } } catch (java.lang.IllegalAccessException iae) { word_test = null; } catch (java.lang.InstantiationException ie) { word_test = null; } return word_test; }