|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.click.control.AbstractControl
org.apache.click.control.AbstractContainer
org.apache.click.control.Form
org.apache.click.extras.hibernate.HibernateForm
public class HibernateForm
Provides Hibernate data aware Form control: <form method='POST'>.
|
|
saveChanges() is called.
public class UserEdit extends Page { private HibernateForm form = new HibernateForm("form", User.class); public UserEdit() { form.add(new TextField("firstName")); form.add(new TextField("middleNames")); form.add(new TextField("FamilyName")); form.add(new Submit("ok", " OK ", this, "onOkClicked")); form.add(new Submit("cancel", this, "onCancelClicked")); form.setButtonAlign("right"); form.setLabelRequiredPrefix("<b>"); form.setLabelRequiredSuffix("</b>"); addControl(form); } public void setUser(User user) { form.setValueObject(user); } public boolean onOkClicked() { if (form.isValid()) { if (form.saveChanges()) { setRedirect("user-list.htm"); } } return true; } public boolean onCancelClicked() { setRedirect("user-list.htm"); return false; } }
SessionContext,
SessionFilter,
Serialized Form| Field Summary | |
|---|---|
protected HiddenField |
classField
The value object class name hidden field. |
protected static String |
FO_CLASS
The form value object classname parameter name. |
protected static String |
FO_ID
The form value object id parameter name. |
protected boolean |
metaDataApplied
The flag specifying that object validation meta data has been applied to the form fields. |
protected HiddenField |
oidField
The value object identifier hidden field. |
protected Session |
session
The Hibernate session. |
protected SessionFactory |
sessionFactory
The Hibernate session factory. |
| Fields inherited from class org.apache.click.control.Form |
|---|
actionURL, ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, buttonAlign, buttonList, buttonStyle, columns, defaultFieldSize, disabled, enctype, error, errorsAlign, errorsPosition, errorsStyle, fieldList, fieldStyle, fieldWidths, FOCUS_JAVASCRIPT, FORM_NAME, formSubmission, javaScriptValidation, labelAlign, labelsPosition, labelStyle, method, MULTIPART_FORM_DATA, POSITION_BOTTOM, POSITION_LEFT, POSITION_MIDDLE, POSITION_TOP, readonly, SUBMIT_CHECK, validate |
| Fields inherited from class org.apache.click.control.AbstractContainer |
|---|
controlMap, controls |
| Fields inherited from class org.apache.click.control.AbstractControl |
|---|
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles |
| Fields inherited from interface org.apache.click.Control |
|---|
CONTROL_MESSAGES |
| Constructor Summary | |
|---|---|
HibernateForm(String name,
Class<?> valueClass)
Create a new HibernateForm with the given form name and value object class. |
|
| Method Summary | |
|---|---|
protected void |
applyMetaData()
Applies the ClassMetadata validation database meta data to the form fields. |
protected String |
getClassname(Class<?> aClass)
Return the original classname for the given class removing any CGLib proxy information. |
Session |
getSession()
Return the form Hibernate Session. |
SessionFactory |
getSessionFactory()
Return the application Hibernate SessionFactory. |
Object |
getValueObject()
Return a Hibernate value object from the form with the form field values copied into the object's properties. |
boolean |
onProcess()
This method applies the object meta data to the form fields and then invokes the super.onProcess() method. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the HibernateForm. |
boolean |
saveChanges()
Save or update the object to the database and return true. |
void |
setSession(Session session)
Set the user's Hibernate Session. |
void |
setSessionFactory(SessionFactory sessionFactory)
Set the form Hibernate SessionFactory. |
void |
setValueObject(Object valueObject)
Set the given Hibernate value object in the form, copying the object's properties into the form field values. |
| Methods inherited from class org.apache.click.control.AbstractContainer |
|---|
contains, getControl, getControlMap, getControls, hasControls, onInit, onRender, renderChildren, renderContent, renderTagEnd, toString |
| Methods inherited from class org.apache.click.control.AbstractControl |
|---|
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHtmlImports, getId, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, removeBehavior, removeStyleClass, renderTagBegin, setActionListener, setAttribute, setId, setParent, setStyle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.click.Control |
|---|
getBehaviors, getContext, getId, getMessages, getName, getParent, hasBehaviors, isAjaxTarget, onDeploy, setParent |
| Field Detail |
|---|
protected static final String FO_CLASS
protected static final String FO_ID
protected HiddenField classField
protected HiddenField oidField
protected Session session
protected SessionFactory sessionFactory
protected boolean metaDataApplied
| Constructor Detail |
|---|
public HibernateForm(String name,
Class<?> valueClass)
name - the form namevalueClass - the value object class| Method Detail |
|---|
public Session getSession()
SessionContext.
Applications using alternative Hibernate Session sources should
set the form's session using the setSession(Session) method.
public void setSession(Session session)
session - the user's Hibernate sessionpublic SessionFactory getSessionFactory()
SessionContext.
Applications using an alternative Hibernate SessionFactory
sources should set the form's session factory using the
setSessionFactory(SessionFactory) method.
public void setSessionFactory(SessionFactory sessionFactory)
sessionFactory - the Hibernate SessionFactorypublic Object getValueObject()
public void setValueObject(Object valueObject)
valueObject - the Hibernate value object to set
public boolean saveChanges()
throws HibernateException
HibernateException - if a persistence error occurredpublic boolean onProcess()
onProcess in interface ControlonProcess in class FormForm.onProcess()public void render(HtmlStringBuffer buffer)
render in interface Controlrender in class Formbuffer - the specified buffer to render the control's output toAbstractContainer.toString()protected void applyMetaData()
protected String getClassname(Class<?> aClass)
aClass - the class to obtain the original name from
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||