我必须选择一个菜单,这不是将代码从视图发送到对象到托管 bean。我不知道发生了什么。
看法:
<p:selectOneMenu value="#{administracionEmpresas.faxServer}" style="margin-bottom: -6px" converter="faxServerConverter" required="true">
<f:selectItem itemLabel="FaxServer" itemValue="" noSelectionOption="true"/>
<f:selectItems value="#{administracionEmpresas.listFaxServer}" var="faxServer" itemLabel="#{faxServer.descripcion}" itemValue="#{faxServer}"/>
</p:selectOneMenu>
转换器:
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if (value.trim().isEmpty()) {
System.out.println("Valor:" +value);
SlpFaxServer e = new SlpFaxServer();
e.setIdFaxServer("173ace38-7");
return e;
} else {
funciones = new FuncionesHibernate(SlpFaxServer.class);
System.out.println("Id Fax Server: " + value);
SlpFaxServer var = funciones.getEntidad(value.toString());
System.out.println("Valor ID:" + var.getIdFaxServer());
return var;
}
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (value != null && value instanceof SlpFaxServer) {
SlpFaxServer var = (SlpFaxServer) value;
System.out.println("Valor getAsString: " + var.getIdFaxServer());
return "" + var.getIdFaxServer();
}
return "";
}