Using the select tag

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Using the select tag

Olivier Auverlot
Hi,

I need to use a drop-down menu in a seaside application. In the examples
that I have found, the displayed values are initialized with #list:

html  select
        list:  #(#Male  #Female);
        selected:  self  contact  gender;
        callback:  [  :value  |
                value  =  #Male
                ifTrue:  [  self  contact  beMale  ]
                ifFalse:  [  self  contact  beFemale  ]  ].

In the browser, I get this HTML code :

<select  name="3"><option  value="1"selected="selected">Male</option><option  value="2">Female</option></select>

My problem is how to set the values for each <option> tag ? I would get
something like :

<select  name="3"><option  value="ML"selected="selected">Male</option><option  value="FML">Female</option></select>


Thanks for your help.

Best regards
Olivier ;-)

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

Philippe Marschall
2011/9/29 Olivier Auverlot <[hidden email]>:

> Hi,
>
> I need to use a drop-down menu in a seaside application. In the examples
> that I have found, the displayed values are initialized with #list:
>
> html  select
>        list:  #(#Male  #Female);
>        selected:  self  contact  gender;
>        callback:  [  :value  |
>                value  =  #Male
>                ifTrue:  [  self  contact  beMale  ]
>                ifFalse:  [  self  contact  beFemale  ]  ].
>
> In the browser, I get this HTML code :
>
> <select  name="3"><option  value="1"selected="selected">Male</option><option
>  value="2">Female</option></select>
>
> My problem is how to set the values for each <option> tag ? I would get
> something like :

Why do you want to do this?

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

davidbuck
In reply to this post by Olivier Auverlot
Try this and let me know if it works for you.

        html select
            with: [
                html option
                    value: 'ML';
                    with: 'Male'.
                html option
                    value: 'FML';
                    with: 'Female'].

David Buck


Olivier Auverlot wrote:

> Hi,
>
> I need to use a drop-down menu in a seaside application. In the
> examples that I have found, the displayed values are initialized with
> #list:
>
> html  select
>     list:  #(#Male  #Female);
>     selected:  self  contact  gender;
>     callback:  [  :value  |
>         value  =  #Male
>         ifTrue:  [  self  contact  beMale  ]
>         ifFalse:  [  self  contact  beFemale  ]  ].
>
> In the browser, I get this HTML code :
>
> <select  name="3"><option  
> value="1"selected="selected">Male</option><option  
> value="2">Female</option></select>
>
> My problem is how to set the values for each <option> tag ? I would
> get something like :
>
> <select  name="3"><option  
> value="ML"selected="selected">Male</option><option  
> value="FML">Female</option></select>
>
>
> Thanks for your help.
>
> Best regards
> Olivier ;-)
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1410 / Virus Database: 1520/3925 - Release Date: 09/28/11
>
>

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

Philippe Marschall
2011/9/29 David Buck <[hidden email]>:

> Try this and let me know if it works for you.
>
>       html select
>           with: [
>               html option
>                   value: 'ML';
>                   with: 'Male'.
>               html option
>                   value: 'FML';
>                   with: 'Female'].
That should break #callback:

Cheers
Philippe

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

Olivier Auverlot
In reply to this post by Philippe Marschall
Hi Philippe,

It's possible that I want work with a too old method for Seaside. I made
many cgi in my programmer life ;-)

For me, when I use a select tag, I don't use the value and the caption
to do the same operation. The caption is displayed for the user, the
value is transmitted to the server. It's very distinct to me.

In my case, I have a database table with a foreign key (the value) and a
description (the caption). The key is immutable but the text can change.
It's logical for me that the user selects a caption and that the serveur
receives the key.

Olivier ;-)

> 2011/9/29 Olivier Auverlot<[hidden email]>:
>> Hi,
>>
>> I need to use a drop-down menu in a seaside application. In the examples
>> that I have found, the displayed values are initialized with #list:
>>
>> html  select
>>         list:  #(#Male  #Female);
>>         selected:  self  contact  gender;
>>         callback:  [  :value  |
>>                 value  =  #Male
>>                 ifTrue:  [  self  contact  beMale  ]
>>                 ifFalse:  [  self  contact  beFemale  ]  ].
>>
>> In the browser, I get this HTML code :
>>
>> <select  name="3"><option  value="1"selected="selected">Male</option><option
>>   value="2">Female</option></select>
>>
>> My problem is how to set the values for each<option>  tag ? I would get
>> something like :
> Why do you want to do this?
>
> Cheers
> Philippe
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

