Guest
Welcome login


TIBCOmmunity > Blogs > General Interface Blog > Tags
Home   Members Communities

General Interface Blog

2 Posts tagged with the grid tag
5

Author: Luke Birdeau

 

The XML Mapping utility does allow you to specify which records in your CDF document actually get mapped. There is a API call exposed by the jsx3.net.Service class called setCDFRecords that can be called from a mapping rule. For example, assume you have a CDF document in the XML Cache called myXML:

 


<data jsxid="jsxroot">
<record jsxid="a" checked="1" jsxtext="a"/>
<record jsxid="b" checked="0" jsxtext="b"/>
<record jsxid="c" checked="1" jsxtext="c"/>
<record jsxid="d" checked="1" jsxtext="d"/>
</data>

 

Next, Create a CDF Document mapping rule using the XML Mapping Utility for the outbound message you are creating. Set its path/value field to: myXML. Add an additional mapping rule (a Script type this time) and set the following as its path/value:

 

setCDFRecords("record[@checked='1']");

 

Here is what happened:

 

Any time a CDF Document mapping is encountered, all record nodes that are immediate children of the root node (data) are placed in a collection (jsx3.util.Collection). Then when a CDF Record mapping is encountered, the first record in the collection is assigned as the CDF Context and the ensuing rules are run. When a CDF Attribute mapping is encountered, the record referenced by the CDF Context is used. The mapper then repeats this as long as there are more records in the collection. By calling setCDFRecords, you effectively tell the system to not use its default query:

 

currentRecordContext.selectNodes("record");

rather, use a custom query. In your case:

 

currentRecordContext.selectNodes("record[@checked='1']");

 

 

NOTE setCDFRecords() goes with your CDF Document mapping as an additional script mapping rule.

 

 

Example We want to map the jsxtext attribute from record with jsxselected checked to WSDL Schema structure

 


<element name = "PersonSearch">
<complexType>
<sequence>
<element name = "QueryTarget" type = "xsd:string" maxOccurs = "unbounded"/>
</sequence>
</complexType>
</element>

 

In the Mapping utility, select the rule tree node PersonSearch.

  1. 1. Add a CDF Document mapping and enter the name of the CDF Document you wish to map to (its cache id).

  2. 2. Next add a Script mapping to the PersonSearch node and set its value to:

setCDFRecords("record[@jsxselected='1']");

 

Next, select the rule named, QueryTarget.

  1. 1. Add a CDF Record Mapping (records don't need a value).

  2. 2. Next, add a CDF Attribute mapping and enter jsxtext as the named CDF attribute on that record that you want to map to.

 

So to recap, you should have two mappings on the PersonSearch rule and two mappings on the QueryTarget rule.

 

5 Comments Permalink
2

Simply adding HTML for a checkbox to a matrix Column header results in a checkbox that doesn;t get checked or unchecked in response to mouse clicks.

The challenge in the implementation is that the Matrix headers are designed to use the mousedown event to reorder columns and trigger sort behaviors. This means that the click event on the checkbox gets intercepted and canceled by the header and clicking on the checkbox never causes the checkbox to get checked.

To address, use the mousedown event on the checkbox to toggle the checked state (see code below). It is also critical to cancel event bubbling to stop the Matrix from sorting and reordering when the user's intention is to check or uncheck the box.

Lastly, note that the checkbox described below is XHTML compliant. This is important if you intend your app to ever run on an XHTML Web page (and it's simply good practice these days to author well-formed HTML).


 <input type="checkbox" 
onmousedown="this.checked = !this.checked; jsx3.gui.Event.wrap(event).cancelBubble();" 
onclick="jsx3.gui.Event.wrap(event).cancelBubble();return false;" 
onmouseup="jsx3.gui.Event.wrap(event).cancelBubble();" />



Darren Hwang (channeling Luke Birdeau)

 

2 Comments Permalink

General Interface Blog

General Interface Blog