You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Joe Latty <jo...@tias.com.au> on 2003/11/24 06:30:20 UTC

Selecting the correct value in a selection-list

I have searched through the archives and docs to no avail.

In the scenario where I have a selection list built up in javascript

var states = [
     { key: "AL", value: "Alabama" },
     { key: "AK", value: "Alaska" },
     { key: "WY", value: "Wyoming" }
 ];
 
I pass it into the form:
form.showForm(uri, { "states" : states });

and in the field I have the following element:
<wd:selection-list type="flow-jxpath" list-path="states" value-path="key" label-path="value"/>

How can I select a value eg "AK":
form.getWidget("myStateDropDown").setValue("AK"); 

does not work...

Joe

Re: Selecting the correct value in a selection-list

Posted by Joe Latty <jo...@tias.com.au>.
OK I have the spinning tie on and I'm having a good laugh at myself.

I had:

    // depPorts being a list I obtained from a SOAP call
 depPortList = new Array(depPorts.length);   for( var i=0; i <
depPorts.length; i++ ) {
    // What should have been
      depPortList[i] = { key : depPorts[i]  };
    // Was
      depPortList[i] = { value : depPorts[i]  };
 }

// Therefore
form.getWidget("repeaterWidget").getRow(0).getWidget("depPort").setValue("SY
D");
// Would not work

I am off to have an expresso and a piece of Humble Pie.

Thanks for your help Bruno.

----- Original Message ----- 
From: "Bruno Dumon" <br...@outerthought.org>
To: <us...@cocoon.apache.org>
Sent: Friday, November 28, 2003 3:04 AM
Subject: Re: Selecting the correct value in a selection-list


> On Thu, 2003-11-27 at 04:16, Joe Latty wrote:
> > Bruno,
> >
> > Ok I think I over simplified things so as to explain my problem
> >
> > I have a repeater with a select-list in each row, I wish to select the
"AK"
> > value in the select-list of the first row.
> >
> >
form.getWidget("myRepeaterWidget").getRow(0).getWidget("myStateDropDown").se
> > tValue("AK");
> >
> > This does not work (for me).
>
> I see no reason it wouldn't work. Could you create a minimal testcase
> (form definition, template & flowscript) to illustrate the problem?
>
> -- 
> Bruno Dumon                             http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno@outerthought.org                          bruno@apache.org
>
>
> ---------------------------------------------------------------------
> 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


Re: Selecting the correct value in a selection-list

Posted by Bruno Dumon <br...@outerthought.org>.
On Thu, 2003-11-27 at 04:16, Joe Latty wrote:
> Bruno,
> 
> Ok I think I over simplified things so as to explain my problem
> 
> I have a repeater with a select-list in each row, I wish to select the "AK"
> value in the select-list of the first row.
> 
> form.getWidget("myRepeaterWidget").getRow(0).getWidget("myStateDropDown").se
> tValue("AK");
> 
> This does not work (for me).

I see no reason it wouldn't work. Could you create a minimal testcase
(form definition, template & flowscript) to illustrate the problem?

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


Re: Selecting the correct value in a selection-list

Posted by Joe Latty <jo...@tias.com.au>.
Bruno,

Ok I think I over simplified things so as to explain my problem

I have a repeater with a select-list in each row, I wish to select the "AK"
value in the select-list of the first row.

form.getWidget("myRepeaterWidget").getRow(0).getWidget("myStateDropDown").se
tValue("AK");

This does not work (for me).

Joe



----- Original Message ----- 
From: "Bruno Dumon" <br...@outerthought.org>
To: <us...@cocoon.apache.org>
Sent: Wednesday, November 26, 2003 5:21 AM
Subject: Re: Selecting the correct value in a selection-list


> On Mon, 2003-11-24 at 23:54, Joe Latty wrote:
> > I still think I am not quite explaining my problem very well.
>
> No, I think I understood your problem.
>
> > In a dropdown list of say 3 state codes I wish to default the selected
value
> > to "AK" this being the second value in the list.
> >
> > Therefore the value of the dropdown list field is defaulted to "AK".
> >
> > Is this possible within Woody? How do I select a value "in the list" as
the
> > default/selected?
>
> sure, this is supposed to work.
>
> I just tried the exact sample you gave in your first mail, and it works
> perfectly for me.
>
> Did you make any changes to the XSL's?
>
> And did you do the setValue() call before the showForm() call? I hope I
> don't insult you by asking such a stupid question ;-)
>
> So this is what I tried:
>
> > > > var states = [
> > > >      { key: "AL", value: "Alabama" },
> > > >      { key: "AK", value: "Alaska" },
> > > >      { key: "WY", value: "Wyoming" }
> > > >  ];
> > > >
> > > > I pass it into the form:
> > > > form.showForm(uri, { "states" : states });
> > > >
> > > > and in the field I have the following element:
> > > > <wd:selection-list type="flow-jxpath" list-path="states"
> > > > value-path="key" label-path="value"/>
> > > >
> > > > How can I select a value eg "AK":
> > > > form.getWidget("myStateDropDown").setValue("AK");
>
> -- 
> Bruno Dumon                             http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno@outerthought.org                          bruno@apache.org
>
>
> ---------------------------------------------------------------------
> 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


Re: Selecting the correct value in a selection-list

Posted by Bruno Dumon <br...@outerthought.org>.
On Mon, 2003-11-24 at 23:54, Joe Latty wrote:
> I still think I am not quite explaining my problem very well.

No, I think I understood your problem.

> In a dropdown list of say 3 state codes I wish to default the selected value
> to "AK" this being the second value in the list.
> 
> Therefore the value of the dropdown list field is defaulted to "AK".
> 
> Is this possible within Woody? How do I select a value "in the list" as the
> default/selected?

sure, this is supposed to work.

I just tried the exact sample you gave in your first mail, and it works
perfectly for me.

Did you make any changes to the XSL's?

And did you do the setValue() call before the showForm() call? I hope I
don't insult you by asking such a stupid question ;-)

So this is what I tried:

> > > var states = [
> > >      { key: "AL", value: "Alabama" },
> > >      { key: "AK", value: "Alaska" },
> > >      { key: "WY", value: "Wyoming" }
> > >  ];
> > >
> > > I pass it into the form:
> > > form.showForm(uri, { "states" : states });
> > >
> > > and in the field I have the following element:
> > > <wd:selection-list type="flow-jxpath" list-path="states"
> > > value-path="key" label-path="value"/>
> > >
> > > How can I select a value eg "AK":
> > > form.getWidget("myStateDropDown").setValue("AK");

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


Re: Selecting the correct value in a selection-list

Posted by Joe Latty <jo...@tias.com.au>.
I still think I am not quite explaining my problem very well.

In a dropdown list of say 3 state codes I wish to default the selected value
to "AK" this being the second value in the list.

Therefore the value of the dropdown list field is defaulted to "AK".

Is this possible within Woody? How do I select a value "in the list" as the
default/selected?

<!-- A typical scenario is where a country dropdown list lists all countries
but defaults to "USA". This is very common behaviour -->

Joe




> On Mon, 2003-11-24 at 06:30, Joe Latty wrote:
> > I have searched through the archives and docs to no avail.
> >
> > In the scenario where I have a selection list built up in javascript
> >
> > var states = [
> >      { key: "AL", value: "Alabama" },
> >      { key: "AK", value: "Alaska" },
> >      { key: "WY", value: "Wyoming" }
> >  ];
> >
> > I pass it into the form:
> > form.showForm(uri, { "states" : states });
> >
> > and in the field I have the following element:
> > <wd:selection-list type="flow-jxpath" list-path="states"
> > value-path="key" label-path="value"/>
> >
> > How can I select a value eg "AK":
> > form.getWidget("myStateDropDown").setValue("AK");
>
> hmmm, strange. Maybe it's a problem that the setted value is a
> javascript string, so try this:
>
> form.getWidget("myStateDropDown").setValue(new java.lang.String("AK"));
>
> or alternatively:
>
> form.getModel().myStateDropDown = "AK";
>
> though normally the setValue() call should raise an exception if the
> argument is of the wrong type.
>
> -- 
> Bruno Dumon                             http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno@outerthought.org                          bruno@apache.org
>
>
> ---------------------------------------------------------------------
> 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


Re: Selecting the correct value in a selection-list

Posted by Bruno Dumon <br...@outerthought.org>.
On Mon, 2003-11-24 at 06:30, Joe Latty wrote:
> I have searched through the archives and docs to no avail.
>  
> In the scenario where I have a selection list built up in javascript
>  
> var states = [
>      { key: "AL", value: "Alabama" },
>      { key: "AK", value: "Alaska" },
>      { key: "WY", value: "Wyoming" }
>  ];
>  
> I pass it into the form:
> form.showForm(uri, { "states" : states });
>  
> and in the field I have the following element:
> <wd:selection-list type="flow-jxpath" list-path="states"
> value-path="key" label-path="value"/>
> 
> How can I select a value eg "AK":
> form.getWidget("myStateDropDown").setValue("AK"); 

hmmm, strange. Maybe it's a problem that the setted value is a
javascript string, so try this:

form.getWidget("myStateDropDown").setValue(new java.lang.String("AK")); 

or alternatively:

form.getModel().myStateDropDown = "AK";

though normally the setValue() call should raise an exception if the
argument is of the wrong type.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


Re: Selecting the correct value in a selection-list

Posted by Joe Latty <jo...@tias.com.au>.
Sorry I'm not sure I have explained well
In the selection-list (dropdown) I will eventually want the html to look
like this

    <option value="Alabama">AL</option>
    <option value="Alaska" selected>AK</option>
    <option value="Wyoming">WY</option>

Where "AK" is the selected value
hence the line:
form.getWidget("myStateDropDown").setValue("AK");


----- Original Message ----- 
From: "Antonio Gallardo" <ag...@agsoftware.dnsalias.com>
To: <us...@cocoon.apache.org>
Sent: Monday, November 24, 2003 4:40 PM
Subject: Re: Selecting the correct value in a selection-list


> Joe Latty dijo:
> > I have searched through the archives and docs to no avail.
> >
> > In the scenario where I have a selection list built up in javascript
> >
> > var states = [
> >      { key: "AL", value: "Alabama" },
> >      { key: "AK", value: "Alaska" },
> >      { key: "WY", value: "Wyoming" }
> >  ];
> >
> > I pass it into the form:
> > form.showForm(uri, { "states" : states });
> >
> > and in the field I have the following element:
> > <wd:selection-list type="flow-jxpath" list-path="states"
value-path="key"
> > label-path="value"/>
> >
> > How can I select a value eg "AK":
>
> I guess this can be a typo while writing the mail:
>
> > form.getWidget("myStateDropDown").setValue("AK");
>
> but to be sure, I wrote the correct one:
>
> form.getWidget("myStateDropDown").getValue();
>
> This solve your problem?
>
> Best Regards,
>
> Antonio Gallardo
>
>
> ---------------------------------------------------------------------
> 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


Re: Selecting the correct value in a selection-list

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Joe Latty dijo:
> I have searched through the archives and docs to no avail.
>
> In the scenario where I have a selection list built up in javascript
>
> var states = [
>      { key: "AL", value: "Alabama" },
>      { key: "AK", value: "Alaska" },
>      { key: "WY", value: "Wyoming" }
>  ];
>
> I pass it into the form:
> form.showForm(uri, { "states" : states });
>
> and in the field I have the following element:
> <wd:selection-list type="flow-jxpath" list-path="states" value-path="key"
> label-path="value"/>
>
> How can I select a value eg "AK":

I guess this can be a typo while writing the mail:

> form.getWidget("myStateDropDown").setValue("AK");

but to be sure, I wrote the correct one:

form.getWidget("myStateDropDown").getValue();

This solve your problem?

Best Regards,

Antonio Gallardo


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