1 2 Previous Next 27 Replies Latest reply on Jul 21, 2009 6:11 AM by meghiddo Go to original post
      • 15. Re: Can you make List<String, List<String>> work with rich:t

        hmm, I really have no idea how to do something like that unfortunately.
        So you would say that is my only option though?

        • 16. Re: Can you make List<String, List<String>> work with rich:t
          nbelaevski

          Just create new class that will store your data and put your map there.

          • 17. Re: Can you make List<String, List<String>> work with rich:t

            SO I would make a new class that uses the deviceID as the key, and then populates the List of channels in that fashion.

            But then how would I bind that to the rich:tree correctly? I wish I could get a grasp on what your telling me here, I have till friday or all these months of project will be scrapped.

            The way I see it, I would keep the class that has project name and the list of devioces, and then just use the rich:tree like this to display that:

            <rich:tree>
             <rich:treeNodesAdaptor nodes="#{nodesBean.projects}" var="project">
             <rich:treeNode>
             <h:outputText value="#{project.projectName}" />
             </rich:treeNode>
             <rich:recursiveTreeNodesAdaptor roots="#{project.devicesList}" var="device">
             <rich:treeNode>
             <h:outputText value="#{device}" />
             </rich:treeNode>
            
             </rich:recursiveTreeNodesAdaptor>
             </rich:recursiveTreeNodesAdaptor>
             </rich:treeNodesAdaptor>
             </rich:tree>



            I mean that is simple enough and that does work as it is right now. But then when I make a class to hold the channels, how will I be able to tell the tree which device to put the lst of channels underneath? It seems if I did something like:

            <rich:tree>
             <rich:treeNodesAdaptor nodes="#{nodesBean.projects}" var="project">
             <rich:treeNode>
             <h:outputText value="#{project.projectName}" />
             </rich:treeNode>
             <rich:recursiveTreeNodesAdaptor roots="#{project.devicesList}" var="device">
             <rich:treeNode>
             <h:outputText value="#{device}" />
             </rich:treeNode>
             <rich:recursiveTreeNodesAdaptor roots="#{channelBean.channelsList}" var="channel">
             <rich:treeNode>
             <h:outputText value="#{channel}" />
             </rich:treeNode>
             </rich:recursiveTreeNodesAdaptor>
             </rich:recursiveTreeNodesAdaptor>
             </rich:treeNodesAdaptor>
             </rich:tree>


            It would just display the full List of channles under each and every device, showing no actual owenership.

            Please tell me what I can do here, I got screwed over with two lazy team mates and I have had to do all of this myself for 4 months now and I cannnot take losing all the work I have put into this

            • 18. Re: Can you make List<String, List<String>> work with rich:t
              nbelaevski

              From what I see, device has to contain list of channels, not some channelBean. Or channelBean should have method to filter channel by some device - then you'll use this method. As method expressions cannot accept parameters in JSF (if you are not using Seam), then you can use application.evaluateExpressionGet("#{device}", ...) to get the current device.

              • 19. Re: Can you make List<String, List<String>> work with rich:t

                application.evaluateExpressionGet
                will be used in my java code correct? I need a little more elaboration if possible, I am researching it now, but my time to finish this is very short

                • 20. Re: Can you make List<String, List<String>> work with rich:t

                  so far this is all I have lol :(

                  public void Application(){
                   Application application = null;
                   FacesContext context = null;
                   String expression = null;
                   Class expectedType = null;
                   application.evaluateExpressionGet(context, expression, expectedType);
                  
                   }


                  • 22. Re: Can you make List<String, List<String>> work with rich:t

                    yeah I have been looking at that already, thats how I was able to even get this:

                    Application application;
                    
                     public ProjectHolder evaluateExpressionGet(FacesContext context, String expression, ProjectHolder expectedType){
                     application.getExpressionFactory();
                     ExpressionFactory.createValueExpression(#{device}, expectedType);
                    
                     application.evaluateExpressionGet(context, expression, expectedType);
                     return null;
                    
                     }


                    But honestly I have no idea how to use this, Ive never been able to figure out how to use this stuff just using the java docs.

                    I don't know what class to put this in, I dont know what arguments to pass and how (it says FacesContext but I know absoluely nothing about FacesContext), I dont know what type of class to make this method (right now I have it set to ProjectHolder which is the class that holds the projectName and device variables)

                    But I am not going to be able to figure it out just using the javadoc, I guarantee that.

                    If only I had more time or my friggin team members were wortha crap and could have done some of the stuff I have been wasting my time on.

                    Now when it comes to tackling problems like this that will take research I dont have the freakin time. Man this sucks, I have till friday and this is just one of my many damn problems.


                    SOmeone else suggested using TreeNode and HtmlRecursiveTreeNode data types instead of using an Object bound to a list like I have been doing, do you think this might be easier? I looked at it and I couldnt get much out of it either.

                    Theres just not enough damn time man

                    • 23. Re: Can you make List<String, List<String>> work with rich:t

                      I mean there has to be some kind of treenode data structures that I can use here.
                      First I would create soem tree data type. Then populate some nodes with all the projects. Then populate nodes under the projects with some device nodes that belong to each project, then I populate a third set of nodes with channels that belong to each device.

                      God if only i were only dealing with projects and devices this would be simple but these channels are killing me

                      • 24. Re: Can you make List<String, List<String>> work with rich:t
                        nbelaevski

                        Ok, you can make your devices return channels-per-device instead. Then no evaluateExpressionGet() is necessary.

                        • 25. Re: Can you make List<String, List<String>> work with rich:t

                          Thats what I dont know how to do though. Make the devices only list the channels that belong to them instead of every channel the code finds, which is what happens if I just make a generic deviceList and a generic channelList.

                          The generic deviceList is fine because that deviceList will only belong to one project, but the channelsList won't work because I will fill the channesList with values for a device, and then once the next device is found, the channelsList gets cleared and the channels for the davice are added. So I end up with a channelsList that only has channels loaded for the last device it found them for.

                          • 26. Re: Can you make List<String, List<String>> work with rich:t

                            If it helps, and if you want to take the long time it will probably take to go over it, here is the code I am using to create the Objects I bind to my tree:

                            @PostConstruct
                             public void loadValues(){
                             //class instances that use SimpleXml to read and write Objects
                             MeasurementProjectCollectionXMLAO accessProjectCollection = new MeasurementProjectCollectionXMLAO();
                             MeasurementProjectXMLAO accessProject = new MeasurementProjectXMLAO();
                             DeviceXMLAO accessDevice = new DeviceXMLAO();
                             ChannelXMLAO accessChannel = new ChannelXMLAO();
                            
                             //class instances that use HttpClient to get xml from web service, which is passed to methods above
                             HttpClientMethods httpMethod = new HttpClientMethods();
                             ProjectHttpClient method = new ProjectHttpClient();
                             ChannelHttpClient channelHttpMethod = new ChannelHttpClient();
                            
                             //instances of various Objects that will be set to xml from the web service thorugh above methods
                             MeasurementProjectCollection measurementProjectCollection = null;
                             MeasurementProject measurementProject = null;
                             Device device = null;
                             Channel channel = null;
                            
                             //sets measurementProjectCollection to the xml received from web service
                             try {
                             measurementProjectCollection = accessProjectCollection.readXML(method.Response(null));
                             } catch (Exception e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                             }
                            
                             //start outer for loop, for every project found in the project COllection do this:
                             for (MeasurementProject project : measurementProjectCollection.getMeasurementProjects()){
                             //create an instance of ProjectHolder for each run through the for loop
                             ProjectHolder projectHolder = new ProjectHolder();
                             //sets projectName for use when needed
                             projectHolder.setProjectId(project.getProjectId());
                             //sets projectName variable for ProjectHolder class
                             projectHolder.setProjectName(project.getName());
                             //sets url value to be passed to ProjectHttpClient GetMethod in order to get devices for that project
                             projectUrl = project.getProjectId();
                             //check the values being set to projectName variable
                             System.out.println("Value of ProjectName "+projectHolder.getProjectName());
                            
                             //starts process of populating devicesList and channelsListwith values
                             if(project.getDevices() != null){
                             //clear previous values from the devicesList
                             projectHolder.devicesList.clear();
                             //clear previous values from the channelsList
                             projectHolder.channelsList.clear();
                            
                             //sets project to the xml received from web service
                             try {
                             measurementProject = accessProject.readXML(method.GetMethod(projectUrl));
                             } catch (Exception e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                             }
                            
                             //start 1st nested for loop, for every device found in a project do this:
                             for (ProjectDevice projectDevice : measurementProject.getDevices()){
                             //sets deviceUrl to devices/deviceId to pass to GetMethod
                             deviceUrl=projectDevice.getDeviceId();
                            
                             //sets device to the xml received from the web service using devices/devicesUrl
                             try {
                             device = accessDevice.readXML(httpMethod.GetDevice(deviceUrl));
                             } catch (Exception e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                             }
                            
                             //add the deviceName to the deviceList for ProjectHolder class
                             projectHolder.devicesList.add(device.getName());
                             //check the values being sent to devicesList List
                             System.out.println("Value of devicesList "+projectHolder.getDevicesList().toString());
                             } //end of 1st nested for loop
                            
                            
                            
                            
                            
                            
                            
                             } //end process of populating devicesList and channelsList with values
                            
                             //adds each version of the ProjectHolder Object to the projectHolder List
                             projects.add(projectHolder);
                            
                             } //end of outer for loop
                             } //end of loadValues class


                            • 27. Re: Can you make List<String, List<String>> work with rich:t

                              well 5am here, guess I better sleep, I will have 3 more late late nights to do this same thing anyway

                              1 2 Previous Next