Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSF remove a component from the component-tree

843844Sep 18 2009 — edited Sep 18 2009
Hello,
i have the follow problem with JSF.
i try to manipulate the component tree of my JSF from a managed-bean action-method.
i can add succefuly an another component to this tree, but i can not remove a old component from this tree.
The System-Output show the right number of gridpanel chlid component before and after removing the a chid component. But i see no change in the Browser (the 3 colums of my panels are allready available).
This is the JSF code
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<f:view>
	<h:form id="form" binding="#{foo.form}">
		<h:panelGrid columns="3" binding="#{foo.panelGrid}" id="panel">
			<h:outputText value="Colum 1" id="t1"/>
			<h:outputText value="Colum 2" id="t2"/>
			<h:outputText value="Colum 3" id="t3"/>
		</h:panelGrid>
		<h:commandButton id="button" action="#{foo.doBinding}" value="Binding Example 2" />
	</h:form>
</f:view>
</body>
</html>
and this is the code of my managedbean
package test.bean;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlPanelGrid;

public class Foo 
{
	private HtmlPanelGrid panelGrid;
	private HtmlForm form;
	
	public HtmlPanelGrid getPanelGrid() {
		return panelGrid;
	}

	public void setPanelGrid(HtmlPanelGrid panelGrid) {
		this.panelGrid = panelGrid;
	}
	
	public HtmlForm getForm() {
		return form;
	}

	public void setForm(HtmlForm form) {
		this.form = form;
	}

	public String doBinding()
	{
		System.out.println(panelGrid.getChildCount());
  	      panelGrid.getChildren().remove(1);
              System.out.println(panelGrid.getChildCount());
		return "";
	}
}
can some body help me?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2009
Added on Sep 18 2009
13 comments
1,957 views