Getting field value from SQLcontainer

Hi! I’m new to Vaadin and Java world, dut have some expirience in pl\sql (if it matters).
I have an issue with using
SQLcontainer
and need your help.

So, in my application I query Oracle database using Vaadin
FreeFormQuery
like this:

“SELECT text_field , number_field
FROM table”
.

After that, I hope, my
SQLcontainer
contains some kind of a table data. I want to use
text_field
it to fill a
ListSelect
, but I can’t.

  1. How can I choose a field, whiich must be displayed in
    ListSelect
    ? Right now I have
    ListSelect
    filled with
    number_field
    data, and I want to see
    text_field
    data there. Is it possible to do it without cycle (my associates use cycle and .addItem() method, but is there an easy way?);

  2. Suppose, I have my
    ListSelect
    filled right. How can I get a
    number_field
    value, which matches the selected
    text_field
    value from the
    ListSelect
    ? (my associates use ArrayList class, and I’m not sure that i clearly understand how it works. Is there an easy way?).

Excuse my possible mistakes, I have had lack of english practice during last years.
Thank you for reading.

I suppose you’re setting the SQLContainer as the data source for your ListSelect. In that case this should work:

yourListSelect.setItemCaptionPropertyId("text_field");

For getting the number_field of the selection, you could use something like this (note that if multi-select is enabled you must change this a bit):

yourListSelect.getContainerProperty(yourListSelect.getValue(), "number_field").getValue();

Thank you very much!

Hi,
I’m not sure if I’m on the right threat but anyway …

is there any chance to get the primary key of a Item from the SQLContainer, when I only have the value of the non primary Key Column?

like i have a Table which have only 2 Columns

ID, TEXT

and i only have the Text in sql it would be like

select id from table where text= ‘text’

Thank you in advance