0

I am using primefaces autocomplete in my application to suggest userIds to the User.Once user enters three characters into the Autocomplete textbox my UserIds list will be suggested to the user to Autocomplete. As soon as user selects userId from List, I am updating the User First and Last name in the Output Text in the following format John Doe(jd123) with a Delete button beside to this name. As shown in comments in the code first ajax request is perfectly working fine.But When I am trying to delete name that I am printing using <h:outputText/> I am getting an error which is

javax.faces.FacesException: Cannot find component with identifier "items" referenced from "j_idt34:0:imgid".

My Code :

<h:outputLabel value="Select user" for="acMinLength" />
<p:autoComplete id="acMinLength" 
                minQueryLength="3" 
                value="#{autoCompleteBean.txt2}" 
                completeMethod="#{autoCompleteBean.complete}">
    <p:ajax event="itemSelect" 
            listener="#{autoCompleteBean.handleSelect}" 
            update="items"/>    // First Ajax request perfectly working fine
</p:autoComplete>

<h:outputLabel value="selectedUsers" for="acMinLength" />
<h:panelGroup id="items">
    <ui:repeat value="#{autoCompleteBean.printId}" var="item">
        <h:outputText value="#{item}"/>
        <h:graphicImage name="delete.png" library="images" id="imgid">
        <p:ajax event="click"
                listener="#{autoCompleteBean.updateList}" 
                update="items"/>  // This is where i am getting exception 
   </ui:repeat>
<h:panelGroup>

I know I can update the parent component with child Ajax request. But I don't know what I am doing wrong.

SRy
  • 2,901
  • 8
  • 36
  • 57

2 Answers2

0

it should be safer to update the h:form component. I'm not sure you can update every h: component by id. If you open the resulting xhtml and try checking the actual id path of the children components, you will see that the don't include the ids of all of their parent's component. Some id's are skipped

However, you can try this

update=":#{p:component('items')}"

Hope it helps

yannicuLar
  • 3,083
  • 3
  • 32
  • 50
  • Ultimately the above expression rendered as `:items` with which I have already tried but no luck.Yes I can update the form but it messes up my design. As you seen my code above it's able to find the when I am updating from `outside that component` but not through it's child component – SRy Oct 16 '13 at 14:06
0

After a rigorous search I tried the answer posted by andre here(Primefaces - Cannot find component with identifier outside the datatable) and hurray it's working.

like this

update="@([id$=items])"
Community
  • 1
  • 1
SRy
  • 2,901
  • 8
  • 36
  • 57