on 07-16-2007 9:19 AM
<input type="text" name="searchtext" size="25">
<input type="submit" value="search" name="_event_searchpage">
how do i do a search function using syncBoAPI?
Hi Yzme,
If you are talking about searching a particular record present in the client database, you will have to make use of the appropriate persistence APIs (for smart sync applications you can use the persistence APIs exposed by the smart sync layer).
Typically, this means you will have to pass on the search string entered by the user in the JSP onto the application servlet. There should then be code to call the persistence manager, create queries and conditions from the APIs exposed and then execute the query passing the correct classDescriptor as paramaeter (each class descriptor will map to the storage of each object, in essence it will provide MI with the knowledge on which database table to hit to execute the query).
Best Regards,
Sandeep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
how do i modify this
public MeIterator getRowInstances(String syncBoName,int start,int count,int sortIndex,boolean sortOrder,String filter) {
System.out.println("getRowInstance: " +syncBoName);
try {
SyncBoDescriptor sbd =descriptorFacade.getSyncBoDescriptor(syncBoName);
MeIterator iteratorRows = null;
if (sortIndex < 0) {
iteratorRows = dataFacade.getSyncBos(sbd).iterator();
} else {
SmartSyncQueryFactory queryFactory =SmartSyncRuntime.getInstance().getQueryFactory();
RowDescriptor rd = sbd.getTopRowDescriptor();
FieldDescriptor fd =rd.getFieldDescriptor(arrayHeaderFieldNames[sortIndex]);
BasisFieldType bft = fd.getFieldType();
RelationalOperatorType filterOperator;
if (bft == BasisFieldType.C) {
filterOperator = RelationalOperatorType.STARTS_WITH;
} else {
filterOperator = RelationalOperatorType.GREATER_THAN;
}
System.err.println("field name:" +fd.getName() +" OP: " +filterOperator +" filter : "+filter);
Condition cond =queryFactory.createCondition(fd, filterOperator, filter);
SortOrder singleSortOrder =queryFactory.createSortOrder(fd, sortOrder);
Query syncBoQuery =queryFactory.createQuery(rd,cond,singleSortOrder,start,count);
iteratorRows = dataFacade.getRows(syncBoQuery).iterator();
}
return iteratorRows;
} catch (PersistenceException pex) {
System.out.println(pex.getMessage());
return null;
}
}
Message was edited by:
yzme yzme
Hi Yzme,
Not sure if i understand what is the problem in doing that.
Actually the method itself is fine. As you have rightly said you need to pass the search string (vendor name in your case) to the method. For this you have to parse the request object coming in from the http request to your servlet. Something like:
String searchString = request.getParameter("VendorName");
And then pass the searchString as the filter to the method.
Best Regards,
Sandeep
http://i192.photobucket.com/albums/z231/yzme/page2.jpg
Search [ ]
[submit]
filter----> LGORT=0001
i need to change this code
FieldDescriptor fd =rd.getFieldDescriptor(arrayHeaderFieldNames[sortIndex]);
TO
FieldDescriptor fd =rd.getFieldDescriptor("LGORT");
then i will still get the same no of rows but the figure in the LGORT COLUMNS ALL change to 0001...
it doesnt filter
Message was edited by:
yzme yzme
Hi Yzme,
In that case, instead of submitting "LGORT" from the JSP, you can get the column index and the value ("0001"). Then your code will work just fine if you pass "0001" to filter and the column index to sortIndex in the method.
Alternatively, you can get "LGORT", the column name itself onto your code like
columnName=request.getParameter("SearchOnColumnName");
and then instead of
rd.getFieldDescriptor(arrayHeaderFieldNames[sortIndex]);
you can use something like:
rd.getFieldDescriptor(columnName);
Hope I am not confusing you too much
Best Regards,
Sandeep
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.