I have a list of autocompletes that is rendered using a p:dataList
. Something like shown below:
<h:panelGroup layout="block" id="outerPanel"> <p:dataList rendered="#{bean.myModel.listOfItems.size()>0}" var="additionalMP" value="#{bean.myModel.listOfItems}" rowIndexVar="index" emptyMessage=""> <div class="wrapper ui-g"> <div> <p:autoComplete cache="true" value="#{bean.myModel.listOfItems[index]}" completeMethod ="#{handler.getAutoCompleteData}" rendered ="true" required="false" scrollHeight="200" styleClass="custom" forceSelection="true"> <p:ajax event="query" global="false"/> <f:attribute name="filter" value="filterName" /> <f:attribute name="mode" value="edit" /> </p:autoComplete> </div> <div> <p:commandLink value="+ Add" actionListener="#{bean.addAutoComplete()}" update=":formName:outerPanel"></p:commandLink> </div> </div> </p:dataList> </h:panelGroup>
So, the Add
button inserts a new item in the list and I update the container panel so that the newly added item can be rendered on the UI.
As expected the panel is updated and I see another autocomplete on the UI. But the problem is, all the auto completes now don't work. i.e. they stop firing the query event and don't give any suggestions.
Edited: The partial response that updates the section of form with autocomplete fields, contains some script tags, which probably execute on page ready/load event. So I know that basically the newly added prime faces widgets are not being initialized.
Any idea how I can initialize the newly added autocompletes in the DOM?
0 comments:
Post a Comment