Source for Country and State Select as used in the Property

X-Application Version: 4.1.1
Tamino Version : 4.1.1
Platform : Win2k
WebContainer : Tamocat 4.1.1
JDK Version : 1.4.1

Hi all

I am looking for the ‘source code’ i.e. the JSP pages for the

 demoX-App/RealEstateDemo/createProperty.jsp 

, the property demo on the demo zone. I am interested in the functionality of the selection list of the Country and the State and the reload of the page with the State values filled once the Country has been selected.

Any similar example will also do.

Thanks
Elsabe Jacobs

I still have not had any response to this. Surely the code must be around somewhere and available?

Regards
Elsabe Jacobs

Hello,

I forwarded your request to my colleague who implemented the X-Application demo application. He will be back from holidays next Monday (17. Nov. 2003) and will support you.

Many thanks.
Bye,
Christian.

Thank you
Elsabe

Hi Elsabe,

attached I post an extract from the jsp containing the code which is relevant for you.

The functionality of the country / state selection list is basically the following:

For the country selection list the list of available countries is read from a master-xml-document PropAdmin.xml which is stored in Tamino. An xapp:select tag displays the content of the country elements in PropAdmin.xml as html option tags.

For the state selection list the list of available states is read from the master-xml-document using the selected country as a filter (XPath expression:

 /PropAdmin/allStates[@country='Germany']/state 

). An xapp:select tag then displays the state elements as html option tags.

Please note that this solution was developed for Tamino 3.x, which means no XML XQuery but only Tamino X-Query has been used. Since Tamino version 4.x XML XQuery is available and thus a more flexible solution than the one posted below is now possible.

Best regards,


Jan Harmsen
Software Engineer
Software AG
jsp-example.zip (1.41 KB)

Hi Jan

Thank you for this. It is working well.

The result of my query which is based on a selection made in a selection list, is only a single value. I would like to place this single value in a normal field rather than another selection list with only one value (which is what I have now).

How do I go about doing that? I tried

 <input type="text"  value="<xapp:getvar name='QuestionQuery'/>">  

but that gives me the query string and not the evaluated query.

Thanks
Elsabe

Hi Elsabe,

I’m not sure whether I understand your problem correctly but I assume you could do the following depending on whether you have the required xml data already in your workspace or not:

-Use an xapp:directcommand type=“xquery” and then an xapp:display command like

<xapp:display select="/YourXmlRootNode/somePath/@someProperty"><input type="text"/></xapp:display>



- just use an xapp:display command like the one above

I suggest to have a look at the tips+tricks section and the examples section of the X-Application documentation.

Hope this helps :slight_smile:

Best regards,


Jan Harmsen
Software Engineer
Software AG

Hi Jan

Thanks for the reply. The display tag will work, but what to put in it’s select attribute is my problem.

I have a code file (say DocC) with a code and a description. In another doctype (say DocA) I also have elements for the code and description which are populated from the code file at time of capture. In the create function of DocA I populate a select list with all the valid codes from DocC for the code element in DocA and based on the code selected I want to populate the description element of DocA with the description from DocC.

It works well with using a select field for the description in DocA because as part of the xapp:select I can specify the xquery to get the correct description based on the selected code.

I have tried a directcommand with an xquery to get the correct description but am still not able to get it to work. I specify a document attribute in the directcommand and as I understand it that should be where the ‘result’ of the xquery should be. I then create a xapp:form using the document as specified in the directcommand and have the display inside the xapp:form tag. Even when I do a display select=“.” which should show me what is in the document I get exception 219

 The select path "." or the extend select path "null" could not be processed for node "null". 



I’m obviously doing something wrong or I am not understanding the whole directcommand and document/workspace scenario correctly.

Thanks
Elsabe

Hi,

it sounds like you need DocC in your workspace to populate some content of DocA with values from DocC, but obviously you currently don’t have DocC in your workspace.
I suggest to load DocC as a document (e.g. “myWsDocC”) into your workspace by using a

<xapp:directcommand type="read" document="myWsDocC" schema="DocC" arg="your-xquery-to-get-DocC" collection="collection-to-use"/>


.

Then you can directly access the required elements / attributes in myWsDocC and display them or store them in variables and use them wherever required.

Does this solve your problem ?

Best regards,


Jan Harmsen
Software Engineer
Software AG

Thanks, that works very well. I just needed a ‘read’ instead of a ‘xquery’. But I still feel stupid because I have another problem.

I am able to display the description of DocC in the create page of DocA but because the xapp:display was based on the workspace of DocC and not DocA the description element of DocA does not get populated.

I have tried directelementactions to get the value of the description of DocC into the description of DocA but once again I am missing some understanding.

How do I populate the value of an element in one workspace using the value of an element in another?

Thanks
Elsabe

Hi,

you can use

<xapp:setvar ...> <xapp:display .../> </xapp:setvar>  

within the context of myWsDocC to store the content of an element / attribute in a variable which can then be used anywhere within the context of myWsDocA to populate fields.

Best regards,


Jan Harmsen
Software Engineer
Software AG

Hi

I’m sorry that this is turning out like ‘pulling hen’s teeth’. I’m trying my best to help myself but alas…

I have managed to get a variable containing the description but I cannot figure out how the assign this value to the element in DocA. I have tried a directelementaction with setValue but the ‘arg’ attribute takes the value as a literal and does not ‘interpret’ the variable content. I have also tried with display with a getvar but get an error ‘The content is not valid XML’.

Thanks
Elsabe

Hi,

don’t worry, sooner or latter we’ll have the solution :slight_smile:

Okay, when creating the createDocA.jsp page you have a bunch of xapp:edit tags containing input or select tags where the user enters or selects the data. When you don’t want the user to enter or select data but want to prefill it with some value taken from another doc you can do this:
Set a variable with xapp:setvar and then use the following code:

<xapp:edit select="/DocA/some-XPath/ElementXYZ">
   <input type="text" readonly="readonly" value="<xapp:getvar name="your-varname"/>"/>
</xapp:edit>



If you remove the readonly=“readonly” attribute the user is still able to modify the data.

This works and should solve your problem :slight_smile: Last but not least you might want to have a look at the Tamino X-Application Java API documentation which clarifies probably most of your questions. As a start you could have a look at the examples chapter which shows what happens in the background when a business document is created / maintained.

Best regards,


Jan Harmsen
Software Engineer
Software AG

Thanks again.

Believe me, I am constantly in the documentation. That is where I found the following:

The value attribute of the HTML input tag can be used to define a default value if the selected element or attribute is empty. If it is not empty, the value attribute is ignored.   



SO, once the value has been set, it cannot be changed again by the value attribute but what I do is I set the value of the element using a directelementaction type setValue to blank before I set the value to the variable’s content in the edit tag.

So finally I can say that I have achieved what I wanted. Thank you very much!

Elsabe