}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public Writer getWriter(Writer writer, Map params) throws TemplateModelException, IOException {
Component bean = getBean();
// Container container = (Container)
// stack.getContext().get(ActionContext.CONTAINER);
// container.inject(bean);
BeansWrapper objectWrapper = BeansWrapper.getDefaultInstance();
for (Iterator iterator = params.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, Object> entry = (Map.Entry<String, Object>) iterator.next();
String key = entry.getKey();
Object value = entry.getValue();
if (value != null) {
Method m = ComponentHelper.getWriteMethod(bean, key);
if (null != m) {
if (value instanceof TemplateModel) {
try {
value = objectWrapper.unwrap((TemplateModel) value);
} catch (TemplateModelException e) {
logger.error("failed to unwrap [" + value + "] it will be ignored", e);
}
}
try {
m.invoke(bean, value);
} catch (Exception e) {
e.printStackTrace();
}
} else {
bean.getParameters().put(key, value);
}
}
}
return new ResetCallbackWriter(bean, writer);
}