Instance Demo

Ok, i’m a relative newbie to JSP and Xapp, but i using the property demo, i managed to make my page (which was for a cars database). Now, after i find a list of cars, and i click on the ID number that each car in the result set has (see List.jsp of the property example) I go to InstanceDemo.jsp which shows me details about the car. Now what i want to do is, have a link from this page, which will query my database further. I now want to get a list of dealers from my DB for THIS particular car, how would i do that?

Hope this is clear enough to understand.
X-Application Version: 3.1.2, 3.1.1
Tamino Version : 3.1.1
Platform : NT, Win2k, Solaris, …
WebContainer : Tomcat 3.3
JDK Version : 1.3.1

Hello,

There are two ways to implement this.


  • You create a query which is processed when the user clicks the link. To create the query you can use a form with hidden fields, e.g.

    <form name=“CarVendorQuery” method=“post” action="DisplayCarVendors.jsp?>
    <input type=?hidden? name=? queryschema(CarVendor)?>

    <input type=?hidden? name=?query(/CarVendor/Cars/Car,~=)?>


    Then, you assign the link to your verdor page with a JavaScript function. This function is responsible to set the value of the field ?query(/CarVendor/Cars/Car/@name,~=)?. Its value identifies the car the user selected. For example

    <bdm:display select=?/Car/name?>Vendors</bdm:display>

    On the Java Server Page (DisplayCarVendors.jsp) you can use a browse tag with document attribute CarVendorList to show the result.

  • The alternative is to insert a directcommand into the page that shows the vedors.

    bdm:form
    <bdm:directcommand type=?query? document=?CarVendorList? schema=“CarVendor” queryparm=?USEBODY?>
    ./Cars/Car~=<bdm:form document=?selectedCar?><bdm:display select=?/Car/@name?/></bdm:form>
    </bdm:directcommand>
    </bdm:form>



Therefore, interesting for you could be the chapter Defining and Processing Queries of X-Application?s JSP documentation to get more detailed information about queries.
For more information about the tag directcommand have a look at the JSP tag lib reference of X-Application.

Remark: Since I don?t know your schema(s) you have to adapt the paths I used to select the nodes of your documents.

It could be that you will find some typos in my example code. I was to lazy to create an example for testing it. Nevertheless, I hope I could give you an idea how to solve your problem.

Bye,
Christian.

Ok christian,

i managed to do it by doing a bdm:action read and linking to another page where i did a bdm loop to retrieve the list of my dealers.

Now i tried to do that same. For some reason fillselect refuses to work for me, i tried it many times, so what i did was, i used loop again to retrieve the names of the cities the car dealers were in and display them in a drop down. The user can now select the city he wants to find a dealer in and when he clicks the submit button, he will get details about that dealer. But, when i implement it, i get a query error.

Heres the code:



All
<bdm:loop module=“bdProp” select="/car" iterate=“dealer” targetbase=“dealer”>
<option value="<bdm:display select="/dCity"/>"><bdm:display select="$POS"/>: <bdm:display select="/dCity"/>
</bdm:loop>


this successfully shows me the name of each city in which the car has dealers, but when i click the submit button i get the following error:

DesignException: 157: Exception when creating query.
com.softwareag.xtools.xapplication.store.StoreException
collection for the doctype ‘’ is not registered.


now i have the exact same drop down code on my homepage which queries the car list and gets me a bunch of cars, that works very well. Why do i get this error on the Instancedemo.jsp page then?

-Sumier

ok, i managed to work around that, now my dropdown works, it doesn’t query properly tho
this is the structure of my car table:



















so now, the drop down has to target one of the dealers and print the value. each drop down entry shows me the city in which the dealer is (dCity is an element within dealer)
in my drop down code i put the following



but when i press the submit button i always get the first dealer name, nothing else. the page which displays the list doesn’t have a bdm:browse tag, since only one entry has to be displayed.

whata m i doing wrong?

Hello Sumier,

yes, the problem of your dropdown box was the missing field ?queryschema(car)?. The loop to fill your select box is ok. You should have a look at the contribution of my colleague Thorsten Raab (New Tags available). He designed a bdm:select tag which replaces X-Application?s fillselect tag. Perhaps, this new tag helps you to fill select boxes.

Now, for your problem with the query processing:

When you create the query with the select box as you described it by your former posts, X-Application sends the following xql expression to Tamino

/car[dealer/dcity = ?the selected city name?]

The effect is that a set of car documents returned. Each document of the set contains at least one dealer who is in the selected city. I think, that was not your intension. I assume you want to have a filter which displays all the dealers who are part of already selected car document and who are in the selected city.

The query would be

/Property[@ino:id=id of the selected car]/dealer[dcity=‘selected city name’]

Currently, X-Application doesn?t support queries for sub-nodes of a document. We know about this limitation and are looking for a solution.

But, what could you do for your current application?


  • You could work with dealer documents. In this case, you would change your schema. You had a doctype car and a doctype dealer. Documents of type dealer had an ID field and car documents had a list of dealer id. Furthermore, dealers had a list of car ids referring to the cars they sell.

  • You could save the selected city name within an own request parameter, e.g. . On the page where you display the dealers you use embedded Java code to get the value of this request parameter and to filter the entries of the loop tag by this value.


Both of these solutions are not easy to be implemented. Perhaps, somebody else has a better solution.

Bye,
Christian.