我的方法在负责 Vaadin View 的类中调用。当他们尝试在主类中调用它进行测试时,一切正常。这是我在 Repository 类中的方法,我的问题是关于 findAll 类:
@Repository
public class SeansRepository {
@Autowired
JdbcTemplate jdbcTemplate;
public Seans findById(long id) {
return jdbcTemplate.queryForObject("select * from seans where id=? ", new Object[] { id },
new BeanPropertyRowMapper<Seans>(Seans.class));
}
public Collection<Seans> findAll() {
Collection<Seans> seans = (Collection<Seans>) jdbcTemplate.query("select * from seans", new BeanPropertyRowMapper(Seans.class));
return seans;
}
public int deleteById(long id) {
return jdbcTemplate.update("delete from seans where id=?", new Object[] { id });
}
}
这是在 View 类中调用方法的方式:
@DesignRoot
@AutoGenerated
@SuppressWarnings("serial")
public class ChoseNumberOfTicketsView extends AbsoluteLayout implements View{
protected TextField nameTextField;
protected TextField surnameTextField;
protected Label menuLabel;
protected TextField emailTextField;
protected TextField dticketsTextField;
protected TextField nticketsTextField;
protected ComboBox<Seans> movieComboBox;
private SeansRepository repository;
public ChoseNumberOfTicketsView() {
Design.read(this);
repository = new SeansRepository();
movieComboBox = new ComboBox<>("Chose the movie");
movieComboBox.setItems(repository.findAll());
}
}
我正在尝试获取电影列表并将其放在 ComboBox 中以供选择。
我正在添加一个 UI 类,其中包含我的视图实例:
@SpringUI
public class KinoUI extends UI{
Navigator navigator;
@Override
protected void init(VaadinRequest request) {
getPage().setTitle("Exam");
navigator = new Navigator(this, this);
navigator.addView("", new StartView());
navigator.addView("chosenumberoftickets", new ChoseNumberOfTicketsView());
}
}
PIPIONE
相关分类