We do have a small page which is using the viewParam to convert a given Id to a concrete object. This converter is called on leaving (blur) of an inputText field, which is validated. Why? Could I rework this, so that the converter is not called every time?
This is annoying, because the converter calls the set-method for the corresponding object in the BackingBean and this bean is then null, if the page is called the first time for creating this object.
<f:metadata>
<f:viewParam name="id" value="#{bean.object}"
converter="#{objectConverter}"
converterMessage="#{msgs['converter.msg.object']}"/>
<f:viewAction action="#{bean.init}"/>
</f:metadata>
<p:inputText id="text" value="#{cc.attrs.value}"
styleClass="inputTextValidated"
required="#{cc.attrs.required}"
requiredMessage="#{cc.attrs.requiredmessage}"
label="text" validatorMessage="#{cc.attrs.msg}" title="#cc.attrs.title}"
readonly="#{cc.attrs.readOnly}">
<cc:insertChildren/>
<p:ajax update="msg_text" event="blur"/>
</p:inputText>
<p>
<p:message id="msg_text" for="text" display="msg"/>
</p>
If we do not use a converter but just the viewAction to convert the Id to the corresponding object (or create a new object if applicable), everything is fine. Is this the only/correct solution for this problem?
We do use primefaces 6.1 with CDI. The converter is a @Named and @ApplicationScoped bean implementing the Converter Interface.
Using p:fragment around the inputtext-field did not help either.