Package org.appng.api
Interface ActionProvider<T>
-
- Type Parameters:
T
- the bean type for thisActionProvider
sperform(...)
-method. Must matchMetaData.getBindClass()
of theDatasource
used by theAction
public interface ActionProvider<T>
AnActionProvider
usually performs a CRUD-action on a domain object. The implementing class needs to be defined in the application'sbeans.xml
. This bean is then being referenced in a concreteAction
:<action id="update"> <config> <title id="issue.update" /> <params> <param name="form_action" /> <param name="issueName" /> <param name="edit" /> </params> </config> <condition expression="${form_action eq 'update' and not empty issueName}" /> <datasource id="issue"> <params> <param name="issueName">${issueName}</param> <param name="edit">${edit}</param> </params> </datasource> <bean id="issues"> <option name="action" id="update" issue="${issueName}" /> </bean> </action>
There is no need to implement oneActionProvider
perAction
, since theBean
can be parameterized using differentBeanOption
s. So for example, the above defined bean could also be used for creating a new domain object, using anotherBeanOption
:<action id="create"> <config> <title id="issue.create" /> </config> <condition expression="${form_action eq 'create'}" /> <datasource id="new_issue"> <params> <param name="form_action" /> </params> </datasource> <bean id="issues"> <option name="action" id="create" /> </bean> </action>
The distinction between create and update then can be done like this:if ("create".equals(options.getOptionValue("action", "id"))) { // create new domain object } else if ("update".equals(options.getOptionValue("action", "id"))){ // update existing domain object }
- Author:
- Matthias Müller
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
perform(Site site, Application application, Environment environment, Options options, Request request, T formBean, FieldProcessor fieldProcessor)
Performs an action on the givenformBean
-
-
-
Method Detail
-
perform
void perform(Site site, Application application, Environment environment, Options options, Request request, T formBean, FieldProcessor fieldProcessor)
Performs an action on the givenformBean
- Parameters:
site
- the currentSite
application
- the currentApplication
environment
- the currentEnvironment
options
- theOptions
for thisActionProvider
request
- the currentRequest
formBean
- the bean which has been createdfieldProcessor
- theFieldProcessor
containing all writableFieldDef
initions for this action
-
-