Olivier Auverlot
In reply to this post by Philippe Marschall
if I can't set and read the value of an option tag. How can I know the
index of the selected line ?

Olivier ;-)

> 2011/9/29 Olivier Auverlot<[hidden email]>:
>> Hi,
>>
>> I need to use a drop-down menu in a seaside application. In the examples
>> that I have found, the displayed values are initialized with #list:
>>
>> html  select
>>         list:  #(#Male  #Female);
>>         selected:  self  contact  gender;
>>         callback:  [  :value  |
>>                 value  =  #Male
>>                 ifTrue:  [  self  contact  beMale  ]
>>                 ifFalse:  [  self  contact  beFemale  ]  ].
>>
>> In the browser, I get this HTML code :
>>
>> <select  name="3"><option  value="1"selected="selected">Male</option><option
>>   value="2">Female</option></select>
>>
>> My problem is how to set the values for each<option>  tag ? I would get
>> something like :
> Why do you want to do this?
>
> Cheers
> Philippe
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: Using the select tag

Boris Popov, DeepCove Labs (SNN)
The framework will pass an actual 'selected' object from your 'list' into the callback, what it puts in the 'value' in the HTML should be completely irrelevant to you.

-Boris


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:00 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag

if I can't set and read the value of an option tag. How can I know the index of the selected line ?

Olivier ;-)

> 2011/9/29 Olivier Auverlot<[hidden email]>:
>> Hi,
>>
>> I need to use a drop-down menu in a seaside application. In the
>> examples that I have found, the displayed values are initialized with #list:
>>
>> html  select
>>         list:  #(#Male  #Female);
>>         selected:  self  contact  gender;
>>         callback:  [  :value  |
>>                 value  =  #Male
>>                 ifTrue:  [  self  contact  beMale  ]
>>                 ifFalse:  [  self  contact  beFemale  ]  ].
>>
>> In the browser, I get this HTML code :
>>
>> <select  name="3"><option  value="1"selected="selected">Male</option><option
>>   value="2">Female</option></select>
>>
>> My problem is how to set the values for each<option>  tag ? I would
>> get something like :
> Why do you want to do this?
>
> Cheers
> Philippe
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

Olivier Auverlot
Hi Boris,

This means that I must analyze the choice of the user from the text that is displayed on the screen. ok :-(

But how can I must doing if my application supports many languages ?

Olivier ;-)
The framework will pass an actual 'selected' object from your 'list' into the callback, what it puts in the 'value' in the HTML should be completely irrelevant to you.

-Boris


-----Original Message-----
From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:00 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag

if I can't set and read the value of an option tag. How can I know the index of the selected line ?

Olivier ;-)
2011/9/29 Olivier Auverlot[hidden email]:
Hi,

I need to use a drop-down menu in a seaside application. In the 
examples that I have found, the displayed values are initialized with #list:

html  select
        list:  #(#Male  #Female);
        selected:  self  contact  gender;
        callback:  [  :value  |
                value  =  #Male
                ifTrue:  [  self  contact  beMale  ]
                ifFalse:  [  self  contact  beFemale  ]  ].

In the browser, I get this HTML code :

<select  name="3"><option  value="1"selected="selected">Male</option><option
  value="2">Female</option></select>

My problem is how to set the values for each<option>  tag ? I would 
get something like :
Why do you want to do this?

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: Using the select tag

Boris Popov, DeepCove Labs (SNN)

Olivier,

 

No, you have a way of separately providing display ‘labels’ for your actual objects in the list,

 

(html select)

list: self countries;

selected: country;

enabled: [:ea | ea notNil];

labels: [:ea | ea ifNil: ['---'] ifNotNil: [ea name]];

callback: [:value | country := value].

 

-Boris

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:16 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag

 

Hi Boris,

This means that I must analyze the choice of the user from the text that is displayed on the screen. ok :-(

But how can I must doing if my application supports many languages ?

Olivier ;-)

