|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.template.AbstractBeanHandler
public abstract class AbstractBeanHandler
| Constructor Summary | |
|---|---|
AbstractBeanHandler()
|
|
| Method Summary | |
|---|---|
protected abstract MimeType |
getMimeType()
|
protected abstract Map<String,Object> |
getPropertyValues(Template template,
Object bean,
String prefix)
|
void |
removeBean(Template template,
Object bean,
String prefix)
Reverts all values to their defaults when the identifiers match properties of the given bean preceded by the given prefix, whether or not those values were set with a previous call to Template.setBean(Object). |
void |
setBean(Template template,
Object bean,
String prefix,
boolean encode)
Sets all values in the given template whose names match names of properties in the given bean, preceded by the given prefix, if present. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.uwyn.rife.template.BeanHandler |
|---|
getFormBuilder |
| Constructor Detail |
|---|
public AbstractBeanHandler()
| Method Detail |
|---|
protected abstract MimeType getMimeType()
protected abstract Map<String,Object> getPropertyValues(Template template,
Object bean,
String prefix)
throws BeanUtilsException
BeanUtilsException
public void setBean(Template template,
Object bean,
String prefix,
boolean encode)
throws TemplateException
BeanHandlernull, it is ignored.
For example, given a class:
class Person {
private String first;
private String last;
public String getFirstName() { return first; }
public void setFirstName(String name) { this.first = name; }
public String getLastName() { return last; }
public void setLastName(String name) { this.last = name; }
}
And given a template:
Hello <!--V 'NAME:firstName'/--> <!--V 'NAME:lastName'/-->.
Calling this method with an instance of Person where
first was "Jim" and last was "James",
and the prefix "NAME:", would produce:
Hello Jim James.
Calling this method is equivalent to calling setValue individually for each
property of the bean prefixed with the given prefix.
If encode is true, this method will use
the template's encoder to encode the
bean properties before setting the values.
Only bean properties will be considered for insertion in the template. This means only properties with a getter and a setter will be considered.
setBean in interface BeanHandlertemplate - the template whose values will be filledbean - a bean whose properties will be used to fill in values in
the templateprefix - the prefix of values which will be filled with the given
bean's property values
TemplateException - if this template has no bean handling
capability; or
an error occurred during the introspection of the bean
public void removeBean(Template template,
Object bean,
String prefix)
throws TemplateException
BeanHandlerTemplate.setBean(Object). The values of the bean's properties are
ignored.
Calling this method is equivalent to calling Template.removeValue(java.lang.String) once for the name of each property of the given
bean, prefixed with the given prefix.
removeBean in interface BeanHandlerbean - a bean whose property names will be used to determine
whetherprefix - a prefix
TemplateException - if this template has no bean handling
capability; or
an error occurred during the introspection of the bean
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||