I have the following facelet:
<h:form id="submitForm">
<ui:include src="/inc.xhtml">
<ui:param name="bean" value="#{helloBean}" />
</ui:include>
<ui:include src="/inc.xhtml">
<ui:param name="bean" value="#{myBean}" />
</ui:include>
<h:commandButton />
</h:form>
Where inc.xhtml
:
<f:subview xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:inputText id="val" value="#{bean.p}" converter="conv"/>
</f:subview>
Reading this and this answers wasn't helpful because in my case there's the converter which I tried to write:
@FacesConverter("conv")
public class ProducerConveter implements Converter{
public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
UIInput c = (UIInput) arg0.getViewRoot().findComponent("submitForm:val") ;
Object val = c.getValue(); //NPE
//convertion itself involving the val Object
}
public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2){
return ((Producer) arg2).getProducer();
}
}
Later on, I've noticed that it's impossible for the implementation to decide which component I wanted to retrieve (from the first include or from the second one).
Is it even possible to get the component from the second include?
Update:
After some debugging, I figured out that the actual name of the component from the second include was submitForm:j_idt5:val
. Is there a way to specify the id explicitly for any inlclude instead of j_idt5
?