Thanks very much for your response, Pieter.
I agree that I could have gone that route as I have used that technique
(based on the samples) in a previous project.
On this project, I have been trying to use more declarative techniques (I'm
weird like that) hence the cry for help with the DynamicSelectionList filter
stuff. I abandoned the DynamicSelectionList approach shortly after lunch.
However, because I have the filter parameter (team) in the flowscript I went
with using the loadDocument function to load it into the form from the
flowscript :-
var sources = loadDocument("cocoon:/sources?filter="+team);
// Show the form
form.showForm("viewform-client-create.html", { team: team, sources:
sources });
This puts the filtered values in scope for the form. The form definition
uses flow-jxpath to get them into the selection list :-
<fd:selection-list type="flow-jxpath" list-path="//entry"
value-path="value" label-path="label"/>
Unbelievably, it worked first time although how the flow-jxpath 'knows' what
object the XML is in I don't know.
That's the 'magic' of Cocoon,
Thanks again,
Warrell
-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Pieter Delmee
Sent: 24 April 2007 16:20
To: [email protected]
Subject: Re: DynamicSelectionList filter parameter
Warrell wrote:
> Hi,
>
> Can anyone shed a bit more light on how to user the filter parameter?
> The documentation states :-
>
> This list is filterable, and if a filter is provided, the "filter"
> parameter is appended to the URL, e.g. <fd:selection-list
> src="cocoon://pipeline.xml"/> will call, given the "foo" filter
> value, the URL cocoon://pipeline.xml?filter=foo.
>
> Where do I specify the parameter value? What I would like to do is :-
>
> In the Template form define the selection list as
>
> <fd:field id="sourcecode" required="true">
> <fd:label>Source Code:</fd:label>
> <fd:datatype base="string"/>
> <fd:selection-list src="cocoon:/sources" cache="request"/>
> </fd:field>
>
> Then in the Instance form do something like :-
>
> <ft:widget id="sourcecode">
> <filter>${team}</filter>
> </ft:widget>
>
> So that in the sitemap I can do :-
>
> <map:match pattern="sources">
> <map:generate src="teams.xml"/>
> <map:transform src="filterTeamsToSL.xsl">
> <map:parameter name="team"
> value="{request-param:filter}"/>
> </map:transform>
> <map:serialize type="xml"/>
> </map:match>
>
> Is this how it's supposed to work? I will take another look at the
> Java source but any help would be very welcome,
>
> Regards
>
> Warrell
Hi Warrell,
You can set the filter in the fd:on-value-changed javascript.
Using your sourcecode field you'ld need another field in which the filter is
specified, for example:
<fd:field id="filter">
<fd:label>filter</fd:label>
<fd:datatype base="string"/>
<fd:on-value-changed>
<fd:javascript>
var sourcecodeWidget = this.lookupWidget('../sourcecode');
if (this.value != null) {
sourcecodeWidget.setSelectionList('cocoon:/sources?filter=' +
this.value);
} else {
sourcecodeWidget.setSelectionList('cocoon:/sources');
}
</fd:javascript>
</fd:on-value-changed>
</fd:field>
You can also use the following lines to enable/disable the field when
there's no filter specified.
sourcecodeWidget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetS
tate.ACTIVE);
sourcecodeWidget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetS
tate.DISABLED);
regards,
Pieter
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]