Define actions available on a search form with the actions property on the ComponentSearchPresenter object:
<bean id="EnvelopeSearch" class="com.flower.docs.gui.client.search.ComponentSearchPresenter" scope="prototype">
<property name="actions">
<list>
<ref bean="myAction1" />
<ref bean="myAction2" />
</list>
</property>
</bean>
By default, these actions are only visible once the search has been executed. To change this behaviour, you can add the following property:
<property name="enableActionsIfDirty" value="false" />
Types of action
Component creation
An action can be added to allow users to create a component from a search form. This type of action pre-indexes the component to be created based on the search criteria.
For example, if a user searches for a document in the Invoice class with a status tag whose value is paid, then the action will create a document with the same information.
<bean id="EnvelopeSearch" class="com.flower.docs.gui.client.search.ComponentSearchPresenter" scope="prototype">
<property name="actions">
<list>
<ref bean="createComponentFromSearchAction" />
</list>
</property>
</bean>
<bean id="createComponentFromSearchAction" class="com.flower.docs.gui.client.search.action.ComponentCreationActionPresenter">
<property name="componentRef">
<bean class="com.flower.docs.domain.component.ComponentReference">
<property name="category">
<value type="com.flower.docs.domain.component.Category">FOLDER</value>
</property>
<property name="id">
<bean class="com.flower.docs.domain.common.Id">
<property name="value" value="Agency" />
</bean>
</property>
</bean>
</property>
</bean>
Screen change
GoToPlaceActionPresenter type actions are used to switch screens.
<bean class="com.flower.docs.gui.client.search.action.GoToPlaceActionPresenter">
<constructor-arg type="java.util.List">
<list>
<bean class="com.flower.docs.domain.i18n.I18NLabel">
<property name="language" value="EN"/>
<property name="value" value="Create envelope"/>
</bean>
<bean class="com.flower.docs.domain.i18n.I18NLabel">
<property name="language" value="FR"/>
<property name="value" value="Créer une enveloppe"/>
</bean>
</list>
</constructor-arg>
<property name="place">
<bean class="com.flower.docs.gui.client.search.CreateWithVerificationPlace">
<property name="id">
<bean class="com.flower.docs.domain.common.Id">
<property name="value" value="EEnvelopeSearch" />
</bean>
</property>
<property name="category">
<value type="com.flower.docs.domain.component.Category">TASK</value>
</property>
</bean>
</property>
</bean>
Activation
Control when an action is available with the enablingStrategy property. Built-in strategies:
- Whatever the search results (default):
AnyResultEnablingStrategy
<bean class="com.flower.docs.gui.client.search.action.AnyResultEnablingStrategy" />
- Only if the search leads to no results:
NoResultEnablingStrategy
<bean class="com.flower.docs.gui.client.search.action.NoResultEnablingStrategy" />
-
If the user has selected a certain number of components based on an operator:
MultipleComponentsEnablingStrategyThis activation strategy has two properties:operator: The operator used to evaluate the number of components selected. The following operators are available:EQUALS_TO,GREATER_THAN,LESS_THANandDIFFERENT.componentsCount: The number of components
Example: Activating the action, if the number of selected components is equal or more than 2.
<bean class="com.flower.docs.gui.client.search.action.MultipleComponentsEnablingStrategy">
<property name="componentsCount" value="2"/>
<property name="operator">
<value type="com.flower.docs.domain.search.Operators">GREATER_THAN</value>
</property>
</bean>