sorting

X-Application Version: 3.1.2
Tamino Version : 3.1.1
Platform : Solaris 8
WebContainer : Tomcat 4.03
JDK Version : 1.3.1

Any pointer as how to sort the results on the same page, when the query is done using bdm:directcommand type=query.

The documentation mentions use of form element with name querysort and type hidden, but it does not suffice if the sorting is to be done on the same page as the result.

regards
Amit

[This message was edited by Christian Freytag on 26 Jul 2002 at 10:47.]

Hello Amit,

sorting as described in the documentation is only possible for query pages, not for directcommand.

But it is not difficult to add sorting to directcommand query.

Let me try to outline a possible solution:


  • add an attribute “sortby” to the xapplication.tld file in the web-inf directory of your application. This could be done similar to the “queryparm” attribute.
  • open the class DirectCommandTag.java in directory src\com\softwareag\xtools\xapplication\jsp\taglib
    - add an import statement:
    import com.softwareag.xtools.xapplication.businessdocument.QuerySort;
    - add a setter method
    code:

    private String sortby = null;
    public void setSortby(String sortby) {
    this.sortby = sortby;
    }


    - change method processaction() to add a new sort object:
    code:

    else if (type.equals(“query”)) {
    QueryContainer qc=new QueryContainer(schema);
    qc.add(new QueryFilter(queryParm));
    if (sortby != null) qc.add(new QuerySort(sortby));
    sessionContext.setQuery(requestContext, getDocument(),qc);
    }


    - you might like to add the parameter to the traceInfo, method endDumpDiagnosis()
  • rebuild X-Application:
    - build.cmd in x-application root directory.
    - copy lib\debug\xapplication.jar into your-web-app-dir\web-inf\lib
    - restart tomcat
  • test the new attribute:
    <bdm:directcommand type=“query” schema=“yourSchema” queryparm=“yourFilter” sortby=“./@Category

If you succeed, you could post the solution (new class plus tld file) into the community Contribution Forum to share this with others.

Regards, Harald

[This message was edited by Harald Wolf on 05 Apr 2002 at 18:03.]

Hello,

for X-Application 3.1.3 the solution for directcommand is to use the attribute ‘arg’ which can contain a XQL expression inclusive ‘sortby’ or ‘sortall’ clause, e.g.

<xapp:directcommand type=“query” arg=“/Property[./Address/State~=‘N*’] sortby(./Price)” …/>

Have a look at the documentation and the simple examples of X-Application 3.1.3. It is also possible to use ‘variables’ for parameterizing the query expression of the ‘arg’ attribute.

Bye,
Christian.