I am using a PrimeFaces autoComplete box in my code. I have used this components in various places in my application with no problem. When I have it in a block of code that is dynamically included via ui:include, I get:
14:32:30,115 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (http-steves-10.11.100.136-15081-2) java.lang.NullPointerException
If I take the exact code copy and paste it into the parent right before the ui:include, it works there. So obviously the problem has something to do with it being in the ui:include. Is there a problem with ajax controls in an include? What would I need to work around this?
My environment is PF3.4RC1, JBoss7.1, Mojarra 2.1.5
Update: Here is the code I am using. I haven't bothered including the backing beans because I put breakpoints in that code and it only is touched when I use the "working" autocomplete. As an additional piece of information, I tries putting a commandbutton on the fragment and it too fails to call the actionlistener method on the backing bean.
Main (Parent) page:
<p:panel id="dataEntryPane"
rendered="#{manageItemHandler.currItem ne null}">
<!-- This Auto Complete works -->
<p:autoComplete
completeMethod="#{itemAutoComplete.autoCompleteList}" var="item"
itemLabel="#{item.itemNum}" itemValue="#{item}"
converter="ItemConverter" queryDelay="750">
<f:facet name="itemtip">
<p:panelGrid columns="2" cellpadding="5" style=" width:400px;">
<f:facet name="header">
<p:column colspan="2">
<h:outputText value="Item Information"
style="font-weight:bold; font-size:20px; font-style:italic;" />
</p:column>
</f:facet>
<p:row>
<h:outputText value="#{item.itemNum}" />
</p:row>
<p:row>
<h:outputText value="#{item.itemDesc}" />
</p:row>
</p:panelGrid>
</f:facet>
</p:autoComplete>
<ui:include src="#{manageItemHandler.dataEntryFrag}" />
</p:panel>
Included Fragment:
<p:panel>
<f:facet name="header">
<h:outputText value="Operation - #{manageItemHandler.dataEntryOp.operationNum} BOM Entry" />
<p:commandButton value="SignOff"
actionListener="#{manageItemHandler.doSignOff(manageItemHandler.dataEntryOp.bom)}"
style="float:right"
rendered="#{speed2Session.isRendered('editManageItemOp')}" />
</f:facet>
<!-- This autocomplete does not work -->
<p:autoComplete completeMethod="#{itemAutoComplete.autoCompleteList}"
var="item" itemLabel="#{item.itemNum}" itemValue="#{item}"
converter="ItemConverter" queryDelay="750">
<f:facet name="itemtip">
<p:panelGrid columns="2" cellpadding="5" style=" width:400px;">
<f:facet name="header">
<p:column colspan="2">
<h:outputText value="Item Information" style="font-weight:bold; font-size:20px; font-style:italic;" />
</p:column>
</f:facet>
<p:row>
<h:outputText value="#{item.itemNum}" />
</p:row>
<p:row>
<h:outputText value="#{item.itemDesc}" />
</p:row>
</p:panelGrid>
</f:facet>
</p:autoComplete>
<p:dataTable id="dt_bom" value="#{manageItemHandler.dataEntryOp.bom}"
var="bom">
<p:column headerText="Item Number">
<p:inputText value="#{bom.component}"
disabled="#{speed2Session.isDisabled('editManageItemOp')}" />
</p:column>
<p:column headerText="Item Description">
<h:outputText value="#{bom.descrip}" />
</p:column>
<p:column headerText="QTY">
<p:inputText value="#{bom.qty}"
disabled="#{speed2Session.isDisabled('editManageItemOp')}"></p:inputText>
</p:column>
</p:dataTable>
<p:commandButton value="test button"></p:commandButton>
</p:panel>
Unfortunately, the above error is all that I get in the stack trace. Here are a few preceeding lines for completeness. I Typed into the autocomplete box twice in the trace and you can see by the time what was logged when I did.
15:58:11,578 INFO [stdout] (http-steves-10.11.100.136-15081-6) Hibernate:
15:58:11,578 INFO [stdout] (http-steves-10.11.100.136-15081-6) select
15:58:11,579 INFO [stdout] (http-steves-10.11.100.136-15081-6) itemdata0_.DESCRIP as col_0_0_
15:58:11,579 INFO [stdout] (http-steves-10.11.100.136-15081-6) from
15:58:11,580 INFO [stdout] (http-steves-10.11.100.136-15081-6) MCSITEM itemdata0_
15:58:11,580 INFO [stdout] (http-steves-10.11.100.136-15081-6) where
15:58:11,581 INFO [stdout] (http-steves-10.11.100.136-15081-6) itemdata0_.ITEM=?
15:58:16,538 INFO [com.newpig] (http-steves-10.11.100.136-15081-6) In AutoLoginFilter.doFilter
15:58:16,541 INFO [com.newpig] (http-steves-10.11.100.136-15081-6) In SecurityFilter.doFilter
15:58:16,542 INFO [com.newpig] (http-steves-10.11.100.136-15081-6) OriginalURL: /speed2/modules/main.faces
15:58:16,575 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (http-steves-10.11.100.136-15081-6) java.lang.NullPointerException
16:02:43,442 INFO [com.newpig] (http-steves-10.11.100.136-15081-6) In AutoLoginFilter.doFilter
16:02:43,445 INFO [com.newpig] (http-steves-10.11.100.136-15081-6) In SecurityFilter.doFilter
16:02:43,446 INFO [com.newpig] (http-steves-10.11.100.136-15081-6) OriginalURL: /speed2/modules/main.faces
16:02:43,475 SEVERE [javax.enterprise.resource.webcontainer.jsf.context] (http-steves-10.11.100.136-15081-6) java.lang.NullPointerException
UPDATE 2: My intention is to dynamically swap out a section of the screen as the user clicks buttons. As a test, I defaulted to the fragment in question (SpecSheet) when the backing bean is created. When I do that, the Autocomplete works for that fragment. When I switch to another fragment(BOM) with an autocomplete, that one doesn't work. If I switch back to SpecSheet, that autocomplete still works.