All pastes #344014 Raw Edit

Stuff

public text v1 · immutable
·published 2007-02-07 13:29 UTC
rendered paste body
   <h:form id="form1">            
                <h:panelGrid id="pg" columns="2">
                    <h:outputText id="testValue2" value="Value:"/>
                    <h:inputText id="testValue" value="#{test.test}">
                        <f:validateLength minimum="4"/>
                    </h:inputText>
                </h:panelGrid>
                <h:commandButton value="Test" action="#{test.performTest}"/>
   </h:form>            
   <h:messages/>

Action method 

FacesContext ctx = FacesContext.getCurrentInstance();
UIViewRoot viewRoot = ctx.getViewRoot();
removeComponent(viewRoot.getChildren());

Remove method

private void removeComponent(List childrens) {
       Iterator it = childrens.iterator();
        while(it.hasNext()) {
            UIComponent comp = (UIComponent) it.next();            
            
            if ("testValue".equals(comp.getId())) {
                System.out.println("Test Test Test");
                childrens.remove(comp);   
                comp.setParent(null); 
                
                return;
            }
            if (comp.getChildren().size() != 0) {
                removeComponent(comp.getChildren());
            }
        } 
    }