Methods Summary |
---|
protected boolean | complexType(java.lang.Object value)
return value instanceof freemarker.ext.beans.BeanModel
|| value instanceof SimpleNumber
|| value instanceof SimpleSequence;
|
protected java.util.Map | convertParams(java.util.Map params)
HashMap map = new HashMap(params.size());
for (Iterator iterator = params.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
Object value = entry.getValue();
if (value != null && !complexType(value)) {
map.put(entry.getKey(), value.toString());
}
}
return map;
|
protected abstract org.apache.struts2.components.Component | getBean()
|
protected java.util.Map | getComplexParams(java.util.Map params)
HashMap map = new HashMap(params.size());
for (Iterator iterator = params.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
Object value = entry.getValue();
if (value != null && complexType(value)) {
if (value instanceof freemarker.ext.beans.BeanModel) {
map.put(entry.getKey(), ((freemarker.ext.beans.BeanModel) value).getWrappedObject());
} else if (value instanceof SimpleNumber) {
map.put(entry.getKey(), ((SimpleNumber) value).getAsNumber());
} else if (value instanceof SimpleSequence) {
try {
map.put(entry.getKey(), ((SimpleSequence) value).toList());
} catch (TemplateModelException e) {
LOG.error("There was a problem converting a SimpleSequence to a list", e);
}
}
}
}
return map;
|
public java.io.Writer | getWriter(java.io.Writer writer, java.util.Map params)
Component bean = getBean();
Container container = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getContainer();
container.inject(bean);
Map unwrappedParameters = unwrapParameters(params);
bean.copyParams(unwrappedParameters);
return new CallbackWriter(bean, writer);
|
protected java.util.Map | unwrapParameters(java.util.Map params)
Map map = new HashMap(params.size());
DefaultObjectWrapper objectWrapper = new DefaultObjectWrapper();
for (Iterator iterator = params.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
Object value = entry.getValue();
if (value != null) {
// the value should ALWAYS be a decendant of TemplateModel
if (value instanceof TemplateModel) {
try {
map.put(entry.getKey(), objectWrapper
.unwrap((TemplateModel) value));
} catch (TemplateModelException e) {
LOG.error("failed to unwrap [" + value
+ "] it will be ignored", e);
}
}
// if it doesn't, we'll do it the old way by just returning the toString() representation
else {
map.put(entry.getKey(), value.toString());
}
}
}
return map;
|