The framework will pass an actual 'selected' object from your 'list' into the callback, what it puts in the 'value' in the HTML should be completely irrelevant to you.
 
-Boris
 
 
-----Original Message-----
From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:00 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag
 
if I can't set and read the value of an option tag. How can I know the index of the selected line ?
 
Olivier ;-)
2011/9/29 Olivier Auverlot[hidden email]:
Hi,
 
I need to use a drop-down menu in a seaside application. In the 
examples that I have found, the displayed values are initialized with #list:
 
html  select
        list:  #(#Male  #Female);
        selected:  self  contact  gender;
        callback:  [  :value  |
                value  =  #Male
                ifTrue:  [  self  contact  beMale  ]
                ifFalse:  [  self  contact  beFemale  ]  ].
 
In the browser, I get this HTML code :
 
<select  name="3"><option  value="1"selected="selected">Male</option><option
  value="2">Female</option></select>
 
My problem is how to set the values for each<option>  tag ? I would 
get something like :
Why do you want to do this?
 
Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

 


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

Olivier Auverlot
Thank Boris but I don't know if your example can resolve my question. The problem is not to produce labels but setting a unique value for each line of the select tag and read this value in my seaside application.

It's possible that we have the same problem with the radio and checkbox tags

In web application, it's a very common practice to dissociate the information displayed for the user and the data exchanged between the client and the server.

http://www.w3schools.com/tags/att_option_value.asp

I used this approach in all my previous web applications with many programming languages (C, Rebol, Perl, PHP, ...). Why not with Pharo and Seaside ? .

In fact in the callback, I think that the server code must not work with the label value but with the value of the tag. It's not the same thing.

Olivier ;-)


Olivier,

 

No, you have a way of separately providing display ‘labels’ for your actual objects in the list,

 

(html select)

list: self countries;

selected: country;

enabled: [:ea | ea notNil];

labels: [:ea | ea ifNil: ['---'] ifNotNil: [ea name]];

callback: [:value | country := value].

 

-Boris

 

From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:16 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag

 

Hi Boris,

This means that I must analyze the choice of the user from the text that is displayed on the screen. ok :-(

But how can I must doing if my application supports many languages ?

Olivier ;-)

The framework will pass an actual 'selected' object from your 'list' into the callback, what it puts in the 'value' in the HTML should be completely irrelevant to you.
 
-Boris
 
 
-----Original Message-----
From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:00 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag
 
if I can't set and read the value of an option tag. How can I know the index of the selected line ?
 
Olivier ;-)
2011/9/29 Olivier Auverlot[hidden email]:
Hi,
 
I need to use a drop-down menu in a seaside application. In the 
examples that I have found, the displayed values are initialized with #list:
 
html  select
        list:  #(#Male  #Female);
        selected:  self  contact  gender;
        callback:  [  :value  |
                value  =  #Male
                ifTrue:  [  self  contact  beMale  ]
                ifFalse:  [  self  contact  beFemale  ]  ].
 
In the browser, I get this HTML code :
 
<select  name="3"><option  value="1"selected="selected">Male</option><option
  value="2">Female</option></select>
 
My problem is how to set the values for each<option>  tag ? I would 
get something like :
Why do you want to do this?
 
Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

 

_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: Using the select tag

Boris Popov, DeepCove Labs (SNN)

Olivier,

 

Seaside generates unique values for you to be able to look up an actual object and feed it into the callback, what I’m saying is that you don’t need to worry about those at all – you populate the list with objects, possibly using custom label getters and wait until you get an object fed into your callback.

 

-Boris

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 3:10 PM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag

 

Thank Boris but I don't know if your example can resolve my question. The problem is not to produce labels but setting a unique value for each line of the select tag and read this value in my seaside application.

It's possible that we have the same problem with the radio and checkbox tags

In web application, it's a very common practice to dissociate the information displayed for the user and the data exchanged between the client and the server.

http://www.w3schools.com/tags/att_option_value.asp

I used this approach in all my previous web applications with many programming languages (C, Rebol, Perl, PHP, ...). Why not with Pharo and Seaside ? .

In fact in the callback, I think that the server code must not work with the label value but with the value of the tag. It's not the same thing.

Olivier ;-)



Olivier,

 

No, you have a way of separately providing display ‘labels’ for your actual objects in the list,

 

