Announcement

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

    VirtualDataSource

    Not sure how or wheter to use it, but it sounds good.

    And here is the problem:
    I dynamically load all my DataSources in a servlet (that actually reads the ds directory and than passes the LoadDataSource all the names),
    than in the view i let the user choose which DS he want to display.

    So i try to find a way to make the view get all my datasources that i`ve loaded before.

    i thought to load an extra "virtual" ds named DATASOURCES
    and add as the data all of my DS IDs.

    But i can`t make it work..

    Any idea how should i implement it? where can i see an example of using this class? or generating a DS by myself + addind data to it?

    #2
    That's a fine approach, just realize you can't return just a simple Array of String, you still need to return a List of Records. So you'll want to return something that would look like this in JSON:

    Code:
    [
    { dataSourceID:"products", title:"Products" },
    { dataSourceID:"orderItem", title:"Order Items" }
    ]
    You can put that together as eg a List of HashMaps in Java and provide it to dsResponse.setData().

    Comment


      #3
      not sure i understand..

      i didn't realize how to make that DS alive and reachable in both side,

      i think that describing my code again would help,

      I extended the DataSourceLoader so instead of giving him in the HTML a list of datasources it reads the directory of where the DS are stored and loads them all.
      That list is data i want to have access from my view class.

      How can i do that?
      In my approach i find it hard to "fake" a DS - so if you could give me a code example or a different approach that would help a lot..

      Comment


        #4
        You're not explaining why you have trouble creating a "fake" DS. Just look at the Custom DataSource samples, it's simple.

        Comment


          #5
          The custom-ds looks like a overhead for me, all i want is to pass that list,
          isn't a easier way with less code involved?

          Comment


            #6
            Try actually writing it rather than speculating further. You'll find the code involved is about as short as it can be.

            Comment


              #7
              But, is that the right way?

              Comment


                #8
                I looked on customDS example and didn't succeed to make it work for me,

                i made my datasource (that the serverConstructor points to)
                return the list whenever the request is to that DS of all DSs.
                -in the list i put a POJO that has one field "name" just like this DS.xml contains

                but in the grid it doesn't appear (show empty records)

                in customDS it works that way, any idea why i got a grid with empty records (the number of records is correct..)?

                Comment


                  #9
                  in other words - what objects should i pass to DSResponse as data to make it work?

                  Comment


                    #10
                    i can`t find an example or find the way by myself :(

                    Comment


                      #11
                      once again - what and how should i set the data on the DSResponse so it appears on the grid?

                      Comment


                        #12
                        There are a dozen samples, copy any one of them. If you can't follow the sample, then of course you need to show your attempt.

                        You probably have different capitalization or spelling of the property name in the DataSource vs the name of the property on the POJO, or some mistake like that.

                        Comment

                        Working...
                        X