Omniface Selectitemsconverter does not reflect the values of the object on screens

Asked

Viewed 52 times

1

I’m using the component selectOneMenu with the conversion of omnifaces. When I save my object in the database works right, but when I restore the information, they do not reflect on the screen, ie the component selectOneMenu is positioned on the first item or the null item.

I’ve confirmed with a log and a inputText test and information is loaded correctly. I am using the selectItemsConverter (tried with the SelectItemsIndexConverter also) of Omnifaces 1.8.3 (tried version 1.10 too).

Automacaoemail.java

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

...

@ManyToOne(fetch = FetchType.EAGER)
private ModeloEmail modeloEmail;

...

@Override
public int hashCode() {
    int hash = 7;
    hash = 31 * hash + Objects.hashCode(this.id);
    return hash;
}

@Override
public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final AutomacaoEmail other = (AutomacaoEmail) obj;
    if (!Objects.equals(this.id, other.id)) {
        return false;
    }
    return true;
}

@Override
public String toString() {
    return String.format("%s[id=%d]", getClass().getSimpleName(), getId());
}

loadFromDatabaseMethod()

    List<ModeloEmail> modelosTemp = modeloEmailFacade.buscarTodos();
    SelectItemsBuilder selectItemsBuilder = new SelectItemsBuilder();
    if (modelosTemp != null) {
        for (ModeloEmail modeloEmail : modelosTemp) {
            selectItemsBuilder.add(modeloEmail, modeloEmail.getNome());
        }
        modelosEmails = selectItemsBuilder.buildList();
    }

page.xhtml

<p:selectOneMenu value="#{automacaoEmailsController.automacaoEmail.modeloEmail}" converter="omnifaces.SelectItemsConverter">
    <f:selectItem noSelectionOption="true" itemLabel="Selecionar um modelo"/>
    <f:selectItems value="#{automacaoEmailsController.modelosEmails}"/>
</p:selectOneMenu>
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.