本文整理汇总了Java中org.apache.commons.beanutils.DynaBean.getDynaClass方法的典型用法代码示例。如果您正苦于以下问题:Java DynaBean.getDynaClass方法的具体用法?Java DynaBean.getDynaClass怎么用?Java DynaBean.getDynaClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.beanutils.DynaBean
的用法示例。
在下文中一共展示了DynaBean.getDynaClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDynaClass
import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
* Returns the {@link SqlDynaClass} for the given bean.
*
* @param dynaBean The bean
* @return The dyna bean class
*/
public SqlDynaClass getDynaClass(DynaBean dynaBean) throws SqlDynaException
{
DynaClass dynaClass = dynaBean.getDynaClass();
if (dynaClass instanceof SqlDynaClass)
{
return (SqlDynaClass)dynaClass;
}
else
{
// TODO: we could autogenerate an SqlDynaClass here ?
throw new SqlDynaException("The dyna bean is not an instance of a SqlDynaClass");
}
}
示例2: createActionForm
import org.apache.commons.beanutils.DynaBean; //导入方法依赖的package包/类
/**
* <p>Create and return an <code>ActionForm</code> instance appropriate to
* the information in this <code>FormBeanConfig</code>.</p>
*
* <p>Although this method is not formally deprecated yet, where possible,
* the form which accepts an <code>ActionContext</code> as an argument is
* preferred, to help sever direct dependencies on the Servlet API. As
* the ActionContext becomes more familiar in Struts, this method will
* almost certainly be deprecated.</p>
*
* @param servlet The action servlet
* @return ActionForm instance
* @throws IllegalAccessException if the Class or the appropriate
* constructor is not accessible
* @throws InstantiationException if this Class represents an abstract
* class, an array class, a primitive type,
* or void; or if instantiation fails for
* some other reason
*/
public ActionForm createActionForm(ActionServlet servlet)
throws IllegalAccessException, InstantiationException {
Object obj = null;
// Create a new form bean instance
if (getDynamic()) {
obj = getDynaActionFormClass().newInstance();
} else {
obj = formBeanClass().newInstance();
}
ActionForm form = null;
if (obj instanceof ActionForm) {
form = (ActionForm) obj;
} else {
form = new BeanValidatorForm(obj);
}
form.setServlet(servlet);
if (form instanceof DynaBean
&& ((DynaBean) form).getDynaClass() instanceof MutableDynaClass) {
DynaBean dynaBean = (DynaBean) form;
MutableDynaClass dynaClass =
(MutableDynaClass) dynaBean.getDynaClass();
// Add properties
dynaClass.setRestricted(false);
FormPropertyConfig[] props = findFormPropertyConfigs();
for (int i = 0; i < props.length; i++) {
dynaClass.add(props[i].getName(), props[i].getTypeClass());
dynaBean.set(props[i].getName(), props[i].initial());
}
dynaClass.setRestricted(isRestricted());
}
if (form instanceof BeanValidatorForm) {
((BeanValidatorForm)form).initialize(this);
}
return form;
}