FileDocCategorySizeDatePackage
StrutsBeanWrapper.javaAPI DocExample4207Mon Jul 23 13:26:42 BST 2007org.apache.struts2.views.freemarker

StrutsBeanWrapper

public class StrutsBeanWrapper extends freemarker.ext.beans.BeansWrapper
The StrutsBeanWrapper extends the default FreeMarker BeansWrapper and provides almost no change in functionality, except for how it handles maps. Normally, FreeMarker has two modes of operation: either support for friendly map built-ins (?keys, ?values, etc) but only support for String keys; OR no special built-in support (ie: ?keys returns the methods on the map instead of the keys) but support for String and non-String keys alike. Struts provides an alternative implementation that gives us the best of both worlds.

It is possible that this special behavior may be confusing or can cause problems. Therefore, you can set the struts.freemarker.wrapper.altMap property in struts.properties to false, allowing the normal BeansWrapper logic to take place instead.

Fields Summary
private boolean
altMapWrapper
Constructors Summary
StrutsBeanWrapper(boolean altMapWrapper)

        this.altMapWrapper = altMapWrapper;
    
Methods Summary
public freemarker.template.TemplateModelwrap(java.lang.Object object)

        if (object instanceof TemplateBooleanModel) {
            return super.wrap(object);
        }

        // attempt to get the best of both the SimpleMapModel and the MapModel of FM.
        if (altMapWrapper && object instanceof Map) {
            return getInstance(object, FriendlyMapModel.FACTORY);
        }

        return super.wrap(object);