Help About Edit

Hi all,

this code not found:

Usuario u=new Usuario(); u.setId(6); BeanFieldGroup fieldGroup = new BeanFieldGroup<Usuario>(Usuario.class); fieldGroup.setItemDataSource(new BeanItem<Usuario>(u)); fieldGroup.bind(txtNombre, "nombre"); The result is null :frowning:

What do you mean ā€œthe result is nullā€? Which result? The code you pasted looks good, no problems there. Do you mean that the textfield has a value of ā€œnullā€ in it? If thatā€™s the problem, then please read
the chapter about handling null values
.

Becouse i click a row and get a element ID, after that i need to complete the textfield and combobox to update elementsā€¦

Hi:

first selected item in a table and obtenego ID , then I pressed the button and open the UN edit window, then that must bring all loaded elements in the text boxes to make the upgrade . By now Iā€™m Solving follows , sea But I do not think right.

Attach Image.

TABLE USUARIO(id,nombre,apepat,apemat,fono,celular,ciudad_id,estado) TABLE CIUDAD(id,nombre,estado) Fist get the element id of table:

tabla.setSelectable(true); tabla.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent itemClickEvent) { id = (Integer) itemClickEvent.getItem().getItemProperty("id").getValue(); } }); Second i show de the windows and load element:

....
//FIND WITH ID AND COMPLETE TEXTFIELD AND COMBOBOX
        UsuarioDAO uDAO = new UsuarioDAO();
        List<Usuario> c = uDAO.buscarPorId(id);
        for (int i = 0; i < c.size(); i++) {
            System.out.println("" + i);
            System.out.println("NOMBRE" + c.get(i).getNombre());
            txtNombre.setValue(c.get(i).getNombre());
            txtApepat.setValue(c.get(i).getApepat());
            txtApemat.setValue(c.get(i).getApemat());
            txtFono.setValue(c.get(i).getFono());
            txtCelular.setValue(c.get(i).getCelular());
            comboCiudad.setNewItemsAllowed(true);
            comboCiudad.addItem(c.get(i).getCiudad().getNombre());
            comboCiudad.setValue(c.get(i).getCiudad().getNombre());
            txtEstado.setValue(c.get(i).getEstado());
            comboCiudad.setEnabled(false);

        }
//IF I CLICK  THE BUTTON EDIT SHOW SELECT * FROM CIUDAD AND COMPLETE COMBOBOX
        btnEdit.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                comboCiudad.setEnabled(true);
                CiudadDAO cDAO=new CiudadDAO();
                BeanItemContainer bic = new BeanItemContainer<Ciudad>(Ciudad.class, cDAO.mostrarTodo());
                comboCiudad.setItemCaptionPropertyId("nombre");
                comboCiudad.setContainerDataSource(bic);
            }
        });

  ...    

Attach Image.

Thank you.

Bye

21503.png

So what is the problem? You mentioned in your original post about ā€œresult is nullā€ - I donā€™t see anything being null in your screenshot. Sorry, but I canā€™t quite understand what the problem is that your are facing.