NIHVIVO-2508 Preparation for exposing some template model methods as methods rather than properties. Also condensed code used to generate editing links for menu management.
This commit is contained in:
parent
44ef90bf6a
commit
c356b16807
20 changed files with 83 additions and 51 deletions
|
@ -33,7 +33,19 @@ public class ReadOnlyBeansWrapper extends BeansWrapper {
|
|||
decision.setExposeMethodAs(null);
|
||||
} else if ( method.getReturnType().getName().equals("void") ) {
|
||||
decision.setExposeMethodAs(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For exposing a method as a property (when it's not named getX or isX). Note that this is not
|
||||
// just a syntactic change in the template from X() to X, but also makes the value get precomputed.
|
||||
// private void exposeAsProperty(Method method, MethodAppearanceDecision decision) {
|
||||
// try {
|
||||
// PropertyDescriptor pd = new PropertyDescriptor(method.getName(), method, null);
|
||||
// decision.setExposeAsProperty(pd);
|
||||
// decision.setMethodShadowsProperty(false);
|
||||
// } catch (IntrospectionException e) {
|
||||
// log.error(e, e);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
20
webapp/src/freemarker/ext/beans/WrapperExtractor.java
Normal file
20
webapp/src/freemarker/ext/beans/WrapperExtractor.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package freemarker.ext.beans;
|
||||
|
||||
import freemarker.template.TemplateModel;
|
||||
|
||||
/**
|
||||
* Class to extract information about the wrapper used to wrap an object in
|
||||
* the template model.
|
||||
*/
|
||||
public class WrapperExtractor {
|
||||
|
||||
public static BeansWrapper getWrapper(BeanModel model) {
|
||||
return model.wrapper;
|
||||
}
|
||||
|
||||
public static int getWrapperExposureLevel(BeanModel model) {
|
||||
return model.wrapper.getExposureLevel();
|
||||
}
|
||||
}
|
|
@ -321,7 +321,7 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put(Key.TYPE.toString(), object.getClass().getName());
|
||||
|
||||
// Compile the sets of properties and methods available to template
|
||||
// Compile the collections of properties and methods available to the template
|
||||
SortedMap<String, Object> properties = new TreeMap<String, Object>();
|
||||
List<String> methods = new ArrayList<String>();
|
||||
|
||||
|
@ -379,6 +379,8 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
}
|
||||
// Else look for the entire methodName in the key set. Include those
|
||||
// starting with "get" or "is" that were not found above.
|
||||
// NB This does not properly account for methods exposed as properties
|
||||
// using BeansWrapper.finetuneMethodAppearance().
|
||||
if (keySet.contains(methodName)) {
|
||||
String methodDisplayName = getMethodDisplayName(method);
|
||||
methods.add(methodDisplayName);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue