cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christofer Dutz" <d...@c-ware.de>
Subject AW: AW: Accessing AJAX forms field values
Date Tue, 01 Aug 2006 13:29:32 GMT
Hi Grzegorz,

Well I am not using the ordinary approach. We used to generate plain old
selection lists. These were populated by internal pipelines. The initial
version of our suggestion-list support contained a function walking through
the dom of this pipelines result building the array of name-values the
suggestion-list generator expects. While debugging I found out that all this
does is to generate a selection-list and then to flatten that again. So we
took out the suggestion-list generator entirely. Here our current pipeline
for the suggestion-lists:

<!-- Pipeline for creating the suggestion list content -->
<map:match pattern="_cocoon/forms/suggest">
	<!-- the parameter "filter" contains the current content of 
		the textfield and "widget" the id of the currently active 
		widget. Knowing this it should be easily possible to use
		the SZT pipeline directly without the need for converting
		the content multiple times. -->
	<!-- the forms-content generator gets the from object from the
continuation the same way the suggestion-list generator dies and
creates a xml-representation of the forms values with the ids as
tag names and their values as content -->
	<map:generate type="forms-content"/>
	<!-- uses the values of the current form to dynamically 
		create a query -->
	<map:transform type="xslt-saxon" 
		src="selection-lists/suggestion-list-query.xslt"/>
	<!-- execute the query -->
	<map:transform type="sql"/>
	<!-- transform the result into a selection-list -->
	<map:transform type="xslt-saxon" 
		src="selection-lists/suggestion-list-trans.xslt"/>
	<!-- flatten the selection list, so the suggestion-list code can
work 		with the results -->
	<map:transform
		src="resource://org/apache/cocoon/forms/resources/selection-
list2json.xsl"/>
	<map:serialize type="text"/>
</map:match>

This way I should be able to have all the information I need unfortunately I
can't. I added a print command to the on-value-changed code of the country
widget and it is not executed when the field value changes. As a matter of
fact on-value-changed seems not to work at all with suggestion-list widgets.
It seems that this the problem. If I change the country-widget to a
non-suggestion-list, everything works fine. I'll post a question for this in
a separate thread.

Any other Ideas? Your approach will not work because of this problem. All
the fields Country, Zip and Town are String widgets with suggestion-lists.

Chris

-----Urspr√ľngliche Nachricht-----
Von: Grzegorz Kossakowski [mailto:grek@tuffmail.com] 
Gesendet: Dienstag, 1. August 2006 14:20
An: users@cocoon.apache.org
Betreff: Re: AW: Accessing AJAX forms field values

Christofer Dutz napisal(a):
> Hi Grzegorz,
>
> Thanks for your reply. In general your Idea sounds good. Could you explain
> what you mean by "seting an attribute of zip"? Is it possible to add
> additional attributes to a field? How can I access them when generating
the
> suggestion-list. Is there any sample code showing this?

Every CForms widget can have a collection of attributes, see [1].
Your country widget should look like:
<fd:field id="country">
<fd:on-value-changed>
<fd:javascript>
event.sourceWidget.lookupWidget("../zip").setAttribute("country", 
event.sourceWidget.value);
<fd:javascript>
</fd:on-value-changed>
</fd:field>

Taking a quick look on source of JavaScriptSelectionListBuilder[2] it 
seems that there is no way to access a widget object from implementation 
of suggestion-list. However, there is dirty workaround for this. You can 
put your form instance in viewdata in flowscript and then access it in 
from javascript code.

<fd:field id="zip">
<fd:suggestion-list type="javascript">
//your javascript code
</fd:suggestion-list>

I have to think about it for a while, maybe come with better solution.

[1] 
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/formmodel/Widge
t.html
[2] 
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/datatype/JavaSc
riptSelectionListBuilder.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message