cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christofer Dutz" <d...@c-ware.de>
Subject [CFORMS] Alternate Suggestion-List generation
Date Fri, 25 Aug 2006 09:21:41 GMT
Hi,

 

I would like to post an alternate way of generating suggestion lists. In our
current project we had the need of generating context-sensitive
suggestion-lists. 

Next to the context sensitivity, there were other things bothering us. While
debugging everything we had a look at what was actually happening: 

 

-          When the pipeline for generating the suggestion-list is called, 

o        the suggestion-list generator looks up the form and widget

o        the corresponding java-script block is executed on the widget:

*         Since the content of the suggestion-lists is the result of an
xquery, the first step was to do an xquery

*         The result of the xquery pipeline was loaded into a dom

*         that is walked through generating an array, which is returned to
the suggestion-list generator

o        that array is transformed to sax-events by the suggestion-list
generator

o        this sax stream is then flattened back to plain old ASCII text in
the usual pipeline definition for suggestion lists

 

A conversion nightmare.

 

After quite some time of trying we found a way simplifying the way
suggestion-lists content is generated and as an addition we get the benefit
of being able to generate context-sensitive suggestion-lists very easily:

 

The pipeline for generating the content:

                  <!-- Pipeline for creating the suggestion list content.

                        the parameter "filter" contains the current content
of 

                        the text field and "widget" the id of the currently
active 

                        widget. These are used in the initial xslt
generating the

                        query. -->

                  <map:match pattern="_cocoon/forms/suggest">

                        <!-- generate an xml stream of the current form
model with

                        element name set to the id of a widget and it's
content to 

                        the value. I had to use this, because otherwise it
was not

                        possible to create suggestion-lists that are context


sensitive. -->

                        <map:generate type="forms-content"/>

                        <!-- prepare a database-query using the current form
values

This is where the real logic is set … using request-parameters

For individual xslts depending on the widget id are also 

possible -->

                        <map:transform type="xslt-saxon"
src="selection-lists/suggestion-list-query.xslt"/>

                        <!-- execute the query -->

                        <map:transform type="sql"/>

                        <!-- thransform the query results to a
SELECTION-LIST (not

                        a suggestion-list) -->

                        <map:transform type="xslt-saxon"
src="selection-lists/suggestion-list-trans.xslt"/>

                        <!-- transform the selection-list to the primitive
array-form

                        the dojo component can operate on -->

                        <map:transform

 
src="resource://org/apache/cocoon/forms/resources/selection-list2json.xsl"/>

                        <!-- send it back as text -->

                        <map:serialize type="text"/>

                  </map:match>

 

 

Widget definition (As you can see … there is no difference between a simple
text-field and a suggestion-list):

            <fd:field id="lad_plz" required="">

                  <fd:label>PLZ:</fd:label>

                  <fd:datatype base="string"/>

                  <fd:validation>

                        <fd:length max="6">

                             <fd:failmessage>Die PLZ darf nur 6 Buchstaben
enthalten.</fd:failmessage>

                        </fd:length>

                  </fd:validation>

            </fd:field>

 

 

Widget template:

            <ft:widget-label id="lad_land" type="suggest"/>

 

The logic for generating the suggestion-list content is now wrapped up in
the selection-lists/suggestion-list-query.xslt query.

It was much easier understanding suggestion-lists this way.

 

Just wanted to share my ideas and maybe get some hints for improvements.

 

Regards,

Chris

 

[ c h r i s t o f e r   d u t z ]

 

IT-Berater

univativ GmbH & Co. KG

Robert-Bosch-Str. 7, 64293 Darmstadt

 

fon: 0 61 51 / 66 717 - 21

fax: 0 61 51 / 66 717 - 29

email: christofer.dutz@univativ.de

http://www.univativ.de

 

Darmstadt, Stuttgart, Karlsruhe, Düsseldorf

 

 


Mime
View raw message