带有选项列表的表格:
<p:inputText id="number" value="#{accountNumberBean.account.accountNumber}" required="true" label="#{msg['newAccountNumberForm.number']}">
<f:validateLength maximum="50" for="name" />
</p:inputText>
<p:message for="number" display="text" />
<p:pickList id="integrations" value="#{accountNumberBean.integrations}" var="integration" itemLabel="#{integration.name} (#{integration.backend.name})" itemValue="#{integration}" converter="integrationConverter">
<f:facet name="sourceCaption">#{msg['newAccountNumberForm.integrations.available']}/>
<f:facet name="targetCaption">#{msg['newAccountNumberForm.integrations.used']}/>
</p:pickList>
<p:commandButton value="#{msg['button.createAndNext']}" action="#{accountNumberBean.addNewAndStay}" update="@form" />
当我不填写数字输入时,单击命令按钮 - 显示验证消息,但选项列表中的对象标签会更新,它们只是空括号。
itemLabel="#{integration.name} (#{integration.backend.name})"
当我选择它们并填写名称时 - 一切正常(就像我首先填写名称一样),所以唯一的问题是标签。这是我的转换器:
@FacesConverter(forClass = Integration.class, value = "integrationConverter")
public class IntegrationConverter implements Converter {
/**
* {@inheritDoc}
*/
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
Integration integration = new Integration();
integration.setId(Long.parseLong(value));
return integration;
}
/**
* {@inheritDoc}
*/
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
return ((Integration) value).getId().toString();
}
}
以及 bean 上获取集成的方法(bean 是视图范围的):
public DualListModel<Integration> getIntegrations() {
integrations.setSource(customerService.getIntegrations(customer));
return integrations;
}
是什么导致标签为空?