Meaningless Drivel is fun!*
The moose likes JSF and the fly likes Bound PanelGrid removing dynamically added components Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Bound PanelGrid removing dynamically added components" Watch "Bound PanelGrid removing dynamically added components" New topic
Author

Bound PanelGrid removing dynamically added components

Mark Rausch
Greenhorn

Joined: Apr 10, 2003
Posts: 4
Hello,

I have a bound panelGrid as follows:
<h anelGrid binding="#{MyBean.somePanelGrid}" />

In getSomePanelGrid I create the grid and dynamically add some components to the grid as so:

...
somePanelGrid = new HtmlPanelGrid();

somePanelGrid.setId(FacesContext. getCurrentInstance().getViewRoot().createUniqueId());
somePanelGrid.setStyleClass("someStyleClass");
somePanelGrid.setRowClasses("evenRow, oddRow");
...

UIInput in = new UIInput();
in.setId("test");
in.setValue(f.getValue());
in.setRequired(true);
in.setParent(somePanelGrid);
in.setRendered(true);
somePanelGrid.getChildren().add(in);

The root view build as expected and the page displays perfectly on the initial request. If I force process validation to fail by submitting an empty string value for the inputText which is defined as required then I see the following. By implement PhaseListener and examining the tree in the beforePhase where phase is render response I see that the HtmlPanelGrid is there with all of the childeren that were added to it. Examining the tree again in the afterPhase I see that all of the childeren are null.

Any ideas would be appreciated.
Mark Rausch
Greenhorn

Joined: Apr 10, 2003
Posts: 4
I should also mention that I am using facelets and myfaces 1.1.0. When I run this without the facelets, everything works as expected.
Mark Rausch
Greenhorn

Joined: Apr 10, 2003
Posts: 4
Fixed!

Changed from release version of facelets.jar to version 1.0.2 and the problem went away.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bound PanelGrid removing dynamically added components
 
Similar Threads
dynamic panel grid binding
h:panelGrid with Attribute value
How to add new text boxes and check boxes dynamically when clicking on button in JSF
setAction Problem HtmlCommandButton
building a dataTable from java code