public class UseBeanTag extends MapTagSupport implements BeanSource
Class
instance or
a String which will be used to load the class using either the current
thread's context class loader or the class loader used to load this
Jelly library.
This tag can be used it as follows,
<j:useBean var="person" class="com.acme.Person" name="James" location="${loc}"/> <j:useBean var="order" class="${orderClass}" amount="12" price="123.456"/>
body, context, parent
Constructor and Description |
---|
UseBeanTag() |
UseBeanTag(Class defaultClass) |
Modifier and Type | Method and Description |
---|---|
protected void |
addIgnoreProperty(String name)
Adds a name to the Set of property names that will be skipped when setting
bean properties.
|
protected Class |
convertToClass(Object classObject)
Attempts to convert the given object to a Class instance.
|
void |
doTag(XMLOutput output)
Evaluates this tag after all the tags properties have been initialized.
|
Object |
getBean() |
protected Class |
getDefaultClass()
Allows derived classes to provide a default bean implementation class
|
protected Set |
getIgnorePropertySet() |
boolean |
isIgnoreUnknownProperties() |
protected Class |
loadClass(String className)
Loads the given class using the default class loading mechanism
which is to try use the current Thread's context class loader first
otherise use the class loader which loaded this class.
|
protected Object |
newInstance(Class theClass,
Map attributes,
XMLOutput output)
Creates a new instance of the given class, which by default will invoke the
default constructor.
|
protected void |
processBean(String var,
Object bean)
By default this will export the bean using the given variable if it is defined.
|
protected void |
setBean(Object bean)
Allow derived classes to programatically set the bean
|
protected void |
setBeanProperties(Object bean,
Map attributes)
Sets the properties on the bean.
|
void |
setIgnoreUnknownProperties(boolean ignoreUnknownProps)
If this tag finds an attribute in the XML that's not
ignored by
ignoreProperties and isn't a
bean property, should it throw an exception? |
protected void |
validateBeanProperties(Object bean,
Map attributes)
If
isIgnoreUnknownProperties() returns true, make sure that
every non-ignored (addIgnoreProperty(String) ) property
matches a writable property on the target bean. |
createAttributes, getAttributes, setAttribute
getAttributeType
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBody, getContext, getParent, invokeBody, setBody, setContext, setParent
public UseBeanTag()
public UseBeanTag(Class defaultClass)
public Object getBean()
getBean
in interface BeanSource
public void doTag(XMLOutput output) throws JellyTagException
Tag
doTag
in interface Tag
JellyTagException
protected void setBean(Object bean)
protected Class convertToClass(Object classObject) throws MissingAttributeException, ClassNotFoundException
protected Class loadClass(String className) throws ClassNotFoundException
ClassNotFoundException
protected Object newInstance(Class theClass, Map attributes, XMLOutput output) throws JellyTagException
JellyTagException
protected void setBeanProperties(Object bean, Map attributes) throws JellyTagException
getIgnorePropertySet()
.JellyTagException
protected void validateBeanProperties(Object bean, Map attributes) throws JellyTagException
isIgnoreUnknownProperties()
returns true, make sure that
every non-ignored (addIgnoreProperty(String)
) property
matches a writable property on the target bean.bean
- the bean to validateattributes
- the list of properties to validateJellyTagException
- when a property is not writeableprotected void processBean(String var, Object bean) throws JellyTagException
JellyTagException
protected Class getDefaultClass()
protected void addIgnoreProperty(String name)
name
- protected Set getIgnorePropertySet()
public boolean isIgnoreUnknownProperties()
#setIgnoreUnknownProperties(boolean)}
public void setIgnoreUnknownProperties(boolean ignoreUnknownProps)
ignoreProperties
and isn't a
bean property, should it throw an exception?ignoreUnknownProperties
- Sets ignoreUnknownProperties
.Copyright © 2014 Apache Software Foundation. All rights reserved.