0
votes

First, I show my code:

XHTML page:

<h:body>
    <h:form id="ffffffffff">
        <p:inputText value="#{prueba.dato}" >
            <p:ajax event="keyup" process="@this" />
        </p:inputText>
    </h:form>
</h:body>

Bean:

@ManagedBean
@ViewScoped
public class Prueba implements Serializable {

    private String dato = "ASSSS";

    public String getDato() {
       return dato;
    }

    public void setDato(String dato) {
        this.dato = dato;

        System.out.println("DAAAAAA: " + dato);
    }

    public void listener() {
        System.out.println("LISTENEEEEEEEEEEEEEEEEEEEEEEEEEE");
    }
}

Converter

@FacesConverter
public class SnaCarreraConverter extends SelectItemsConverter {
    //CODE
}

My problem, setDato is always getting a null value. But when I modify the converter to this:

@FacesConverter(forClass=SnaCarrera.class)

adding forClass resolve my problem, I don't know why this happens. Is The inputText trying to find a Converter without add the converter property?

1

1 Answers

1
votes

First of all, the SelectItemsConverter is for <f:selectItems>. The <p:inputText> is not a <f:selectItems>. So the SelectItemsConverter is useless for the <p:inputText>. See also its documentation and showcase.

Second, it's normal to give the Converter implementation an ID or a "for-class" in order to use it. Otherwise you can't refer it in the <x:inputSomething converter> attribute, or in the <f:converter> tag, or you can't auto-associate it with a certain class. This requirement is totally unrelated to the SelectItemsConverter. It's just required by standard JSF spec.