Hi all,

I'm newbie about AI designer. I'm trying to do something that it should be easy. I want to load a list of values in a Dialog (selectOneMenu) from a DB table. Suppose I have some employees. I want to create a new employee, so I need to assign it to amn existing department. So, I need an object List<department> in the Dialog interface to use it in the selectOneMenu control and save department code when I save this employee data to database.

I'm not finding the way to connect the DB step when I make this query to the dialog step.

Can you help me? Any documentation about this kind of tasks?

BR

asked 17.06.2016 at 15:53

jirazazabal's gravatar image

jirazazabal
(suspended)
accept rate: 0%

edited 17.06.2016 at 15:54


Hi You can use the database element to load the values from the database and store them in a Recordset. Then use the values in the Recordset on the Dialog.

Example:

HTML Dialog with the following Data Class alt text

The Recordset users is loaded by a Database Process Element from a Table in a database. The we use this Recordset in the View like this:

  <p:selectOneMenu value="#{data.userId}" >
    <f:selectItems value="#{data.users}" var="user" itemLabel="#{user.getField('FullName')}" itemValue="#{user.getField('UserId')}"/>
  </p:selectOneMenu>

The value that is displayed is the column FullName of the table (itemLabel). The value that is selected is the column UserId of the table (itemValue). The itemValue of the selected record is stored in the variable data.userId.

link

answered 27.06.2016 at 10:30

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.9k202857
accept rate: 74%

thanks for your response,

It's ok, it's solved using predefined objects recordset and record in Dialog logic:

import project.Departamento;

for (int i=0; i<recordset.size(); i++) {
    Departamento depto = new Departamento();
    depto.setCodigoDepartamento(recordset.getAt(i).getField("codDepartamento").toNumber());
    depto.setNombreDepartamento(recordset.getAt(i).getField("nomDepartamento").toString());

    in.listaDptos.add(depto);
}

And selectOneMenu logic as you use:

<p:selectOneMenu id="departamento" value="#{data.puestoTrabajo.departamento}">
    <f:selectItems value="#{data.listaDptos}" var="item" itemLabel="#{item.nombreDepartamento}" itemValue="#{item.codigoDepartamento}" />
</p:selectOneMenu>
(27.06.2016 at 13:46) jirazazabal jirazazabal's gravatar image

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×78
×5

Asked: 17.06.2016 at 15:53

Seen: 2,298 times

Last updated: 28.06.2016 at 14:02