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

Parameters: object, the map with all the attributes of the object that will be persisted.
Return true, if validation is passed, false otherwise.

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

Parameters: object, the map with all the attributes of the object that will be persisted.
Return true, if validation is passed, false otherwise.

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

Parameters: object, the map with all the attributes of the object that will be deleted.
Return true, if validation is passed, false otherwise.

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")

Return Resolution

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")

Return Resolution

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")

Return Resolution

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")

Return Resolution

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")

Return Resolution

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")

Return Resolution

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.

originalPath

A string with the current path. 

model

A com.manydesigns.portofino.model.Model, which stores all the information about the databases (e.g. tables, columns, ...).

portofinoConfiguration

This object stores all the configuration properties.

application

The Application object which store all common data of your application(e.g. all Hibernate sessions).

session

The Hibernate Session object.

object

A map with the properties of the object you are working on.

objects

A list of map which is populated by a result of a search 

searchForm

com.manydesigns.elements.forms.SearchForm object which represents the html form for the search. 

tableForm

com.manydesigns.elements.forms.TableForm object which represents an html form with a table to visualize a list of objects. 

form

com.manydesigns.elements.forms.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