(html select)

list: self countries;

selected: country;

enabled: [:ea | ea notNil];

labels: [:ea | ea ifNil: ['---'] ifNotNil: [ea name]];

callback: [:value | country := value].

 

-Boris

 

From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:16 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag

 

Hi Boris,

This means that I must analyze the choice of the user from the text that is displayed on the screen. ok :-(

But how can I must doing if my application supports many languages ?

Olivier ;-)


The framework will pass an actual 'selected' object from your 'list' into the callback, what it puts in the 'value' in the HTML should be completely irrelevant to you.
 
-Boris
 
 
-----Original Message-----
From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:00 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag
 
if I can't set and read the value of an option tag. How can I know the index of the selected line ?
 
Olivier ;-)
2011/9/29 Olivier Auverlot[hidden email]:
Hi,
 
I need to use a drop-down menu in a seaside application. In the 
examples that I have found, the displayed values are initialized with #list:
 
html  select
        list:  #(#Male  #Female);
        selected:  self  contact  gender;
        callback:  [  :value  |
                value  =  #Male
                ifTrue:  [  self  contact  beMale  ]
                ifFalse:  [  self  contact  beFemale  ]  ].
 
In the browser, I get this HTML code :
 
<select  name="3"><option  value="1"selected="selected">Male</option><option
  value="2">Female</option></select>
 
My problem is how to set the values for each<option>  tag ? I would 
get something like :
Why do you want to do this?
 
Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

 

 
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

 


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

Lukas Renggli
In reply to this post by Olivier Auverlot
> I used this approach in all my previous web applications with many
> programming languages (C, Rebol, Perl, PHP, ...). Why not with Pharo and
> Seaside ? .
>
> In fact in the callback, I think that the server code must not work with the
> label value but with the value of the tag. It's not the same thing.

Seaside is different by design.

In fact you give Seaside the list of objects you want to display in
the select-box and Seaside tells you which one of these objects was
selected. That's it.

Everything else, like POST URLs, <select> name, <option> values, ...
are automatically generated by Seaside for you. If you let Seaside do
that, things are really easy; if you want to do that yourself, Seaside
might not be the right choice (although you can tell it not to do it
for you).

Lukas

--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

Bob Arning
In reply to this post by Olivier Auverlot

Perhaps it might be clearer to rewrite Boris's example as:


(html select)

    list: self genders;

    selected: self contact gender;

    enabled: [:ea | ea notNil];

    labels: [:ea | ea ifNil: ['---'] ifNotNil: [ea printableVersion]];

    callback: [:value | self contact gender: value].


Where Gender becomes a first-class object rather than some String, Character or Integer value.

Cheers,
Bob

On 9/29/11 3:09 PM, Olivier Auverlot wrote:
Thank Boris but I don't know if your example can resolve my question. The problem is not to produce labels but setting a unique value for each line of the select tag and read this value in my seaside application.

It's possible that we have the same problem with the radio and checkbox tags

In web application, it's a very common practice to dissociate the information displayed for the user and the data exchanged between the client and the server.

http://www.w3schools.com/tags/att_option_value.asp

I used this approach in all my previous web applications with many programming languages (C, Rebol, Perl, PHP, ...). Why not with Pharo and Seaside ? .

In fact in the callback, I think that the server code must not work with the label value but with the value of the tag. It's not the same thing.

Olivier ;-)


Olivier,

 

No, you have a way of separately providing display ‘labels’ for your actual objects in the list,

 

(html select)

list: self countries;

selected: country;

enabled: [:ea | ea notNil];

labels: [:ea | ea ifNil: ['---'] ifNotNil: [ea name]];

callback: [:value | country := value].

 

-Boris

 

From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:16 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag

 

Hi Boris,

This means that I must analyze the choice of the user from the text that is displayed on the screen. ok :-(

But how can I must doing if my application supports many languages ?

Olivier ;-)

The framework will pass an actual 'selected' object from your 'list' into the callback, what it puts in the 'value' in the HTML should be completely irrelevant to you.
 
-Boris
 
 
-----Original Message-----
From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:00 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag
 
if I can't set and read the value of an option tag. How can I know the index of the selected line ?
 
