0

first excuse my english if it's not correct ...

I've a probleme with a primeface's component, I'm trying to refresh a p:selectOneMenu from a p:commandButton, but it's doesn't work (it 's work on another xhtml page, but not here and I can't understand why ...)

First I select an item from an p:autocomplete which update a backingbean's attribute ( for example : userChoose ).

then the p:commandButton is able to call his listener and add userChoose to a list, but i can't refresh the selectOneMenu that display the list. I have to use another p:commandButton to refresh the list.

My form is included into a p:tabMenu in another xhtml page.

<p:autoComplete id="acPojo" value="#{forumBean.user}" 
             completeMethod="#{autoCompleteBean.completeUser}" 
             converter="#{userConverter}" forceSelection="true"
             var="usr" itemLabel="#{usr.loginUtilisateur}" itemValue="#{usr}">  

     <p:column>  
        <h:outputText value="#{usr.loginUtilisateur}"/>
     </p:column>                
</p:autoComplete>       

 <p:commandButton value="ajouter" process="acPojo @this " 
    udpate=":tabView:formSujet:listeUser" actionListener="#{forumBean.addUser}"/>

 <p:selectOneMenu value="#{forumBean.user}" converter="#{userConverter}" var="us" id="listeUser" 
                  itemValue="#{us}" itemLabel="#{us.loginUtilisateur}">

       <f:selectItems value="#{forumBean.newSujet.listeUserAllowed}" var="User"
            itemValue="#{User}" itemLabel="#{User.loginUtilisateur}" />

       <p:column>
          <h:outputText value="#{us.loginUtilisateur}"/>
       </p:column>  

       <p:ajax process="@this" />

 </p:selectOneMenu>

 <p:commandButton id="refreshAdmin" icon="ui-icon-arrowrefresh-1-w" 
    update=":tabView:formSujet:listeUser" />

Thanks for help.

Aritz
  • 30,971
  • 16
  • 136
  • 217
kaizokun
  • 3
  • 2

1 Answers1

0

From your code:

udpate=":tabView:formSujet:listeUser" 

This has at least 2 (potential) mistakes. The right attribute name is update, not udpate. The one on your other button has however the right attribute name.

It that still doesn't work, then the other potential mistake is that the client ID tabView:formSujet:listeUser does not exist in HTML DOM tree (and thus JavaScript/jQuery is unable to find and replace it). That can happen if the <p:tabView> is dynamic (i.e. you're using <p:tabView value="#{bean.tabs}" var="tab">, because it prepents the tab index number in the final client ID like so tabView:0:formSujet:listeUser if it's the 1st tab.

But, after all, as both the dropdownlist and the commandbutton are in the same NamingContainer parent, you don't need an absolute client ID at all. Just the relative client ID should suffice:

update="listeUser" 

Fix that on your both buttons.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555