I have scenerio where I need to use FilterBuilder in the ListGrid and the Data in the List Grid is coming from the CustomDatasource. Now when I filter the values using the filter builder i am unable to do it
I am using smartGWT 2.5 Pro version, smartclient 8.1 version
AddressDataSourceDao.java
customeraddressDMI.ds.xml
main source file
Here the gwt inbuilt filter works perfect but the Filter builder does'nt work can any please help me in this with some sample code ??
I am using smartGWT 2.5 Pro version, smartclient 8.1 version
AddressDataSourceDao.java
Code:
package in.systemintegration.server.dao;
public class AddressDataSourceDao extends BasicDataSource {
/**
*
*/
private static final long serialVersionUID = 1L;
protected String entityName;
protected Session currentSession;
protected static Configuration hibernateConfig;
protected static SessionFactory sessionFactory;
// We are only overriding execute() to provide a central point for
// initialization and
// session/transaction management - for actual data operations, it is more
// appropriate to
// override executeFetch(), et al, as we do further down in this class
public DSResponse execute(DSRequest dsRequest) throws Exception
{
// Initialize the Hibernate Configuration if necessary
if (hibernateConfig == null)
{
createConfig();
}
if (entityName == null)
{
// Pick up the fully-qualified class name from the DataSource
// definition. The property
// can be called anything you like - here, we are expecting to find
// a "mappedBeanClass"
// property in the DataSource definition
entityName = getProperty("mappedBeanClass");
if(hibernateConfig.getClassMapping(entityName) == null)
{
// Config problem - the bean named in the .ds.xml file is not
// mapped in Hibernate
}
}
this.currentSession = sessionFactory.openSession();
Transaction tx = currentSession.beginTransaction();
try
{
return super.execute(dsRequest);
}
finally
{
tx.commit();
currentSession.close();
}
}
// This method is static and synchronized to avoid threading issues when
// multiple requests
// are sent during server startup
private static synchronized void createConfig()
{
hibernateConfig = AddressDSConnection.hibernateConfiguration();
sessionFactory = hibernateConfig.buildSessionFactory();
}
public DSResponse executeFetch(DSRequest dsRequest) throws Exception
{
DSResponse dsResponse = new DSResponse();
dsResponse.setSuccess();
System.out.println("CRITERIA ::: "+dsRequest.getCriteria().toString());
Map<?,?> criteriaMap = dsRequest.getCriteria();
String sql = "";
if(criteriaMap.containsKey("customerId"))
{
sql = "From in.systemintegration.server.dto.CustomerInfo customer Where customer.customerId = " + criteriaMap.get("customerId") ;
List<?> matchingItems = currentSession.createQuery(sql).list();
List<AddressInfo> billingAddress = null;
for (Object cust : matchingItems)
{
billingAddress = new ArrayList<AddressInfo>();
CustomerInfo customer = (CustomerInfo) cust;
for (AddressInfo addressInfo : customer.getAddresses())
{
billingAddress.add(addressInfo);
}
}
dsResponse.setData(billingAddress);
}
return dsResponse;
}
}
Code:
<DataSource ID="customeraddressDMI"
serverConstructor="in.systemintegration.server.dao.AddressDataSourceDao"
mappedBeanClass="in.systemintegration.server.dto.AddressInfo" >
<fields>
<field name="addressId" type="sequence" hidden="true" primaryKey="true" multiple="true"/>
<field name="userAssignedId" type="text" title="Nick Name" required="true" />
<field name="street1" type="text" title="Street1" required="true" />
<field name="street2" type="text" title="Street2" />
<field name="street3" type="text" title="Street3 " />
<field name="city" type="text" title="City" />
<field name="state" type="text" title="State" />
<field name="zipcode" type="text" title="Zip Code" required="true" />
</fields>
</DataSource>
Code:
final ListGrid addList = new GetListGrid();
addList.setWidth100();
addList.setHeight100();
addList.setBodyStyleName("listGridBody");
addList.setStyleName("listGrid");
addList.setBaseStyle("listGridCell");
addList.setLeaveScrollbarGap(false);
addList.setDataSource(DataSource.get("customeraddressDMI"));
//addList.setAutoFetchData(true);
addList.setDataFetchMode(FetchMode.BASIC);
addList.setUseAllDataSourceFields(true);
final FilterBuilder filterBuilder = new FilterBuilder();
filterBuilder.setDataSource(DataSource.get(ADDRESS_TEMP_DATASOURCE));
filterBuilder.setShowSubClauseButton(false);
Comment