autocomplete and datatable : behavior dependent on order !?

UI Components for JSF
Post Reply
emwe
Posts: 6
Joined: 25 Oct 2011, 17:47

26 Oct 2011, 00:06

I reduced the problem to following code, based on the PF 3 lab showcase for autocomplete:
(I put the converter-methods into the autoCompleteBean)

Code: Select all

<h:form>  

	<p:dataTable value="#{autoCompleteBean.players}" var="p" />
                    
	<p:autoComplete  value="#{autoCompleteBean.selectedPlayer1}" 
		forceSelection="true"
		completeMethod="#{autoCompleteBean.completePlayer}"
		converter="#{autoCompleteBean}"                                    
		var="player" itemLabel="#{player.name}" itemValue="#{player}"  />          

 </h:form> 
Now I log all method invocations while typing in the autocomplete field.
When typing "Xa" (for Xavi) i get:

Type "X":

> Bean - getPlayers
> Bean - getPlayers
> Bean - getPlayers
> Bean - complete X
> Bean - getPlayers
> Bean - getPlayers
> Bean - getPlayers
> Bean - getAsString Xavi

Type "a"

> Bean - getPlayers
> Bean - getPlayers
> Bean - getPlayers
> Bean - complete Xa
> Bean - getPlayers
> Bean - getPlayers
> Bean - getPlayers
> Bean - getAsString Xavi

After just changing the order of the components

Code: Select all

<h:form>  
                    
	<p:autoComplete  value="#{autoCompleteBean.selectedPlayer1}" 
		forceSelection="true"
		completeMethod="#{autoCompleteBean.completePlayer}"
		converter="#{autoCompleteBean}"                                    
		var="player" itemLabel="#{player.name}" itemValue="#{player}"  />          

	<p:dataTable value="#{autoCompleteBean.players}" var="p" />

 </h:form> 
the result is (as normally expected):

> Bean - complete X
> Bean - getAsString Xavi
> Bean - complete Xa
> Bean - getAsString Xavi

Apparently the table gets updated some way, when it's before the autocomplete.
Is there any explanation for that? My "real world" problem is much more complex (using the autocomplete component in column-footers) and there i get a mass of these method invocations.

Thanks for help!

porthos
Posts: 122
Joined: 09 May 2011, 03:17

12 Apr 2012, 03:06

You didn't state whether you're using MyFaces or Mojarra. You may get different behaviours depending on which you're using.
-------
PrimeFaces 3.4, Glassfish 3.1.2, Mojarra 2.1.6

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 35 guests