Gerald/...,

I have a recursive method for walking through a checkbox tree at once. The method is called by a command(-Button) under the tree. (Reason is I don't want a servertrip at every "check" but wish to process all checked nodes at once) The algoritm I use is: (selectedNodesIDs is an array of Strings for the SELECTED Node IDs) It walks recursively through the tree and adds selected nodes to this dedicated array.

public void handleLeafs(TreeNodeBase node){
                if(selectedNodesIDs == null)selectedNodesIDs= new 
ArrayList<String>();
                // simple case first: if node is Leaf, we check whether it is 
checked:
                logger.info("Handling of the selected Nodes starts now...");
                if(node.isLeaf()){
                        logger.info("Node is a Leaf");
                        if(((TreeNodeChecked)node).isChecked()){
                                getSelectedNodesIDs().add(node.getIdentifier());
logger.info("Node with this ID was gecheckt: "+ node.getIdentifier ());
                        }
                }
// normal case: if node has kids --> we recursively get to the Leafs to check them out:
                else if(node.getChildCount() >0){
                        logger.info("Node has kids which we will start treating 
now...");
                        List<TreeNodeBase> childs = 
(List<TreeNodeBase>)node.getChildren();
                         for (TreeNodeBase nodeSub : childs) {
                                 if(nodeSub.isLeaf()){
                                         logger.info("Node is Leaf - is it 
checked?");
                                         // it is a leaf now, --> it is a 
TreeNodeCheked
                                         
if(((TreeNodeChecked)nodeSub).isChecked()){
                                                 
getSelectedNodesIDs().add(nodeSub.getIdentifier());
logger.info("Node met deze ID was gecheckt: "+ node.getIdentifier());
                                         } else {logger.info("Node was not 
checked");}
                                                        }
                                 else {handleLeafs(nodeSub);}
                                 }
                         }
                else {logger.info("Node at this level has no kids... ");}
                                
                }


The tree2 is defined like this:
<t:tree2 id="clientTree" value="#{calmgmtbean.treeRootNode}" var="node" varNodeToggler="t" clientSideToggle="true"
                                                                        
preserveToggle="false" >
                                                
                                                        <f:facet name="root">
                                                                <h:panelGroup>
<h:outputLabel value="#{labels.calMgmt_tree_rootTxt}" styleClass="inhoudKolom2"/>
                                                                </h:panelGroup>
                                                        </f:facet>
                                
                                                        <f:facet 
name="calendarSet">
                                                                <h:panelGroup>
<t:graphicImage value="../pics/calMgmt/blue-folder-open.gif" border="0" rendered="#{t.nodeExpanded}"/> <t:graphicImage value="../pics/calMgmt/blue-folder- closed.png" border="0" rendered="#{!t.nodeExpanded}"/> <h:outputLabel value="#{labels.calMgmt_tree_calSetTxt} : # {node.description}" styleClass="inhoudKolom2"/> <h:outputText value=" (#{node.childCount})" styleClass="childCount" rendered="#{!empty node.children}"/>
                                                                </h:panelGroup>
                                                         </f:facet>             
          
                                                
                                                        <f:facet name="trigger">
                                                        <h:panelGroup>
                                                <h:selectBooleanCheckbox 
value="#{node.checked}" />
<h:outputText value=" #{node.description} " style="font-size:12px;font-style:italic;color:darkgrey;font- family:verdana;"/>
                                                                </h:panelGroup>
                                                </f:facet>
                                                
                                                </t:tree2>


Yet, the checked values are not retained. The method's log output always writes "Node was not checked"...
Any idea on how to remedy this?
"Funny" thing is: used to work in the past, but apparently broke with one of the upgrades. (Tomahawk) & I moved to T115 to avoid problems with other components...

Wolf


On 11 Aug 2006, at 13:33, Gerald Müllan wrote:

The boolean checkbox is set according to the value binding.

In your case is this the expression value="#{node.checked}", but you
don`t influence the checked variable in your code.

You only need to get the new value out of the event:

event.getNewValue()

and set the checked variable to it.

cheers,

Gerald

On 8/10/06, Johnny Gonzalez <[EMAIL PROTECTED]> wrote:
Hello Gerald,

Sorry for taking to long to answer,...
the part of the JSP I have is this:

<t:tree2 id="serverTree" value="#{EntradasBean.modeloArbol}" var="node"
varNodeToggler="t" clientSideToggle="true">


                        <f:facet name="opcion">
                             <h:panelGroup>
                                 <h:selectBooleanCheckbox
title="#{node.description}" value="#{node.checked}"
valueChangeListener="#{EntradasBean.checkBoxSelected}"
onchange="this.form.submit()" immediate="true"/>
<h:outputText value="# {node.description}"
style="FONT: xx-small Verdana, Arial, Helvetica, sans-serif;"
styleClass="nodeFolder"/>
                             </h:panelGroup>
                        </f:facet>


                        <f:facet name="menu">
                            <h:panelGroup>
                                 <h:selectBooleanCheckbox
title="#{node.description}" value="true"
valueChangeListener="#{EntradasBean.checkBoxSelected}"
onchange="this.form.submit()" immediate="true"/>
                                 <h:outputText value="*"
rendered="#{t.nodeSelected}" />
<h:outputText value="# {node.description}" styleClass="nodeFolder" style="FONT: xx-small Verdana, Arial, Helvetica,
sans-serif;" />
                            </h:panelGroup>
                        </f:facet>

                        <f:facet name="raiz">
                            <h:panelGroup>
                                <h:selectBooleanCheckbox
title="#{node.description}" value="true"
valueChangeListener="#{EntradasBean.checkBoxSelected}"
onchange="this.form.submit()" immediate="true"/>
<h:outputText value="# {node.description}" styleClass="nodeFolder" style="FONT: xx-small Verdana, Arial, Helvetica,
sans-serif;" />
                            </h:panelGroup>
                        </f:facet>

                        </t:tree2>


and in the backing bean I have:

this is the valueChangeEvent method:

 public void checkBoxSelected(ValueChangeEvent event){
          FacesContext contexto = FacesContext.getCurrentInstance();

          // Obtengo la sesion en que estamos
          HttpSession sesion = ( HttpSession )
contexto.getExternalContext().getSession( false );

          // Objeto para manejar el radio button
HtmlSelectBooleanCheckbox select = ( HtmlSelectBooleanCheckbox )
event.getComponent();

          String valor = new String();
          if(select.getValue().equals(true)){
              valor = ( String ) select.getTitle();
              System.out.println("ValueChange: "+valor);
              this.checkBoxSelected.add(valor);
          }
          select.setValue(new Boolean(true));

          for(String s: this.checkBoxSelected){
              System.out.println(this.checkBoxSelected.size());
              System.out.println(s);
          }

    }

What do you think about it?

thanks a lot,
Johnny






Gerald Müllan <[EMAIL PROTECTED]> escribió:
 Hi,

have you set the value attribute of the h:selectBooleanCheckbox component?

What do you do in the backend method?

Would be helpful if you could support with some code fragments.

cheers,

Gerald

On 8/9/06, Johnny Gonzalez wrote:
> Hello everybody,
>
> I have built a tree with selectBooleanCheckbox, I wrote a valuechange
event
> to store if every of the h:selectBooleanCheckbox, were selected, but after
> the method is executed the page is repainted and the
h:selectBooleanCheckbox
> that I selected appears unchecked, why this strange behaviour?
>
> TIA,
>
> Johnny
>
>
> ________________________________
>
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com
>
>


--
Gerald Müllan
Schelleingasse 2/11
1040 Vienna, Austria
0043 699 11772506
[EMAIL PROTECTED]




 ________________________________

LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com




--
Gerald Müllan
Schelleingasse 2/11
1040 Vienna, Austria
0043 699 11772506
[EMAIL PROTECTED]

Reply via email to