Announcement

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

    Automatic populated of **CLIENT-SIDE** record object and EJB object from dynamicform

    Hi,

    We've been evaluating SmartGWT EE for a few weeks now and have been very impressed. We have run into a situation where we can't figure out an easy automated way to populate a record object from a very simple dynamicform (attached below) whose datasrouce was built against an EJB (ie whose server type is "generic" and which does NOT have any server side logic / persistence). Here are the details:

    Problem #1
    =================
    I have a very simple datasource (attached below) which was built using Visual Builder. I pointed Visual Builder to an EJB. This datasource will NOT be communicationg the server side, i.e it's client only. I then built a dynamicform which is associated with this datasource and then display the fields automatically (source attached). Everything displays fine in the dynamic form.

    However, I now need to get the values that the user keyed into the dynaform into a record object. I accomplished this by writing out the set statements each field explicitly, as follows:

    rcSelWrkfl = new Record();
    rcSelWrkfl.setAttribute("workflowID", -1);
    rcSelWrkfl.setAttribute("workflowName", (String) frmNewWorkflow.getValue("workflowName"));
    rcSelWrkfl.setAttribute("briefDescription", (String) frmNewWorkflow.getValue("briefDescription"));
    rcSelWrkfl.setAttribute("version", -1);

    But, this will be a problem when I have dozens of fields (e.g, 50) and dozens of datasources corresponding to dozens of different EJBs. I would think that there is a way for a record object (that is based on a datasource whose server type is "generic" and was created against an EJB) to **automatically** get populated from the form. But, I couldn't figure out any method in either the dynamicform or datasoruce classes that would accomplish this. I would think that there is some method like

    Record rcSelWrkfl = dynamicForm.getRecord();

    Any help would be appreciated.

    Problem #2
    =================================
    My second question is this:

    For the same example above, I would also need to populate a CLIENT-SIDE object that is an instantiated verion of the original EJB with the values from the dynamicform. Since the datasource that we used was built directly from this EJB, and since the object based off this EJB exists on the client-side, I would think that there is an *automated* way to populate it, just as there is if the object needed to be populated on the server side, e.g

    WorkflowEJB workflow;
    dynamicForm.populate(workflow);

    or perhaps it could use (again on the client side) logic that I saw in the *server* side samples, such as:

    Map newValues = rcSelWrkfl.getValues(); // where rcSelWrkfl gets populated using the solution for the problem #1 above
    DataTools.setProperties(newValues, workflow);

    (I'm assuming that DataTools will work on the client side.)

    Minor Problem #3
    ================================

    Using the same datasource, I tried to do this:

    dataSource.setClientOnly(true);

    But it returned an error as follows:

    Error :Cannot change configuration property 'clientOnly' to true after the component has been created.

    So my guess is that when the datasource says that the servertype is "generic", that the datasource effectively becomes client-only. Is that correct? If not, how can I set the datasoruce to be client-only, as I'm assuming that I ought to do that.

    ==============
    Other general details for this entire email thread are below:

    OS: Windows XP Pro
    IDE: MyEclipse 9.0 with Google Plugin for Eclipse (2.3.1)
    SmartGWT EE 2.4
    Broswer: Mozilla Firefox 4.0.1
    GWT SDK: 2.2
    Sun JDK 1.6.0_13
    Attached Files

    #2
    1) dynamicForm.getValuesAsRecord()

    2) GWT does not support Java reflection, so you cannot use server-side APIs like DataTools/DataSource.setProperties() which use reflection. There are complicated workarounds involving writing GWT compiler extensions to enable a limited form of reflection with specific classes. Going down this route may or may not be worthwhile - can you give a big picture of what you're trying to accomplish?

    3) no, serverType:"generic" means not one of the built-in connectors (SQL, Hibernate, JPA), so you will need custom Java code. For a clientOnly DataSource, don't set serverType at all.

    Comment


      #3
      Thank you.

      With respect to #2 from your reply post:

      We have a relatively intricate model that reflect a DAG (directed acyclic graph), or to use ordinary terms, a flowchart. So, a single "DAG" (or flowchart) consists of 1 to many Processes. (The Process class has a bunch (e.g., 20) subclasses that refers to specific processes, such as "SaveFileProcess" or "EmailFileProcess" etc.). These process subclasses (e.g, EmailFileProcess) have anywhere from 5 to 50 fields/properites all of which are primitive types (int/string/float etc.) and they're designed as EJB (POJOs with the normal getters/setters).. It is the fields in these subclasses that will be displayed on a dynamicForm for an enduser to edit.

      However, since this is a flochart application, each Process has a collection of other processes that it links to. (Technically, it has 2 collections: one for all outgoing links; one for all incoming links.)

      These processes are then drawn on a GWTCanvas & Canvas object to display a typical flowchart, with each subclass process being represented by some nice image that a user can double-click on. If a user double-clicks on the image, then that's when the dynamic form open ups and the end user can then edit the 50+ fields to set the properties.

      So, the best that I've come up with using SmartGWT so far is this:

      1) Create a datasource for each process subclass. (This is not too bad since there are only about 20 to max 30 of them, and Visual Builder ought to semi-automate this step.)
      2) Then, when a user double-clicks on one of the images that corresponds to a subclassed process, the program will determine what type of subclass the process is (using instaceOf), open up DynamicForm form, and associate it with the correct datasource and automatically display all the needed fields based on the datasource xml file definition. (I haven't tested this yet.)

      3) Then, the tricky part is:
      3a) Have the values in the subclass object get transformed into some sort of record object and then have that recordobject added to the datasource/DynamicForm.

      3b) If a user makes a change to any of the fields in the DynamicForm, then update the subclassed Process properly by somehow automatically transforming the DynamicForm record object back into the subclassed Process Object. (That is, this would be a good solution for DataTools if it worked on the client side).

      But, given that DataTools won't work on client side, and given that there are about 10 to 50 fiels per subclass, and there are about 20 subclassses, I'm trying to find some semi-automated way of getting the data in the dynamicform back into the Process objects. (FYI: That said, the fields in these subclasses don't change often; so one possibility is to semiautomatically generate the java code needed to populate each field and then compile it....)

      Also, in case it's relevant, we looked into NOT using Java objects and just having SmartGWT talk directly to the underlying datamodel (which sits in MySQL). However, it sounded like that would complicate things for 3 reasons:

      1) The "drawing" prorgam on the GWTCanvas would be much easier to do if we're working with a real object model that can represent the relationships well (and have underlying methods), rather than just interacting with a series of "records"
      2) We couldn't find any SmartGWT UI class that reflected well our DAG/Flowchart. The closes thing is the hierachical tree representation, but I think (but I'm not sure), that that would not work for the following reason: a DAG does have parent and children, and the children can be parents themselves (just like SmartGWT's tree representation), BUT in a DAG, a child can (and often does) have many parents.
      3) The java classes/model were already more-or-less built.

      Comment


        #4
        Thanks, this is the kind of background information that really helps when giving advice.

        It seems as if, since you ultimately want to save this Process description, you'll want DataSources for each Process element, or perhaps a single uber-DataSource that just includes field definitions for all attributes. Which one to use depends on how you save the data: single table, blob of BPMN XML, etc.

        As far as whether to use beans client-side vs generic Records, this is the most relevant thing driving the decision:

        The "drawing" prorgam on the GWTCanvas would be much easier to do if we're working with a real object model that can represent the relationships well (and have underlying methods), rather than just interacting with a series of "records"
        You didn't mention *why* you think it's easier, just a mention of hierarchical relationships, but these can be represented by IDs pointing between elements to form a DAG, and a structure like this can be easier to serialize when you go to save (no loops).

        Now, something to be aware of: what you're building closely aligns with areas of our roadmap, and you may want to take advantage of this via the Jump Start or Feature Sponsorship programs:

        1. we're building a GWT compiler extension that will allow populating beans from Records (and vice versa). You could sponsor this to get it by a certain date and ensure it has the features you need.

        2. we've got a Drawing module for building interactive vector graphics. It's already in use by FacetChart in the Analytics module, but the APIs will soon be available for direct use as well. This might make more sense to use than GWTCanvas because we will harmonize this with our event model, drag and drop, etc. We could do a JumpStart where we build an interactive flow chart from your data model.

        3. we happen to be building a Workflow & form rules engine. It's not quite what you describe (which sounds like a full BPMN modeller) and is more oriented toward in-browser workflow tasks (non-parallel, UI centric) but there may be synergy or areas of possible Feature Sponsorship.

        Comment


          #5
          Hi,

          We're probably going to stick to what we've almost got working, but we *may* change so, we're very open to listening on how one does the jumpstarting or feature sponsorship, if not for what we're currently implementing, then for future areas. I presume we should have this discussion offline? If so, should I mention this topic to my current SmartGWT sales contact?

          On that note, when do you think the Drawing module for SmartGWT will be GA (generally available)?

          Comment


            #6
            Yes, use your current sales contact and/or the Contact Us form to further explore Jump Start or Feature Sponsorship possibilities.

            Drawing will be GA in SmartGWT 3.0, which will go beta sometime this quarter.

            Comment

            Working...
            X