Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Nested Datasources

    Hi,

    Is there a possibility to define nested data sources without involving the server - so something like (if it would be in xml) this:

    A Team with user members:
    Code:
    <List>
       <team>
         <name>Team1</name>
         <type>internalusers</type>
         <userid>11</userid>
         <userid>12</userid>
         <userid>13</userid>
       </team>
       <team>
           xxxxxx
       </team>
    </List>
    Where the Users are defined in another Datasource:

    Code:
    <List>
                 <user>
    		<userid>11</userid>
    		<firstname>xxxx</firstname>
    		<lastname>yyyy</lastname>
                    <enabled>true</enabled>
                 </user>
                 <user>
    		<userid>12</userid>
    		<firstname>xxx2</firstname>
    		<lastname>yyy2</lastname>
                    <enabled>true</enabled>
                 </user>
    </List>
    My question is how to define the team datasource ?

    I started with that - but the nesting is not shown

    DataSourceIntegerField userId = new DataSourceIntegerField("userId","User");
    userId.setMultiple(true);
    userId.setForeignKey("userDS.userid");

    Is this way correct - and what is missing to get it run ?

    br
    johannes

    #2
    Take several steps back and explain basics like how you want the data to appear, in what components, and when it should be loaded.

    Comment


      #3
      What i want to achive is that i can show all the users of a team within a TreeGrid - and when selecting the user resource to display that within a DynamicFormField for editing (the subfields of the user) !

      Thats why i want to link those together - on the database side (server side - seam) that a "classical" onetomany relationship (one team a lot of users) - which i also want to present in the client!

      Within the examples i have seen you always nest the same datasource to itself (employee belongs to employee) - but i want to show the team as the "root" of the tree - showing the members of it !

      I hope my explanation is what you asked for !

      Regarding the load - i have an tab which is loaded when the user clicks on so called "user management" - then this should be loaded !

      To explain everything... i plan to get the data as a custom datasource using the gilead software (seam server -> gilead remote objects -> smart client)!
      I want to avoid a two server strategy (seam server -> gilead -> smartclient server -> smart client) therefore i need to know how i should present the data (as a client datasource) to the TreeGrid - and my starting point was to use the "classical" xml files as a datasource to see if it is possible to achieve what i want!
      Last edited by jhollerer; 13 Jan 2010, 15:28.

      Comment


        #4
        To present two or more different types of entities in a single tree with a common set of columns, use the tree facade approach explained in this thread.

        Consider also a side by side treeGrid and listGrid as shown in the Showcase Application - this is better for trees with large numbers of children, which have poor usability if shown as a tree alone.

        Comment


          #5
          Hi thanks for the answer !

          Only to be shure... i want to present something like this:

          Team1
          |....> User A
          |....> User B

          and if i click on the user - the user details should be shown !


          And what i understood you mean to make a DS which covers them both - like this:

          Code:
          <List>
             <team>
              <name>Team1</name>
              <type>internalusers</type>
          	<user>
          		<userid>11</userid>
          		<firstname>xxxx</firstname>
          		<lastname>yyyy</lastname>
          		<enabled>true</enabled>
          	</user>
          	<user>
          		<userid>12</userid>
          		<firstname>xxx2</firstname>
          		<lastname>yyy2</lastname>
          		<enabled>true</enabled>
          	</user>	
             </team>
             <team>
                 xxxxxx
             </team>
          </List>

          Code:
          DataSourceTextField f1 = DataSourceTextField("name", "TeamName");
          f1.setPrimaryKey(true);
          
          DataSourceTextField f2 = DataSourceTextField("type", "Type");
          
          DataSourceTextField f3 = DataSourceTextField("firstname","Fistname");
          f3.setMultiple(true);
          
          DataSourceTextField f4 = DataSourceTextField("lastname","Lastname");
          f4.setMultiple(true);

          If you mean by facade the example above - how do i get to the pressed user to show the Details ?

          Comment


            #6
            If i make some JavaBeans on the server having the - can i then achive what i need ??

            like it is done in this example:
            http://www.smartclient.com/smartgwtee/showcase/#javabeans

            So to make two classes

            Team.class
            Code:
            private int id;
            private String name;
            private String type;
            private List<User> users;
            ....

            User.class
            Code:
            private int id;
            private String firstname;
            private String lastname;
            ....

            but how does the .ds.xml then look like (to make that work) ?

            Comment


              #7
              You need to make the nodes uniform so that they can be displayed in a single tree. Create one data response that incorporates data from each of the two classes in a single, uniform object.

              For example, create a single property "title" that will be shown as the tree node title. Populate it with the "name" property in the case of Teams, and the firstName + lastName property in the case of Users.

              Comment


                #8
                Thanks for the info - so i need to combine both within one source !
                The bad thing is that i then loose the whole advantage of the DataSource - when adding / deleting as i need to write a layer in between - who checks what really gets added / changed/ deleted ...


                But thanks for the help !

                Comment


                  #9
                  Load on demand, filtering and many other DataSource behaviors still apply - you're probably referring to cache sync, and it is true that you need to manually implement it with this pattern. That's one of the reasons it's still worthwhile to sponsor the multi-DataSource tree feature mentioned in the thread about the tree facade pattern.

                  Comment


                    #10
                    Mainly i loose all the "nice" things of a datasource !!
                    If i would not need the functions now - i would consider to make a sponsorship !

                    Comment


                      #11
                      Just in case - you may be thinking a sponsorship implies waiting until the next public release - it doesn't, the feature would be available as soon as it can be implemented, in nightly builds.

                      Comment


                        #12
                        Can you give me an idea what this would mean in terms of time and money for that special function - as if we need to decide if we have to implement the "workaround" or generally go for another solution - like flex (which i am not a fan of)!

                        Comment


                          #13
                          And one other question - just arising:

                          If i now have one datasource which holds my ID(s) of the real datasource - how can i tell the DynamicForm - which ID of his datasource it should show - when it comes to the part of editing of the selected item ?

                          Comment


                            #14
                            Could you try explaining that question in different terms?

                            Note that you always have the API DataSource.fetchData() to directly fetch data without affecting any components.

                            Comment


                              #15
                              What i want to achive is something like this:

                              Team
                              |..> User1
                              |..> User2

                              As soon as you click on the User1 i want a form to be displayed where the details of that User are shown and can be edited.

                              As described in your "solution" i should make one datasource, which contains the Team and the User objects - and their IDs.

                              Now if the User1 is pressed in the ID - how can i tell the DataSource of the Form - which UserID to load ??

                              Does this description make sense ??

                              Or can i achive that using Criteria(s) - on the second datasource ??

                              Comment

                              Working...
                              X