問題があります。オブジェクトを DB に保存すると正常に動作しますが、DB から取得したいときに動作しません。Omnifaces の selectItemsConverter を使用しています。
「Marca」と「Gama」という 2 つのオブジェクトが内部にあるオブジェクト「Modelo」があります。

これらは私の Java エンティティです (toString() は Omnifaces 用です)。
モデル:
private Marca marca;
private Gama gama;
getters and setters...
@Override
public String toString() {
return String.format("%s[codigo=%d]", getClass().getSimpleName(), getCodigo());
}
マルカ:
getters and setters...
@Override
public String toString() {
return String.format("%s[codigo=%d]", getClass().getSimpleName(), getCodigo());
}
ガマ:
getters and setters...
@Override
public String toString() {
return String.format("%s[codigo=%d]", getClass().getSimpleName(), getCodigo());
}
さて、これは私のmanagedBeanです
モデロビーン
@ManagedBean
@ViewScoped
public class ModeloBean {
private Modelo modelo = new Modelo();
getters and setters ...
//This is for call the DB to retrieve the value, and works fine, but i cant show the preselected value to the xhtml
public void leer(Modelo mo) throws Exception {
ModeloDAO dao = new ModeloDAO();
try {
this.init();
this.modelo = dao.leer(mo);
} catch (Exception e) {
throw e;
} finally {
dao = null;
}
}
これは私のxhtmlページです。オブジェクトの保存と更新に使用したダイアログがあります
<p:dialog id="dlgDatos" widgetVar="wdlgDatos" modal="true" appendToBody="true" header="#{modeloBean.accion}" draggable="false" resizable="false">
<h:form>
<h:panelGrid columns="2">
<p:outputLabel value="Marca" />
<p:selectOneMenu value="#{modeloBean.modelo.marca}" converter="omnifaces.SelectItemsConverter" filter="true" filterMatchMode="startsWith" required="true">
<f:selectItem itemLabel="Seleccione" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{marcaBean.lstMarcasVigentes}" var="marca" itemLabel="#{marca.nombre}" itemValue="#{marca}" />
</p:selectOneMenu>
<p:outputLabel value="Gama" />
<p:selectOneMenu value="#{modeloBean.modelo.gama}" converter="omnifaces.SelectItemsConverter" filter="true" filterMatchMode="startsWith" required="true">
<f:selectItem itemLabel="Seleccione" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{gamaBean.lstGamasVigentes}" var="gama" itemLabel="#{gama.nombre}" itemValue="#{gama}" />
</p:selectOneMenu>
<p:outputLabel for="txtNombre" value="Modelo" />
<p:column>
<p:inputTextarea id="txtNombre" value="#{modeloBean.modelo.nombre}" />
<p:watermark for="txtNombre" value="Para registrar varios modelos, sepárelos por comas (,)" />
</p:column>
<p:outputLabel value="Vigencia" rendered="#{modeloBean.accion eq 'Modificar'}"/>
<p:selectBooleanCheckbox value="#{modeloBean.modelo.vigencia}" rendered="#{modeloBean.accion eq 'Modificar'}"/>
<p:commandButton value="#{modeloBean.accion}" actionListener="#{modeloBean.operar()}" oncomplete="PF('wdlgDatos').hide(); PF('wdtLista').clearFilters();" update=":frmLista:dtLista, :msj"/>
<p:commandButton value="Cancelar" immediate="true" onclick="PF('wdlgDatos').hide();"/>
</h:panelGrid>
</h:form>
</p:dialog>
selectOneMenu は保存では正常に機能しますが、更新では、コンボボックスの事前に選択された値ではなく、文字列の値のみを取得します

これは、「105」の文字列値のみを取得するダイアログです。原因は文字列であり、チェックボックス「Vigencia」のブール値ですが、comboBoxes 値ではありません。どこが間違っていますか?
