Obtener código del valor seleccionado en un combo box / Get code of value selected in a combo box

1
0
-1

Hola,

Estoy con un problema, si me pueden ayudar

  1. Como mapear tipo objeto a una lista de opciones en el formulario Sabiendo que objeto cuenta con estos campos: objeto{id:1, descripcion: "nombre1"}

Hasta el momento sólo puedo obtener una lista (List) y no ambos campos que necesito.

  1. Obtener id del objeto seleccionado Tengo un formulario, que tiene un campo de selección el cual muestra el campo descripción que se obtiene de una base de datos. Lo que intento hacer es, al seleccionar una determinada descripción obtener el "id" para reconocer el objeto, que es una fk(clave foránea en la DB).

Saludos :)

Hello, I have a problem, help me please

  1. how I can mapping a object type to a list of objects in a form? the object representation as follows: objeto{id:1, descripcion: "nombre1"}

Until now only I can get a list (List) and I need both fields.

  1. Get object id selected I have a form, it has a selection field, this show the description field wich it's obtained from database. I'm trying to do is, when I select a specific description get the "id" for recognize the object, wich is a fk(foreign key in the database).

regards :)

Comments

Submitted by yannick.lombardi on Fri, 05/22/2015 - 09:24

Hi.

If you are familiar with Java object, you can create your own java class and export it as a jar to use it in Bonita.

Another easier solution, I recommand to use a HashMap.

ArrayList<HashMap<String, Object>> objetoList = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> objeto = new HashMap<String, Object>();
objeto.put("id",1);
objeto.put("descripcion", "nombre1");
objetoList.add(objeto);

To display the list of description in a select widget you can do this :

ArrayList<String> descripcionList = new ArrayList<String>();
for (HashMap<String, Object> objeto : objetoList) {
String descripcion = (String) objeto.get("descipcion");
descripcionList.add(descripcion);
}

In the end, to get the id from the description, you can do this :

for (HashMap<String, Object> objeto : objetoList) {
if (objeto.get("descipcion").equals(selectedDesciption)) return (Integer) objeto.get("id");
}
Submitted by clara.lopez on Tue, 05/26/2015 - 05:37

Hi Lombardi..

thank you so much, for take a time to answers my question.

This works!!

I'm create my Java Object and import a .jar in bonita and add in process dependency.

Steps

  1. Create my object in eclipse and export to a jar file
  2. Import my object in bonita and add to process dependency
  3. Create a ArrayList

and then I use your example to display the description and get de id.

PD: Lo siento, por responder recién. I'm sorry for my bad english.

Que estes bien :)

Submitted by rodrigojcortes on Wed, 11/18/2015 - 16:43

hola jhoana podrias explicarme esto de una forma mas clara, gracias por tu ayuda, si es posible contactarte mi correo es rojaco007@gmail.com.

Muchas gracias

No answers yet.
Notifications