aspose file tools*
The moose likes JSF and the fly likes composite component inside a p:dataGrid doesn't set div id. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "composite component inside a p:dataGrid doesn Watch "composite component inside a p:dataGrid doesn New topic
Author

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

M Shipway
Greenhorn

Joined: Nov 12, 2013
Posts: 1
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
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: composite component inside a p:dataGrid doesn't set div id.