1. Integration with Seam Query Component
Integration with Seam Query Component
In the case of Seam, there is the option to use a Query component as the remote data provider. In particular filtering is supported by the use of Seam Query restrictions. This can be done by using the Seam-specific implementation of PagedQuery.
import org.granite.tide.seam.framework.PagedQuery;
Seam.getInstance().addComponent("people", PagedQuery);
You then have to define your Seam Query component:
<component name="examplePerson" class="test.granite.ejb3.entity.Person"/> <framework:entity-query name="people" ejbql="select p from Person p" max-results="36"> <framework:restrictions> <value>lower(p.lastName) like lower( #{examplePerson.lastName} || '%' )</value> </framework:restrictions> </framework:entity-query>
This is a very standard Seam Query definition, only the max-results property is important as it will be used as the page size for the client component.
| Note that defining max-results is mandatory when using server page size and it is necessary that the max-results page size is greater than the expected maximum size of the UI component that will be bound to the collection. |
When using client side page size definition, you can omit max-results.
To change filter parameters on the client-side, you just have to set values on the restriction object (here examplePerson) in the context. Tide tracks the changes on the object on the Flex side and will update the server filter instance accordingly. Internally, PagedQuery forces the detected restriction variables to be synchronized remotely with the server so you don't have to do [Out(remote="true")] or Seam.getInstance().setComponentRemoteSync("examplePerson", true) manually.
For example, you can use a filter like this :
<mx:Script> [In(create="true")] public var examplePerson:Person; [In] public var people:PagedQuery; </mx:Script> <mx:TextInput id="lastName" text="{examplePerson.lastName}"/> <mx:Button label="Search" click="people.refresh()"/> <mx:DataGrid id="peopleGrid" dataProvider="{people}"> ... </mx:DataGrid>
