Hi all,
I'm trying to execute simple datasource example with form filter and grid.
Here is my code snippets:
1. Client Code (UI)
That's all into client side,
Now I've to separate Datasource file.
1.OpersDS (XML File)
2. And grid datasource
That's all
The Problem :
If I select something from selectitem search works perfectly and grid is filtered,
but i have not selected anything from selectitem i got an exception , criteria field is not set. :(
and i got sql syntax exception.
What i did wrong ?
Thanks In advance,
Regards,
Paata Lominadze
I'm trying to execute simple datasource example with form filter and grid.
Here is my code snippets:
1. Client Code (UI)
Code:
// Form DynamicForm searchForm = new DynamicForm(); searchForm.setAutoFocus(true); searchForm.setWidth(700); searchForm.setTitleWidth(200); // Select Item SelectItem operatorItem = new SelectItem(); operatorItem.setTitle("Operator); operatorItem.setType("comboBox"); operatorItem.setName("operatorId"); // Add Select Item into Form. searchForm.setFields(operatorItem); // Set Datasource to SelectItem DataSource operatorsDS = DataSource.get("OpersDS"); operatorItem.setOptionDataSource(persons); // And the grid final ListGrid sessionsGrid = new ListGrid(); sessionsGrid.setWidth(820); sessionsGrid.setHeight(224); sessionsGrid.setDataSource(sessionsDS); sessionsGrid.setCanEdit(false); sessionsGrid.setCanRemoveRecords(false); sessionsGrid.setFetchOperation("customSearch"); // search button click. buttonItem.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Criteria criteria = sessionsGrid.getCriteria(); if (criteria == null) { criteria = new Criteria(); } Criteria formCriteria = searchForm.getValuesAsCriteria(); criteria.addCriteria(formCriteria); sessionsGrid.invalidateCache(); sessionsGrid.filterData(criteria); } });
That's all into client side,
Now I've to separate Datasource file.
1.OpersDS (XML File)
Code:
<DataSource ID="OpersDS" serverConstructor="com.isomorphic.jpa.JPADataSource" beanClassName="com.info08.billing.callcenter.shared.entity.Person"> <fields> <field name="operatorId" type="integer" hidden="true" primaryKey="true" /> <field name="fullPersonName" type="text" title="Person Name"/> </fields> </DataSource>
Code:
<DataSource ID="LogSessions_DataSource" serverType="sql" tableName="info.log_sessions" qualifyColumnNames="false"> <fields> <!-- Some Fields Defined Here --> </fields> <operationBindings> <operationBinding operationId="customSearch" operationType="fetch" customFields="f1, f2, and so on"> <selectClause> f1, f2 </selectClause> <tableClause> Tbl1 t1, Tbl2 t2, </tableClause> <whereClause><![CDATA[ t1.f3 = t2.f4(+) and t1.f5 = $criteria.operatorId ]]> </whereClause> <groupClause> <!-- group by options --> </groupClause> <orderClause> <!-- order by options --> </orderClause> <groupWhereClause>($defaultWhereClause)</groupWhereClause> </operationBinding> </operationBindings> </DataSource>
That's all
The Problem :
If I select something from selectitem search works perfectly and grid is filtered,
but i have not selected anything from selectitem i got an exception , criteria field is not set. :(
and i got sql syntax exception.
What i did wrong ?
Thanks In advance,
Regards,
Paata Lominadze
Comment