use of org.apache.sling.scripting.jsp.jasper.JasperException in project sling by apache.
the class JspRuntimeLibrary method handleSetProperty.
public static void handleSetProperty(Object bean, String prop, long value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { new Long(value) });
} catch (Exception ex) {
throw new JasperException(ex);
}
}
use of org.apache.sling.scripting.jsp.jasper.JasperException in project sling by apache.
the class JspRuntimeLibrary method handleSetProperty.
public static void handleSetProperty(Object bean, String prop, int value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { new Integer(value) });
} catch (Exception ex) {
throw new JasperException(ex);
}
}
use of org.apache.sling.scripting.jsp.jasper.JasperException in project sling by apache.
the class JspRuntimeLibrary method handleSetProperty.
public static void handleSetProperty(Object bean, String prop, short value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { new Short(value) });
} catch (Exception ex) {
throw new JasperException(ex);
}
}
use of org.apache.sling.scripting.jsp.jasper.JasperException in project sling by apache.
the class JspRuntimeLibrary method internalIntrospecthelper.
private static void internalIntrospecthelper(Object bean, String prop, String value, ServletRequest request, String param, boolean ignoreMethodNF) throws JasperException {
Method method = null;
Class type = null;
Class propertyEditorClass = null;
try {
java.beans.BeanInfo info = java.beans.Introspector.getBeanInfo(bean.getClass());
if (info != null) {
java.beans.PropertyDescriptor[] pd = info.getPropertyDescriptors();
for (int i = 0; i < pd.length; i++) {
if (pd[i].getName().equals(prop)) {
method = pd[i].getWriteMethod();
type = pd[i].getPropertyType();
propertyEditorClass = pd[i].getPropertyEditorClass();
break;
}
}
}
if (method != null) {
if (type.isArray()) {
if (request == null) {
throw new JasperException(Localizer.getMessage("jsp.error.beans.setproperty.noindexset"));
}
Class t = type.getComponentType();
String[] values = request.getParameterValues(param);
//XXX Please check.
if (values == null)
return;
if (t.equals(String.class)) {
method.invoke(bean, new Object[] { values });
} else {
Object tmpval = null;
createTypedArray(prop, bean, method, values, t, propertyEditorClass);
}
} else {
if (value == null || (param != null && value.equals("")))
return;
Object oval = convert(prop, value, type, propertyEditorClass);
if (oval != null)
method.invoke(bean, new Object[] { oval });
}
}
} catch (Exception ex) {
throw new JasperException(ex);
}
if (!ignoreMethodNF && (method == null)) {
if (type == null) {
throw new JasperException(Localizer.getMessage("jsp.error.beans.noproperty", prop, bean.getClass().getName()));
} else {
throw new JasperException(Localizer.getMessage("jsp.error.beans.nomethod.setproperty", prop, type.getName(), bean.getClass().getName()));
}
}
}
use of org.apache.sling.scripting.jsp.jasper.JasperException in project sling by apache.
the class JspRuntimeLibrary method handleSetProperty.
public static void handleSetProperty(Object bean, String prop, float value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { new Float(value) });
} catch (Exception ex) {
throw new JasperException(ex);
}
}
Aggregations