10 Replies Latest reply on Aug 10, 2009 12:29 AM by Matt Kohanek

    need for no node to be selected when new page is laoded on r

    Matt Kohanek Novice

      When I change my page each has a different rich:tree, and every time one of the nodes has a blue rectangle around it as if it has been clicked on.

      Isn't there an attribute you can set to "false" or something like that so that none of the nodes are active or selected, they are just there waiting for someone to click on them first.

      In other words i want that blue-ish rectangle to not be automatically shown on one of the nodes when I change from one tree to another. (It messes up some of my variable settings)

        • 1. Re: need for no node to be selected when new page is laoded
          Matt Kohanek Novice

          Maybe I should make it more clear.

          I have a tree on the left side of my page that always stays the same, used to display projects, devices and channels. When you click on a project it takes you to a screen with two tabs.

          The first tab is a list of the devices for that project and the second tab is a list of channels for that project. Each tab has a tree, the device tab just has a tree with a list of devices, and the channel tab a tree with a list of channels.

          It just looks like a list though, since there are no child nodes, they are all leaf nodes so it just looks like a list. When you click on one of these devices or channels it reRenders some output text fields for that tab. But there is a problem sometimes. If there is only one channel or device on a tab, and you click on the one device or channel, it does reRender the output fields just fine. But then if you go from one tab and back to the first tab, that device or channel will still have a blue rectangle as if it were still selected, but the outputText fields have not been reRendered. Plus, if you try to click on it so i does reRender the fields nothing happens. The method to reRender the fields is not being called, Im guessing because it already thinks this node is selected so there is no need to reRender anything.

          This isn't a problem when there is more than one device, you can just click from device to device to reRender the fields. But if there is only the one device, it will act as if it has already been clicked but you will not be able to do anything.

          • 2. Re: need for no node to be selected when new page is laoded
            Matt Kohanek Novice

            Here is the code for the two tabs by the way. Im sure all I need to do is change some attribute in both of the rich:trees I have. But I have been trying and cant figure out which or what to do.

            <rich:tab label="DEVICES">
             <h:form id="deviceForm">
            
             <h4>Click on a Device Below To Edit It</h4>
             <br/>
             <rich:tree nodeSelectListener="#{updateAllBean.deviceClick}" ajaxSubmitSelection="true" switchType="client"
             ajaxKeys="#{null}" reRender="deviceId, deviceName, deviceLat, deviceLng" showConnectingLines="false">
             <rich:treeNodesAdaptor nodes="#{updateAllBean.deviceList}" var="device">
             <rich:treeNode>
             <h:outputText value="#{device.name}" />
             </rich:treeNode>
             </rich:treeNodesAdaptor>
             </rich:tree>
            
             <br/>
            
             <h:outputText id="deviceId" value="DeviceID: #{updateAllBean.deviceId}" />
             <br/>
             <h:outputText value="Device Name:" />
             <h:inputText id="deviceName" value="#{updateAllBean.deviceName}" size="27" />
             <br/>
             <h:outputText value="Device Latitude: " />
             <h:inputText id="deviceLat" value="#{updateAllBean.deviceLat}" size="27"/>
             <br/>
             <h:outputText value="Device Longitude: " />
             <h:inputText id="deviceLng" value="#{updateAllBean.deviceLng}" size="27"/>
             <br/><br/>
             <h:commandButton type="submit" value="SUBMIT DEVICE CHANGES"
             action="#{updateAllBean.updateDevice}" />
            
             <br/><br/><br/>
             <h:outputLink value="/NI/add_entity/new_device.jsf">Click here to add a device to the project</h:outputLink>
             </h:form>
             </rich:tab>
            
             <rich:tab label="CHANNELS">
             <h:form id="channelForm">
             <h4>Click on a Channel Below To Edit It</h4>
             <br/>
             <rich:tree nodeSelectListener="#{updateAllBean.channelClick}" ajaxSubmitSelection="true" switchType="client"
             ajaxKeys="#{null}" reRender="channelId, channelName" showConnectingLines="false">
             <rich:treeNodesAdaptor nodes="#{updateAllBean.channelList}" var="channel">
             <rich:treeNode>
             <h:outputText value="#{channel.name}" />
             </rich:treeNode>
             </rich:treeNodesAdaptor>
             </rich:tree>
            
             <br/>
            
             <h:outputText id="channelId" value="ChannelID: #{updateAllBean.channelId}" />
             <br/>
             <h:outputText value="Channel Name:" />
             <h:inputText id="channelName" value="#{updateAllBean.channelName}" size="27" />
             <br/><br/>
             <h:commandButton type="submit" value="SUBMIT CHANNEL CHANGES"
             action="#{updateAllBean.updateChannel}" />
            
             <br/><br/><br/>
             <h:outputLink value="/NI/add_entity/new_channel.jsf">Click here to add a channel to the project</h:outputLink>
             </h:form>
             </rich:tab>


            • 3. Re: need for no node to be selected when new page is laoded
              Ilya Shaikovsky Master

              seems the bean updateAllBean is request scoped. So it leaves for a single request only. And the tree component saves it's state between requests. So thats could be the reason that node is selected and the outputText contains default value.

              • 4. Re: need for no node to be selected when new page is laoded
                Matt Kohanek Novice

                It is actually a session scope.

                <managed-bean>
                <managed-bean-name>updateAllBean</managed-bean-name>
                <managed-bean-class>actionBean.UpdateAll</managed-bean-class>
                <managed-bean-scope>session</managed-bean-scope>
                </managed-bean>

                Should it be something else?

                • 5. Re: need for no node to be selected when new page is laoded
                  Matt Kohanek Novice

                  And also, the outputText does not contain the default value, the outputtext is blank, even though it looks like the node is already selected.

                  If the outputText were to stay filled in there would be no need to select a node because it would already be filled out.

                  My problem is, sometimes I go to the channel or device tab, and there is only one node. The problem is, that node is already selected, as in it has a blue rectangle around it, and the outputText fields are blank. If there are multiple nodes, I can go back and forth between them to populate the outputText, but if there is only one node, clicking on it does nothing. It will not populate the outputText.

                  • 6. Re: need for no node to be selected when new page is laoded
                    Nick Belaevski Master

                     

                    "ilya_shaikovsky" wrote:
                    use tree state advisors in order to select/deselect/expand/collapse nodes between requests


                    • 7. Re: need for no node to be selected when new page is laoded
                      Matt Kohanek Novice

                      I will look at that. That quote isnt from this thread though is it? I never saw her post that at least.
                      Im sure you got it from some documentation somewhere or something

                      • 8. Re: need for no node to be selected when new page is laoded
                        Nick Belaevski Master

                        Yes, that's from another thread.

                        • 9. Re: need for no node to be selected when new page is laoded
                          Matt Kohanek Novice

                          before I start to research that now, can someone just verify that is actually what I need, because I dont think I have made it very clear.

                          I have a page that has a rich:tree, and a rich:tabPanel with two tabs. Each tab has another rich:tree, that gets populated and reRendered when you click on the main tree outside the tabs. Then clicking on one of the nodes in these secondary trees reRenders some outputText fields which a user can then edit.

                          The first time you click on a node from the main tree, it renders the two secondary trees just fine. You can then click on a node from the secondary tree and that renders the outputText fields just fine.

                          The problem occurs when you click on subsequent nodes from the main outer tree. It will reRender the two secondary trees, but every time the secondary trees are reRendered, one of their nodes is already selected, yet there is nothing in the oututText fields. If you click on a different node in these secondary trees it will then reRender the outputText fields so thats OK, but there is a problem if these secondary trees only have one node.

                          When that happens, the secondary tree's only node is already selected, and clicking on it again does not reRender the outputText fields.

                          Isn't there a simple attribute I can set to false or something like that, that will make sure none of the secondary tree nodes are selected when the tree gets reRendered?

                          I tried to use adviseNodeSelected="false" but that would give me errors when I tried to click on a node from the main tree; the secondary trees were never even rendered when I used that attribute.

                          • 10. Re: need for no node to be selected when new page is laoded
                            Matt Kohanek Novice

                            nevermind, I got it, stateAdvisor was what I needed, you were right. I couldnt get it to work this whole time because I forgot to create a managed bean in my faces-config.xml...

                            Thanks again for your help as always nbelaevski