public Object getBeanObject(Environment environment, Map params, String directiveName) throws TemplateException {
Object beanParam = params.get("bean");
if(beanParam == null) {
if(params.containsKey("bean")) {
throw new TemplateException("Mandatory <@" + directiveName + "> directive parameter 'bean' is defined, but the bean is not visible in the model. Should be a valid model object reference (no quotes) e.g. <@" + directiveName + " bean=customer.address />.", environment);
} else {
throw new TemplateException("Mandatory <@" + directiveName + "> directive parameter 'bean' is not defined. Should be a valid model object reference (no quotes) e.g. <@" + directiveName + " bean=customer.address />.", environment);
}
}
if(!(beanParam instanceof StringModel)) {
throw new TemplateException("Mandatory <@" + directiveName + "> directive parameter 'bean' not defined properly. Should be a valid model object reference (no quotes) e.g. <@" + directiveName + " bean=customer.address />.", environment);
}
StringModel beanModel = (StringModel) beanParam;
return beanModel.getWrappedObject();