title: How to integrate the controller with form (Hibernate Spring Vaadin)
body: <p>I'm busing developing an application (Hibernate Spring Vaadin Postgres Liferay).
  I did all of the configurations for the project (Hibernate, Spring, Postgres) and
  I generated a database, but when I do a dynamic formulaire I have a problem integrating the controller with the form.</p>
  
  <p>This is the article.java:</p>
  
  <pre><code> package com.bd.entity;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name="Articlet")
  public class Article {
  
      int id;
      String nom;
      String type;
      int qte;
  
  
      public Article() {
          super();
          // TODO Auto-generated constructor stub
      }
      @Id
      @GeneratedValue
       @Column(name="ID")
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
       @Column(name="Nom")
      public String getNom() {
          return nom;
      }
      public void setNom(String nom) {
          this.nom = nom;
      }
       @Column(name="Type")
      public String getType() {
          return type;
      }
      public void setType(String type) {
          this.type = type;
      }
       @Column(name="Qunatite")
      public int getQte() {
          return qte;
      }
      public void setQte(int qte) {
          this.qte = qte;
      }
  
  
  
  
  }
  </code></pre>
  
  <p>This is articledaoimpl.java:</p>
  
  <pre><code>  package com.bd.dao;
  
  import java.util.Collection;
  import java.util.List;
  
  
  
  import org.hibernate.SessionFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  
  import org.springframework.context.annotation.Configuration;
  import org.springframework.stereotype.Repository;
  import org.springframework.transaction.annotation.Transactional;
  
  import com.bd.entity.Article;
  @Repository
  @Configuration
  
  @Transactional
  public class ArticleDaoImp implements ArticleDao {
  
      @Autowired
      SessionFactory sessionFactory;
  
      @SuppressWarnings("unchecked")
      @Transactional(readOnly = true)
      public List&lt;Article&gt; getAll() {
  
          return sessionFactory.getCurrentSession().createQuery("from Article")
                  .list();
      }
  
      @Transactional(readOnly = true)
      public Article getById(int articleId) {
  
          return (Article) sessionFactory.getCurrentSession().get(Article.class,
                  articleId);
      }
  
      @Override
      public void save(Article article) {
          sessionFactory.getCurrentSession().merge(article);
  
      }
  
      @Override
      public void delete(Article article) {
          sessionFactory.getCurrentSession().delete(article);
  
      }
  
  }
  </code></pre>
  
  <p>This is articleserviceimpl.java:</p>
  
  <pre><code> package com.bd.service;
  
  import java.util.Collection;
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.stereotype.Service;
  
  import com.bd.dao.ArticleDao;
  import com.bd.entity.Article;
  
  @Service
  @Configuration
  @ComponentScan("com.bd.dao")
  
  public class ArticleServiceImp implements ArticleService {
  
      @Autowired
      private ArticleDao articledao;
  
  
  
      @Override
      public Article getArticleById(int articleId) {
          // TODO Auto-generated method stub
          return articledao.getById(articleId);
      }
  
      @Override
      public void saveArticle(Article article) {
          // TODO Auto-generated method stub
          articledao.save(article);
  
      }
  
      @Override
      public void deleteArticle(Article article) {
          // TODO Auto-generated method stub
          articledao.delete(article);
      }
  
      @Override
      public List&lt;Article&gt; getAllArticles() {
          // TODO Auto-generated method stub
          return articledao.getAll();
      }
  
  }
  </code></pre>
  
  <p>This is the article controleur:</p>
  
  <pre><code>    package com.bd.controleur;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.stereotype.Controller;
  
  import com.bd.entity.Article;
  import com.bd.service.ArticleService;
  
  @Controller
  @Configuration
  @ComponentScan("com.bd.service")
  
  public class ArticleControleur {
  
      @Autowired
      ArticleService articleService;
  
      public void addarticle(Article  article){
          articleService.saveArticle(article);
      }
  }
  </code></pre>
  
  <p>This the form:</p>
  
  <pre><code>    package achrefliferay;
  
  import org.springframework.beans.factory.annotation.Autowired;
  
  import com.bd.entity.Article;
  import com.bd.service.ArticleService;
  import com.vaadin.Application;
  import com.vaadin.ui.Button;
  import com.vaadin.ui.TextField;
  import com.vaadin.ui.VerticalLayout;
  import com.vaadin.ui.Window;
  import com.vaadin.ui.Button.ClickEvent;
  
  
  
  public class AchrefliferayApplication extends Application {
  
      @Autowired
      ArticleService articleService;
  
  
      public void init() {
          Article article;
  
          Window w = new Window("Subscribe Newsletter");
          setMainWindow(w);
          w.setContent(new VerticalLayout());
          TextField name = new TextField("Name");
          TextField type = new TextField("Type");
          TextField qte = new TextField("Quantité");
          Button subscribeBtn = new Button("saisi");
          w.addComponent(name);
          w.addComponent(type);
          w.addComponent(qte);
          w.addComponent(subscribeBtn);
  
          subscribeBtn.addListener(new Button.ClickListener() {
  
              @Override
              public void buttonClick(ClickEvent event) {
  
              articleService.saveArticle();   
              }
          });
      }
  
  }
  </code></pre>