• Post Reply Bookmark Topic Watch Topic
  • New Topic

composite component inside a p:dataGrid doesn't set div id.  RSS feed

M Shipway
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to display a collection of data in a table using Primefaces' p:dataGrid.
My data may have between 2 and 16 columns, with each column being displayed (as a graph) in a cell of the dataGrid.
The graph implementation is irrelevant as it is created by JavaScript after the JSF view has finished rendering, and attached to a div by the div's id.
I've written a composite component which takes a single attribute "number".
The cc creates several h:panelGroup items and a p:slider item with "id" attributes based on the passed in "number".
If I call the cc with a hardcoded attribute, it works as I expected.
However, when the cc is called from with a p:dataGrid, the dynamic passed parameter is used for "value" but not for "id".
Here is a simplified tester version of my composite component:

It contains 2 h:panelGroup elements, each with a h:outputText to display the passed attributes.
The first is my original version where the "id" is constructed on the fly.
The second uses an "id" value which was passed in.

Here is the view code with calls the cc:

I am calling the cc "graph" twice to illustrate the 2 behaviors I mentioned above.
The "layoutList" is being iterated through correctly, so the value of "leadNumber" for the first element is zero.
Here is the HTML which is generated:

As you can see, the div id is generated correctly when a literal "5" is passed (ContainerDiv5).
But when the number is dynamically passed from the "layoutList" variable as "0", the id is wrong (ContainerDiv instead of ContainerDiv0)

Can anyone tell me why these two cases behave differently?
Is there any way to have the number from my variable used to construct the div id within my compound component?

Tim Holloway
Posts: 18715
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ID attribute cannot be expressed as an EL value. It must be absolute text.

On the JavaDocs for JSF elements, one of the columns in the attribute table defines whether an attribute may be an EL value expression or not.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!