Unexpected behaviour p:dataTable (bug?)

UI Components for JSF
Post Reply
Posts: 10
Joined: 10 Jun 2010, 10:54

29 Jun 2010, 09:01


Consider following example:

Code: Select all

<h:outputLabel rendered="true" value="#{sayHelloController.name}"/>
This results in 1 call to the getName() method of the sayHelloController bean.

Code: Select all

<h:outputLabel rendered="false" value="#{sayHelloController.name}"/>
This results in no call.

Code: Select all

<p:dataTable rendered="false" var="row" value="#{sayHelloController.myList}"/>
Although the rendered attribute is set to false, it results in 5 (?) calls to the getMyList() method, while I except no call.

So my question is: is this expected behaviour that the value attribute gets evaluated even when the rendered attribute is set to false?
And is it normal that the call gets executed 5 times?



Koen Verhulst

Posts: 10
Joined: 10 Jun 2010, 10:54

29 Jun 2010, 09:04

update: I'm currently working with PrimeFaces 2.0.2

Posts: 18045
Joined: 05 Jan 2009, 00:21
Location: Cybertron

30 Jun 2010, 11:56

Yes, this is expected behavior in JSF, not related to PrimeFaces. p:dataTable extends from UIData and mysteriously UIData implementation in Mojarra does a call without checking rendered.

User avatar
Posts: 29
Joined: 05 May 2010, 16:07
Location: Bucaramanga, Colombia --> Clermont-Ferrand, France

01 Jul 2010, 10:47

Hi cagatay,

Well, let me say that after falling in love with all the great things I can do with primefaces and JSF now I'm worried for the same reason.

I have interfaces where I show a form on the top of the page, and the datatable in bottom. Each time that my users inserts they data with the top form, I save that on the DB, then the dataTable call the method that have the list of all the inserts of that day, made for that user or others. This method makes the list using Hibernate, and I see on my promt the call of the hql sentence so many times, 6 times when I have 2 data until 72 times the last time I saw my promt... :oops: :( The datatable allows also to delete a record from the list in the database.

I had seen in another forum that the gets show not make anything than return the value, but in this case, I need to update that list each time according to the lastest data in de database. What would be a solution to avoid that number of calls? 72 calls each time that my users save a record to show my dataTable when I call it just one in the page begins to worry. :cry:

That's my jsf with the top form (a selectOneMenu, inputText and CommandButton to save the record) and the bottom form with the datatable that show all the data saved.

Code: Select all

	<h:selectOneMenu required="true"  binding="#{bSlowMovingLog.cmbCodeMelange}" id="qualite" title="Code Melange" style="width: 150">
		<f:selectItems value="#{bSlowMoving.lstMelangeRebatche}" />
	<h:inputText id="quantite" size="8" binding="#{bSlowMovingLog.txtQuantite}" required="true">
		<f:convertNumber integerOnly="true" />
	<h:commandButton value="Enregistrer" action="#{bSlowMovingLog.saveDataRebatche}"/>
<p:dataTable id="todaySuspicious" value="#{bSlowMovingLog.entriesRebatche}" var="dataItem" width="75%" rows="30" paginator="true"
	paginatorTemplate="{PreviousPageLink}{PageLinks}{NextPageLink}{RowsPerPageDropdown}" rowsPerPageTemplate="30,60,90">
		<f:facet name="header"></f:facet>
		<h:inputHidden id="objet" value="#{dataItem}" binding="#{bSlowMovingLog.inputSlowMoving}" />
		<p:commandLink actionListener="#{bSlowMovingLog.dropDataSlowMoving}"	update="@form">
			<h:graphicImage url="/images/icon_delete.gif" style="border:0" />
	<p:column sortBy="#{dataItem.melange.matCode}" filterBy="#{dataItem.melange.matCode}">
		<f:facet name="header">
			<h:outputText value="Code Mélange" />
		<h:outputText value="#{dataItem.melange.matCode}" />
And here's my bean with the method to save, to delete and to query the list for the dataTable (the getter method called so many times)

Code: Select all

public class BSlowMovingLog {

	protected SlowMovingLog registre;
	private transient HtmlInputText 	txtQuantite 	= new HtmlInputText();
	private transient HtmlSelectOneMenu cmbCodeMelange 	= new HtmlSelectOneMenu();
	private transient HtmlInputHidden 	inputSlowMoving = new HtmlInputHidden();

//Method to save. There's no problem with it, called just once
	public void saveDataRebatche(){
		String melange = this.cmbCodeMelange.getValue().toString();
		int quantite = Integer.parseInt(this.txtQuantite.getValue().toString());
		registre = new SlowMovingLog(0, melange, quantite);

//Method to delete. No problem, called just once.
	public void dropDataSlowMoving(){
		registre = (SlowMovingLog) this.inputSlowMoving.getValue();

	public List<SlowMovingLog> getEntriesRebatche(){
		return SlowMovingLogHome.getEntriesByStock(1);
JSF 2.0. Primefaces 2.0.2. Apache Tomcat 6.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests