cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Latty" <joe.la...@tias.com.au>
Subject Re: Woody: selection list problem
Date Sun, 23 Nov 2003 23:44:23 GMT
Sorry to come in at this late point but as an alternative

in javascript:

var data = new Object();

data.cityList = new Array(2);
data.cityList[0] = {value:"AL", label:"Alabama"};
data.cityList[1] = {value:"AK", label:"Alaska"};

form.showForm("flow/myform.form", data);

and then use the flow-jxpath selection list widget

<wd:selection-list type="flow-jxpath" list-path="cityList"
value-path="value" label-path="label" />

Joe

----- Original Message ----- 
From: "Bruno Dumon" <bruno@outerthought.org>
To: <dev@cocoon.apache.org>
Sent: Saturday, November 22, 2003 10:06 PM
Subject: RE: Woody: selection list problem


> On Sat, 2003-11-22 at 09:42, Danny Bols wrote:
> > > -----Original Message-----
> > > From: Bruno Dumon [mailto:bruno@outerthought.org]
> > > Sent: vrijdag 21 november 2003 21:45
> > > To: dev@cocoon.apache.org
> > > Subject: RE: Woody: selection list problem
> > >
> > >
> > > On Fri, 2003-11-21 at 20:37, Danny Bols wrote:
> > > > > -----Original Message-----
> > > > > From: Bruno Dumon [mailto:bruno@outerthought.org]
> > > > > Sent: vrijdag 21 november 2003 17:35
> > > > > To: dev@cocoon.apache.org
> > > > > Subject: Re: Woody: selection list problem
> > > > >
> > > > >
> > > > > On Fri, 2003-11-21 at 10:31, Danny Bols wrote:
> > > > > > Hello,
> > > > > >
> > > > > > when trying to populate a selection list from within flow
> > > > > script I ran into
> > > > > > a problem. The following piece of code did not work:
> > > > > >
> > > > > >  function myform(form) {
> > > > > >      var widget = form.form.getWidget("myfield");
> > > > > >      var selectionList = new
> > > > > >
> > > > > Packages.org.apache.cocoon.woody.datatype.StaticSelectionList(widg
> > > > > et.getData
> > > > > > type());
> > > > > >      selectionList.addItem("AL", "Alabama");
> > > > > >      selectionList.addItem("AK", "Alaska");
> > > > > >      widget.setSelectionList(selectionList);
> > > > > >      form.showForm("flow/myform.form");
> > > > > > }
> > > > >
> > > > > Well, if you would have read the javadoc of that class and method
...
> > > >
> > > > mmhh...I thought I read almost everything.....almost :-)
> > > >
> > > >
> > > > > Anyway, this code changed recently, if you update to current CVS
you
> > > > > should be able to make it work with something like this:
> > > > >
> > > > > selectionList.addItem("AL", new
> > > > > Packages.org.apache.cocoon.woody.util.StringMessage("Alabama"));
> > > >
> > > > Would it be a good idea to create a convenience method which accepts
2
> > > > string objects?
> > >
> > > A convenience method which takes a string for the second argument (the
> > > label) would be a good idea. The first argument, the value itself, can
> > > really be any object type so that doesn't matter.
> >
> > Can you explain to me why the first parameter has to be an object?
>
> Because the type of the objects in the selection list can be anything,
> and depends on the datatype of the widget. For example, if
> datatype.getTypeClass() returns java.lang.Integer, the selection list
> should contain Integer objects.
>
> -- 
> Bruno Dumon                             http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno@outerthought.org                          bruno@apache.org
>


Mime
View raw message