Announcement

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

    Cloning visual builder forms

    Versions: smartgwt 2.0, gwt 2.0.1

    I'd like to be able to use a dynamic form definition (and for that matter a listgrid or other canvas) in multiple places in my application. For example, I have a "result" editor and would like to display two of these side by side for a user to easily compare values. I also have a few different "screens" that have differing query panels, with the same results grid definition.

    Is there a "clone" that does a deep copy (and allows for renaming the IDsin the graph), and if so would this work? If not, what is the best practice for this?

    I have the same issue with the datasource backing these canvases and would like to have the same data source definition, but "N" different criteria against this datasource active at a time (one for each of the above canvases that is backed by the "same" datasource definition).

    I could, of course copy the xml files multiple times every time I edit it and rename the ids, then load them all separately, but I'm wondering if there is another, better way to do this. I don't relish the thought of having to hand edit "N" number of files every time I make a single logical change.

    #2
    This is a classic case of creating a custom component, not really something to do in Visual Builder. This sample shows how you can create a custom components in which the DataSource is "pluggable", that is, the component captures a pattern such as side-by-side editing that can be used with any DataSource.

    Comment


      #3
      I think this only works if you can live with the way DynamicForm and ListGrid work with a datasource without customization.

      Quite honestly, they are great for simple use cases like the example, but I need the Dynamic form to lay out a specific way (large 600x400 textarea item for one field, textfield that spans 4 columns, a separator item between field a and b, some help tooltips on some fields but not others)? I either have to write construction code and call it with an ID pattern from multiple places (which precludes me from using visual builder for these), or I need the "clone". Am I missing another option?

      Also, what about data sources? I have multiple panels in my application that need the "same" datasource, but not the same result sets based on that datasource. is it possible to share a datasource definition between multiple grids?

      Comment


        #4
        You're missing a lot of the flexibility of the system - training would help a lot here.

        In a nutshell:
        1. yes of course, an unlimited number of components can bind to the same DataSource. Each ListGrid bound to a DataSource has it's own ResultSet with independent search criteria, sort direction and cache - see ListGrid.fetchData() and the linked ResultSet docs.

        2. you can pass fields / items to a ListGrid / DynamicForm respectively to customize how that component binds to the DataSource. See also useAllDataSourceFields and this sample.

        3. you can subclass ListGrid / DynamicForm to use this mechanism to influence how the components bind to DataSources. You can even create your own custom properties on DataSource that only your components understand.

        4. once you've wrapped up your customized ListGrid / DynamicForm into a class encapsulating a pattern, you can still allow users of your class to pass in their own fields / items for further customization

        Comment


          #5
          I'm sure training would help me, and I will have to investigate whether that is an option in my situation.

          Thank you for the pointers, I will have a look at them and try them in detail.

          If I understand what you are saying, though, I will have to do what I was planning to do with visual builder in code by passing fields to the DynamicForm constructor. I had hoped to get the form/grid to look exactly like I want it in visual builder, then reuse this XML definition in multiple places in my application. I understand why this will not work, so I'll look into the options you suggest.

          Comment


            #6
            Generating a reusable class from a screen design is a feature Visual Builder could support - if this would help your project, consider Feature Sponsorship.

            Comment

            Working...
            X