TextField.focus()

Hi all !

Again I need you guys help !

I can not focus on any textfield. Specifically in the textfield

txtQtde

.

Now im using Vaadin Framework 7.4.7

Follow part of my code.

btnIncluir.addClickListener(new ClickListener() {
   public void buttonClick(ClickEvent event) {

      final Window window = new Window("INCLUIR PRODUTO NA SEÇÃO : " + nroSecao);
      window.setWidth("400px");
      window.setModal(true);
      window.setResizable(false);
                        
      VerticalLayout layout = new VerticalLayout();
      layout.setWidth("100%");
      layout.setMargin(true);
      layout.setSpacing(true);
      window.setContent(layout);
                        
      final TextField txtQtde = new TextField("Quantidade");
      layout.addComponent(txtQtde);
                              
      Button btnConfirmar = new Button("Confirmar", FontAwesome.CHECK);
      btnConfirmar.setWidth("100%");
      layout.addComponent(btnConfirmar);
                        
      btnConfirmar.addClickListener(new ClickListener() {
      public void buttonClick(ClickEvent event) {
                                
         Double qtde = 0.0;
                                
         try {
                                    
            qtde = Double.parseDouble(txtQtde.getValue().toString().trim());

         } 
         catch (NumberFormatException e) {
                                    
            Notification n = new Notification("", "APENAS NÚMEROS E PONTO DECIMAL !", Type.WARNING_MESSAGE);
            n.setPosition(Position.TOP_CENTER);
            n.setStyleName(ValoTheme.NOTIFICATION_FAILURE);
            n.setDelayMsec(500);
            n.show(Page.getCurrent());
                                    
            txtQtde.focus();
            txtQtde.selectAll();
                                    
            return;
                                       
         } 
                                
         Dados dados = (Dados) btnIncluir.getData();
         Long idSecao = dados.getIdSecao();
         String codBusca = txtProduto.getValue().toString().trim();
         Long idProduto = dados.getIdProduto();
                                
         Connection conexao = null;
                                
         try {
                                    
            conexao = ConnectionFactory.getConnection();
            String sql = "{? = call p_Ajuste20_IncluiProd(?,?,?,?,?)}";
                                    
            CallableStatement cs = conexao.prepareCall(sql);                   
            cs.registerOutParameter(1, Types.OTHER);
                                    
            cs.setLong(2, idSecao);
            cs.setLong(3, 1);
            cs.setString(4, codBusca);
            cs.setLong(5, idProduto);
            cs.setDouble(6, qtde);
                                    
            ResultSet rs = cs.executeQuery();
                                    
            while(rs.next()) {
                                        
               if(rs.getLong("Codigo") == 1) {
                                            
                  Notification n = new Notification("", rs.getString("Retorno").toString(), Type.WARNING_MESSAGE);
                  n.setPosition(Position.TOP_CENTER);
                  n.setStyleName(ValoTheme.NOTIFICATION_FAILURE);
                  n.setDelayMsec(500);
                  n.show(Page.getCurrent());
                                            
                  return;
                                            
               }
                                        
            }

            UI.getCurrent().removeWindow(window);
            listarProdutoSecao();
            txtSecao.focus();
            txtSecao.selectAll();
                                    
         }
         catch(SQLException | IOException e) {
                                    
            Notification n = new Notification("Atenção", e.getMessage(), Type.ERROR_MESSAGE);
            n.setPosition(Position.TOP_CENTER);
            n.setStyleName(ValoTheme.NOTIFICATION_SYSTEM);
            n.show(Page.getCurrent());
                                    
            return;
                                    
         }
                                
      }
   });
                        
   UI.getCurrent().addWindow(window);
   txtQtde.focus(); // --> I need focus here
                        
}
});

Seems like a bug with 7.4.5+ raised in this ticket,
https://dev.vaadin.com/ticket/17731
. Can you try using Vaadin 7.4.4?

I will.
Thanks Emmanuelle