Modify default beahvior of JSP example scripts .....

User e25fe1ac40

14-12-2004 22:21:38

I woould like to modify the behavior of the search example scripts from their defaults: 1) instead of having search results sorted by 'cd_id', I would like to sort by another field value in a custom table I've built and 2) I would like the "startup" behavior of the example search session scripts to pull up not ALL structures, but only those possessing a certain value in a particular field in my customized structure table ... the closest thing I have seen in the documentation so far for ordering the results data is the setting "chemaxon.jchem.db.JChemSearch(ORDERING_BY_ID, [1 or 0]) ....





I am using JChem v 2.3 with MySQL as my database engine ... thanks for your help in advance ....

ChemAxon 9c0afc9aaf

15-12-2004 12:31:39

1. You can use JChemSearch.setStringToAppend():





http://www.jchem.com/doc/api/chemaxon/jchem/db/JChemSearch.html#setStringToAppend(java.lang.String)





Please note, that it only works with caching turned off.


(as of JChem 3.0.x)





If you want to use it with caching, then you should write your


own code for this:





a. get the results (cd_id) values from JChemSearch


b. run your own (JDBC) SQL query to get all cd_id in the order you need them


c. reorder the results according to the result of your SQL query





Probably we will add some functionality to the API later to make this easier.








2. You should use filterQuery for this purpose:





http://www.jchem.com/doc/api/chemaxon/jchem/db/JChemSearch.html#setFilterQuery(java.lang.String)





Please note that the JSP example already uses filterQuery


if some conditions are specified, so you should append to this filterQuery, rather than overriding it.


(otherwise the filter conditions won't work)