T
- the bean type for this ActionProvider
s perform(...)
-method. Must match
MetaData.getBindClass()
of the Datasource
used by the Action
public interface ActionProvider<T>
ActionProvider
usually performs a CRUD-action on a domain object. The implementing class needs to be
defined in the application's beans.xml
. This bean is then being referenced in a concrete Action
:
<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 one
ActionProvider
per Action
, since the Bean
can be
parameterized using different BeanOption
s. So for example, the above defined bean could also be used for
creating a new domain object, using another BeanOption
:
<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
}
Modifier and Type | Method and Description |
---|---|
void |
perform(Site site,
Application application,
Environment environment,
Options options,
Request request,
T formBean,
FieldProcessor fieldProcessor)
Performs an action on the given
formBean |
void perform(Site site, Application application, Environment environment, Options options, Request request, T formBean, FieldProcessor fieldProcessor)
formBean
site
- the current Site
application
- the current Application
environment
- the current Environment
options
- the Options
for this ActionProvider
request
- the current Request
formBean
- the bean which has been createdfieldProcessor
- the FieldProcessor
containing all writable FieldDef
initions for this actionCopyright © 2011–2023 aiticon GmbH. All rights reserved.