Topic
  • 6 replies
  • Latest Post - ‏2010-05-18T17:40:36Z by SystemAdmin
sh_said
sh_said
4 Posts

Pinned topic Custom Builder by extending existing builder

‏2010-05-17T15:54:09Z |
Is it possible to create a new customer builder that extends directly another builder? For example, is it possible to create a new builder that extends DataPage builder but adds a new functionality to it ?
Updated on 2010-05-18T17:40:36Z at 2010-05-18T17:40:36Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    557 Posts

    Re: Custom Builder by extending existing builder

    ‏2010-05-17T16:58:57Z  
    Sure. Input form and View and Form are examples of just that. However extending Data Page is somewhat tricky, because the PageAutomation stuff does different things in different phases of the Generation process. If you say a little more about what it is you are trying to accomplish, I can help you better.
  • SystemAdmin
    SystemAdmin
    557 Posts

    Re: Custom Builder by extending existing builder

    ‏2010-05-17T17:26:00Z  
    Sure. Input form and View and Form are examples of just that. However extending Data Page is somewhat tricky, because the PageAutomation stuff does different things in different phases of the Generation process. If you say a little more about what it is you are trying to accomplish, I can help you better.
    I should have added that everything in the Builders that come with the Factory is available to a builder that a customer makes. That is, with very very few exceptions, they are all based on public API's and techniques, and one could completely recreate any of them. There is nothing fundamentally different between a builder that you create and one that comes with the product.
  • sh_said
    sh_said
    4 Posts

    Re: Custom Builder by extending existing builder

    ‏2010-05-17T17:30:58Z  
    What I meant is to have a new builder that is a DataPage but with just a small enhancement that can be shown in a new section below the DataPage builder sections, add capabilities like filteration, some validations, so on. What is the best approach for that? With minimal effort I mean
  • SystemAdmin
    SystemAdmin
    557 Posts

    Re: Custom Builder by extending existing builder

    ‏2010-05-17T19:12:24Z  
    • sh_said
    • ‏2010-05-17T17:30:58Z
    What I meant is to have a new builder that is a DataPage but with just a small enhancement that can be shown in a new section below the DataPage builder sections, add capabilities like filteration, some validations, so on. What is the best approach for that? With minimal effort I mean
    Hmmm. Neither of those is a "small enhancement."

    PageAutomation is all about the presentation of data and forms (including the collection of the data from the form). It assumes that the data is there, already. The higher-level builders like View and Form are intended to combine the collection of data with its presentation -- that's why they are considered higher level. The idea of filtration (I assume, using information entered somehow by the end user) is definitely a data function rather than a presentation function.

    In fact, View and Form does filtration pretty well. If you make a service that has inputs (i.e. the filter values) and then returns a table of results, V&F does a great job with this. You just have to hand the Data Service to the builder and check that you want an input page. It will even put the input page on the view page, if you check the appropriate box.

    As for validations, are you talking about individual field validation or cross-field validation? If the former, do you know about the built-in validation that Data Page already provides? And how to extend it? If the latter, then the correct approach is the Post-save operation that is an input to Data Page -- you reference a method there which does whatever you like, including accessing the public API of the Errors object, which is where PageAutomation stores all the error messages for display on the page when validation has failed.

    So, the first question is: do you know how to accomplish the task manually, using existing builders? It is pretty easy to make a builder that just wraps up a few others, though there are a few distinctly tricky steps, especially when you are talking about PageAutomation. For instance, to create a single builder that includes a Data Page plus one or more modifier builders (Data Field Modifier, etc.) it is a little tricky to know how to make the selector in the modifier's inputs which tells it which PageAutomation element to modify. And that's if your builder just calls other builders.

    It is also possible to make a "PageAutomation" builder, which means that it runs in the magical PageAutomation phase, in between when Data Page has made the internal representation of what it is going to create but before it has actually rendered anything to the page or to Java code (which is creates roughly simultaneously). This also uses public API's which I could point you at, but I wouldn't want you making your FIRST builder this way. Making a simple builder is enough to wrap your head around. (Not that its hard, exactly, but its a new way of thinking that is tricky at first.)

    Anyway, the first step is to understand how you could accomplish what you are trying to accomplish just with the existing builders. Then we can discuss the steps to make a builder that implements the pattern.
  • sh_said
    sh_said
    4 Posts

    Re: Custom Builder by extending existing builder

    ‏2010-05-18T09:59:38Z  
    I created the model manually using the DataPage with other builders and have the functionality that I need in that model .Now, I want to export this new model as a new builder, I know that model based builder can be used to accomplish that. But what I want is that the new builder inputs will be those of the DataPage and some extra inputs that I expose from the other builders in the model for the new functionality. I was thinking of profiling every input in the DataPage in my model so that it can exposed in the new builder, but I was thinking that there should be a better way to do that. A way like saying that the builder is extending from DataPage or something like that. Can you guide on the best way for that?
  • SystemAdmin
    SystemAdmin
    557 Posts

    Re: Custom Builder by extending existing builder

    ‏2010-05-18T17:40:36Z  
    • sh_said
    • ‏2010-05-18T09:59:38Z
    I created the model manually using the DataPage with other builders and have the functionality that I need in that model .Now, I want to export this new model as a new builder, I know that model based builder can be used to accomplish that. But what I want is that the new builder inputs will be those of the DataPage and some extra inputs that I expose from the other builders in the model for the new functionality. I was thinking of profiling every input in the DataPage in my model so that it can exposed in the new builder, but I was thinking that there should be a better way to do that. A way like saying that the builder is extending from DataPage or something like that. Can you guide on the best way for that?
    Using a model-based builder, I'm afraid that there isn't a better solution. You could simply call the builder via the API class, and that might be a bit easier. You would start by duplicating all the inputs from Data Page into your BDEF, with all of them just extending the same-named input from Data Page. Then, rather than use the the generated setWhatever names in the generated class, you could just loop through your inputs and copy them over using the generic setInput methods.

    Be careful of any XML inputs: Make sure you call cloneElement on them before handing them over.

    So your BDEF is filled with these:

    <InputDefinition name="Name" base="com.bowstreet.builders.webapp.pageautomation.DataPage.Name">
       <UseAssociatedCoordinator>true</UseAssociatedCoordinator>
    </InputDefinition>
    


    which you create by just copying all the inputs from the Data Page bdef (snag it from the zip file at the top of the builders directory) and editing each input to look like the above, where only "Name" is different for each one.
    Updated on 2014-03-25T15:56:03Z at 2014-03-25T15:56:03Z by iron-man