Yes -- if the combobox ever varies from user to user or over time,
then the only way to safely get the label is by the means you
state below. (Other variants getDisplayFieldValue() ok as well of
course, such as CSpDisplayField.getValue() ... but the end result
is the same.)

If the combobox never, ever changes its contents, then Bob Eovine's
approach is fine and dandy.  Otherwise, you MUST do as you've
noted if you want the labels.

This limitation is a consequence of HTML and how comboboxes et. al.
are represented.  The labels as such are never sent back to the
server with the button click.  Given that you can't ever guarrantee
returning back to the CP-Worker and project instance from whence 
you came, and even if you could someone else may have used it in 
the meanwhile, you can't ask the combobox in the CP for its labels 
and get a meaningful answer -- unless it never, ever changes.  

I think there's somewhat of a discussion of this under 
CSpSelectable.getSelected() in the doc set.  It's one of many 
completely valid, yet not necessarily obvious consequences of 
the architecuture that must be understood to write correct applications.
It's not a flaw in the architecuture, but rather a consequence of
a design that consciously re-uses server componenents to yield scalability.

Best,

a.
         .        .        .        .        .        .
Andy Cohen                                 PMB 333
[EMAIL PROTECTED]                  351 Pleasant Street
413.586.2180 direct                        Northampton, MA 01060
212.656.1155 vmail/fax                    
       Software Springs: Software Development, Training, & Troubleshooting

At 01:59 PM 9/6/99 -0500, Shamdasani Nimmi-ANS004 wrote:
>Andy,
>
>Thanks for your response.
>
>So you are saying that the only way to get the label is by putting that also
>as part of the value and extracting it from the result of
>getDisplayFieldValue("ComboBox1"). Right?
>
>-Nimmi
>
>-----Original Message-----
>From: Andy Cohen [mailto:[EMAIL PROTECTED]]
>Sent: Monday, September 06, 1999 6:41 AM
>To: [EMAIL PROTECTED]; Nimmi Shamdasani-ANS004;
>[EMAIL PROTECTED]
>Cc: [EMAIL PROTECTED]
>Subject: Re: [ND] Get the label of the selected item in the Combobox
>
>
>This is a safe thing to do if and only if the combobox/listbox/etc
>is invariant across users.  I.e., if the contents (and labels) vary
>from user to user (or across time), then you have calling getSelected()
>is an error.
>
>Instead, when you set up the CSpSelectable (i.e. combobox, etc) in
>the Studio, you can return both the label and the value.
>
>So to reiterate: if combobox is a 'constant' and never changes from
>user to user, you can use Bob's technique involving getSelected().
>Otherwise, you have to use Nimmi's technique below.
>
>a.
>         .        .        .        .        .        .
>Andy Cohen                                 PMB 333
>[EMAIL PROTECTED]                  351 Pleasant Street
>413.586.2180 direct                        Northampton, MA 01060
>212.656.1155 vmail/fax                   
>       Software Springs: Software Development, Training, & Troubleshooting
>
>
>At 11:31 AM 9/3/99 -0400, [EMAIL PROTECTED] wrote:
>>Nimmi
>>
>>You are in luck.  I built a custom method to do just this.
>>Pass the method the name of the item (your combo box) and it will return
>>the label for the entry the user selected.
>>
>>If you have any questions, please let me know.
>>Bob Eovine
>>General Cinema
>>[EMAIL PROTECTED]
>>
>>
>>      public String getListItemLabel(String sListItemName)
>>      {
>>
>>//-------------------------------------------------------------
>>              // getListItemLabel(String sListItemName)
>>
>>//-------------------------------------------------------------
>>              // DESCRIPTION:
>>              // THIS METHOD WILL TAKE THE PASSED LIST ITEM NAME (THE
>>NAME OF
>>              // A VISUAL OBJECT ON THE PAGE) AND GET THE COMBO/LIST
>>BOX'S CURRENTLY
>>              // SELECTED LABEL.  FOR EXAMPLE, IF I AM WORKING WITH
>>THE SHOW TYPE 
>>              // COMBO BOX AND THE REGULAR FEATURE SHOW TYPE IS
>>SELECTED, THEN WHEN
>>              // I GET THE DISPLAY FIELD VALUE, I SHOULD GET 1.  WHEN
>>THE METHOD GETS THE 
>>              // CURRENTLY SELECTED VALUE'S LABEL, IT SHOULD RECEIVE
>>REGULAR FEATURE.
>>              // AUTHOR:  B.EOVINE
>>              // DATE:    6/04/99
>>
>>//-------------------------------------------------------------       
>>
>>              // CREATE A STRING TO HOLD THE LABEL FOR THE CURRENTLY
>>SELECTED ITEM
>>              String sLabel = new String("");
>>              
>>              // GET A HANDLE ON THE CURRENT COMBO BOX PASSED TO THE
>>METHOD
>>              CSpComboBox cmCurrComboBox      = (CSpComboBox)
>>getDisplayField(sListItemName); 
>>
>>              // GET THE CURRENTLY SELECTED ROW
>>              CSpListItem currSelected        = (CSpListItem)
>>cmCurrComboBox.getSelected(); 
>>
>>              // IF IT ISN'T NULL, GET THE LABEL FOR THE ROW
>>              if (currSelected != null) 
>>                      sLabel = currSelected.getLabel(); 
>>              
>>              // RETURN THE ROW LABEL
>>              return(sLabel);
>>
>>      } // END CUSTOM METHOD getListItemLabel(String sListItemName)
>>
>>-----Original Message-----
>>From: Shamdasani Nimmi-ANS004 [mailto:[EMAIL PROTECTED]]
>>Sent: Friday, September 03, 1999 11:24 AM
>>To: 'NetDynamics'
>>Subject: [ND] Get the label of the selected item in the Combobox
>>
>>
>>I have a combobox based on a dataobject where column1 is the value of
>>the
>>item and column2 is the label displayed for that item in the combobox.
>>
>>I want to get both the value and the label of the selected item. The
>>value I
>>can get by:
>>getDisplayFieldValue("ComboBox1").
>>
>>How can I get the label of the selected item? 
>>
>>I hope there is a straight way to do this otherwise I will have to
>>change my
>>combobox's value to contain both column1 and column2 and then extract
>>the
>>two from the selected item value.
>>
>>Thanks.
>>
>>-Nimmi Shamdasani
>>Motorola Manufacturing Systems
>>1299 E. Algonquin Road,
>>Schaumburg, IL 60196
>>
>>
>>________________________________________________________________________
>>_
>>
>>For help in using, subscribing, and unsubscribing to the discussion
>>forums, please go to:
>>http://www.netdynamics.com/support/visitdevfor.html
>>
>>For dire need help, email: [EMAIL PROTECTED]
>>_________________________________________________________________________
>>
>>For help in using, subscribing, and unsubscribing to the discussion
>>forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
>>
>>For dire need help, email: [EMAIL PROTECTED]
>>
>>
>_________________________________________________________________________
>
>For help in using, subscribing, and unsubscribing to the discussion
>forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
>
>For dire need help, email: [EMAIL PROTECTED]
>_________________________________________________________________________
>
>For help in using, subscribing, and unsubscribing to the discussion
>forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
>
>For dire need help, email: [EMAIL PROTECTED]
>
>
_________________________________________________________________________

For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html

For dire need help, email: [EMAIL PROTECTED]

Reply via email to