gpt4 book ai didi

java - BeanFieldGroup,在 ComboBox 中绑定(bind) List

转载 作者:行者123 更新时间:2023-12-01 12:40:21 26 4
gpt4 key购买 nike

我正在尝试绑定(bind)一个组合框来显示 List<String> 的值带注释@ElementCollection但不起作用并返回一些异常。

我正在尝试这个。

@Entity
public class UnidadeEscolar implements Serializable{
private static final long serialVersionUID = 1L;

@Id @GeneratedValue
private Long id;

@NotNull @NotEmpty @Size(min=5, max=50) @Column(unique=true)
private String nome;

@Enumerated(EnumType.STRING)
private Departamento departamento;

private String cep;
private String endereco;
private String numero;
private String complemento;
private String bairro;
private String cidade;

@Enumerated(EnumType.STRING)
private EstadosDoBrasil uf;

@ElementCollection
@CollectionTable(name="tf_unescolar", joinColumns=@JoinColumn(name="id_unescolar"))
@Column(name="telefone")
private List<String> telefones = new ArrayList<String>();

//gets and sets


//view
//datasource
private final CustomJPAContainer<UnidadeEscolar> datasource = new CustomJPAContainer<UnidadeEscolar>(UnidadeEscolar.class);

//bean
private UnidadeEscolar bean = new UnidadeEscolar();

//beanfieldgroup - binder
private BeanFieldGroup<UnidadeEscolar> binder = new BeanFieldGroup<UnidadeEscolar>(UnidadeEscolar.class);

//fields
ComboBox telefone = new ComboBox("Phones", bean.getTelefoneContato());
binder.bind(telefone, "telefones");
bottom.addComponent(telefone);


//exceptions
ago 06, 2014 11:50:02 AM com.vaadin.server.DefaultErrorHandler doDefault
GRAVE:
java.lang.IllegalArgumentException: Bean property 'telefones' not found
at com.vaadin.data.util.NestedMethodProperty.initialize(NestedMethodProperty.java:146)
at com.vaadin.data.util.NestedMethodProperty.<init>(NestedMethodProperty.java:92)
at com.vaadin.data.util.BeanItem.addNestedProperty(BeanItem.java:267)
at com.vaadin.data.fieldgroup.BeanFieldGroup.ensureNestedPropertyAdded(BeanFieldGroup.java:159)
at com.vaadin.data.fieldgroup.BeanFieldGroup.bind(BeanFieldGroup.java:166)
at br.com.webapp.views.UnidadeEscolarView.buildBottomLayout(UnidadeEscolarView.java:192)
at br.com.webapp.views.UnidadeEscolarView.buildVerticalSplitPanel(UnidadeEscolarView.java:93)
at br.com.webapp.views.UnidadeEscolarView.buildMainLayout(UnidadeEscolarView.java:81)
at br.com.webapp.views.UnidadeEscolarView.<init>(UnidadeEscolarView.java:70)
at br.com.webapp.utils.WebAppMenu$1.menuSelected(WebAppMenu.java:61)
at com.vaadin.ui.MenuBar.changeVariables(MenuBar.java:186)
at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:396)
at com.vaadin.server.communication.ServerRpcHandler.handleBurst(ServerRpcHandler.java:221)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:111)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:91)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1382)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoSuchMethodException: br.com.webapp.bean.UnidadeEscolar.areTelefones()
at java.lang.Class.getMethod(Unknown Source)
at com.vaadin.data.util.MethodProperty.initGetterMethod(MethodProperty.java:541)
at com.vaadin.data.util.NestedMethodProperty.initialize(NestedMethodProperty.java:141)
... 40 more

最佳答案

java.lang.NoSuchMethodException: br.com.webapp.bean.UnidadeEscolar.areTelefones()

似乎您忘记了 UnidadEscolar 类中属性 telefones 的 get/set 方法。

关于java - BeanFieldGroup,在 ComboBox 中绑定(bind) List<String>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25163592/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com