Customization
A CRUD page extends com.manydesigns.portofino.pageactions.crud.CrudAction, you can override any method of it.
SUMMARY
Hooks
CrudAction defines the following hooks, that are predefined methods in Portofino, to extend its behavior.
void createSetup(Object object)
This method is called before the form is displayed to the user. E.g. by changing this method it is possible to set default values.
The parameter "object" is a Map with all the attributes of the object that will be created.
object.attribute_name = value allows you to access and modify an attribute of the object.
Parameters: object, the map with all the attributes of the object that will be created.
boolean createValidate(Object object)
This method is called before persisting the object in the db. You can customize validation and return false if your condition are not satisfied.
Use static methods of com.manydesigns.elements.messages.SessionMessages to add error messages to the user
void createPostProcess(Object object)
This method is called after the object is created and persisted in the db. You can use this method for post create operation (e.g. notifications)
Parameters: object, the map with all the attributes of the object that was created.
void editSetup(Object object)
This method is called before the edit form is displayed to the user. E.g. by changing this method it is possible set default values.
The parameter "object" is a Map with all the attributes of the object that will be created.
Parameters: object, the map with all the attributes of the object that will be edited.
boolean editValidate(Object object)
This method is called before persisting the modified object in the db. You can customize validation and return false if your condition are not satisfied.
Use static methods of com.manydesigns.elements.messages.SessionMessages to add error messages to the user
void editPostProcess(Object object)
This method is called after the object is persisted in the db. You can use this method for post edit operation (e.g. notifications)
Parameters: object, the map with all the attributes of the object that was created.
boolean deleteValidate(Object object)
This method is called before the object deletion. You can customize validation and return false if your condition are not satisfied.
Use static methods of com.manydesigns.elements.messages.SessionMessages to add messages to the user
void deletePostProcess(Object object)
This method is called after the object is deleted. You can use this method for post delete operation (e.g. notifications)
Parameters: object, the map with all the attributes of the object that was deleted.
Resolution getCreateView()
This method returns the Resolution for the Create view. E.g. you can redirect to an other jsp: return new ForwardResolution("/my.jsp")
Resolution getEmbeddedSearchView()
This method returns the Resolution for the Edit View. E.g. you can redirect to an other jsp: return new ForwardResolution("/my.jsp")
Resolution getBulkEditView()
This method returns the Resolution for the Bulk Edit view. E.g. you can redirect to an other jsp: return new ForwardResolution("/my.jsp")
Resolution getReadView()
This method returns the Resolution for the Read view. E.g. you can redirect to an other jsp: return new ForwardResolution("/my.jsp")
Resolution getSearchView()
This method returns the Resolution for the Search view. E.g. you can redirect to an other jsp: return new ForwardResolution("/my.jsp")
getEmbeddedSearchView
This method returns the Resolution for the Embedded Search view. This search view is the view of an embedded crud page in its father E.g. you can redirect to an other jsp: return new ForwardResolution("/my.jsp")
Useful objects
The action gives to you the following objects that you can use in your methods:
context
The Stripes context, e.g. you can obtain the request from it.
portofinoConfiguration
This object stores all the configuration properties.
persistence
The Persistence object which provides access to database persistency (by exposing Hibernate sessions).
session
The Hibernate Session object for the current request.
object
A map with the properties of the object you are working on.
objects
A list of maps which is populated by the result of a search.
searchForm
A SearchForm object which represents the html form for the search.
tableForm
A TableForm object which represents an html form with a table to visualize a list of objects.
form
A Form object which represents a form to read/edit/create an object.
selection
A String array with the key obtained by a multiple selection of objects (e.g. for a bulk edit or delete)
logger
The org.slf4j.Logger that you can use to log your activities.
ognlContext
A map we all the objects in ognl. E.g., you can take an attribute of the father (using the "Variable" specified in the configuration) object with ognlContext.father.attribute