Olivier ;-)
2011/9/29 Olivier Auverlot[hidden email]:
Hi,
 
I need to use a drop-down menu in a seaside application. In the 
examples that I have found, the displayed values are initialized with #list:
 
html  select
        list:  #(#Male  #Female);
        selected:  self  contact  gender;
        callback:  [  :value  |
                value  =  #Male
                ifTrue:  [  self  contact  beMale  ]
                ifFalse:  [  self  contact  beFemale  ]  ].
 
In the browser, I get this HTML code :
 
<select  name="3"><option  value="1"selected="selected">Male</option><option
  value="2">Female</option></select>
 
My problem is how to set the values for each<option>  tag ? I would 
get something like :
Why do you want to do this?
 
Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

 

_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

sebastianconcept@gmail.co
In reply to this post by Olivier Auverlot

On Sep 29, 2011, at 10:00 AM, Olivier Auverlot wrote:

if I can't set and read the value of an option tag. How can I know the index of the selected line ?

let seaside do that for you. By far that's the easy way

If you want hackish values in the each <option> you can try non standard attributes or javascript vars in each element



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Using the select tag

Olivier Auverlot
In reply to this post by Bob Arning
Hi Bob,

ok ! I understood now. I was stuck in an obsolete model based on strings.

Thank you for the help of the community

Olivier :-)

PS: In the future, I promise to try to not think in Perl, Rebol or PHP...

Perhaps it might be clearer to rewrite Boris's example as:


(html select)

    list: self genders;

    selected: self contact gender;

    enabled: [:ea | ea notNil];

    labels: [:ea | ea ifNil: ['---'] ifNotNil: [ea printableVersion]];

    callback: [:value | self contact gender: value].


Where Gender becomes a first-class object rather than some String, Character or Integer value.

Cheers,
Bob

On 9/29/11 3:09 PM, Olivier Auverlot wrote:
Thank Boris but I don't know if your example can resolve my question. The problem is not to produce labels but setting a unique value for each line of the select tag and read this value in my seaside application.

It's possible that we have the same problem with the radio and checkbox tags

In web application, it's a very common practice to dissociate the information displayed for the user and the data exchanged between the client and the server.

http://www.w3schools.com/tags/att_option_value.asp

I used this approach in all my previous web applications with many programming languages (C, Rebol, Perl, PHP, ...). Why not with Pharo and Seaside ? .

In fact in the callback, I think that the server code must not work with the label value but with the value of the tag. It's not the same thing.

Olivier ;-)


Olivier,

 

No, you have a way of separately providing display ‘labels’ for your actual objects in the list,

 

(html select)

list: self countries;

selected: country;

enabled: [:ea | ea notNil];

labels: [:ea | ea ifNil: ['---'] ifNotNil: [ea name]];

callback: [:value | country := value].

 

-Boris

 

From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:16 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag

 

Hi Boris,

This means that I must analyze the choice of the user from the text that is displayed on the screen. ok :-(

But how can I must doing if my application supports many languages ?

Olivier ;-)

The framework will pass an actual 'selected' object from your 'list' into the callback, what it puts in the 'value' in the HTML should be completely irrelevant to you.
 
-Boris
 
 
-----Original Message-----
From: [hidden email] [[hidden email]] On Behalf Of Olivier Auverlot
Sent: Thursday, September 29, 2011 9:00 AM
To: Seaside - general discussion
Subject: Re: [Seaside] Using the select tag
 
if I can't set and read the value of an option tag. How can I know the index of the selected line ?
 
Olivier ;-)
2011/9/29 Olivier Auverlot[hidden email]:
Hi,
 
I need to use a drop-down menu in a seaside application. In the 
examples that I have found, the displayed values are initialized with #list:
 
html  select
        list:  #(#Male  #Female);
        selected:  self  contact  gender;
        callback:  [  :value  |
                value  =  #Male
                ifTrue:  [  self  contact  beMale  ]
                ifFalse:  [  self  contact  beFemale  ]  ].
 
In the browser, I get this HTML code :
 
<select  name="3"><option  value="1"selected="selected">Male</option><option
  value="2">Female</option></select>
 
My problem is how to set the values for each<option>  tag ? I would 
get something like :
Why do you want to do this?
 
Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
 
 
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

 

_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside