cancel
Showing results for 
Search instead for 
Did you mean: 

search for a record

Former Member
0 Kudos

<input type="text" name="searchtext" size="25">

<input type="submit" value="search" name="_event_searchpage">

how do i do a search function using syncBoAPI?

Accepted Solutions (0)

Answers (1)

Answers (1)

sandeep_rs
Advisor
Advisor
0 Kudos

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

Former Member
0 Kudos

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

sandeep_rs
Advisor
Advisor
0 Kudos

Hi Yzme,

That looks fine. Is it not working?

Do let me know the problem you are facing...

Best Regards,

Sandeep

Former Member
0 Kudos

the code is generated automatically,

i need to modify this to pass in the params eg : vendorname

to retrieve the specific rows

sandeep_rs
Advisor
Advisor
0 Kudos

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

Former Member
0 Kudos

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

sandeep_rs
Advisor
Advisor
0 Kudos

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