Xavier Portebois
Xavier Portebois

Reputation: 3504

Primefaces autocomplete inside a custom composite component, behaving as without any suggested result

We use a lot of modals in a JSF project, so we made a simple custom component to embed the needed HTML code. Nothing complicated, just a wrapper without any logic:

<cc:interface>
    <cc:attribute name="modalId" type="java.lang.String" required="true" />
    <cc:attribute name="styleClass" type="java.lang.String" />
    ...
</cc:interface>
<cc:implementation>
    <div id="#{cc.attrs.modalId}" class="modal fade">
        <div class="modal-dialog modal-lg modal-dialog-centered #{cc.attrs.styleClass}">
        ...
        <cc:insertChildren />
        ...
        </div>
    </div>
</div>

In one of this modal, we use a primefaces autocomplete component:

<my:modal modalId="myModal">
    ...
    <p:autoComplete value="#{myBean.myValue}" multiple="true" completeMethod="#{myBean.myMethod}"  
        converter="#{myBean.myConverter}" forceSelection="true" unique="true" appendTo="@this" emptyMessage="no result"
        var="example" itemLabel="#{example.name}" itemValue="#{example}" />
    ...
</my:modal>

In this state, the dropdown displaying the results behaves as if there were no result at all (the component emptyMessage is shown). Of course, I checked the completeMethod, and it is returning results.

If I move the p:autocomplete outside the my:modal component, or if I replace the modal component by its pure HTML counterpart, everything works fine. So I guess our my:modal component is the cause of the fuss.

We're on a JSF 2 and Primefaces 11 project. A lot of other primefaces components (tree, selectBooleanCheckbox, fileUpload, dataTable, ...) are used without any issue in our modals.

What am I missing here?

Upvotes: 1

Views: 157

Answers (0)

Related Questions