• Pavan Kumar
    January 23, 2020 at 1:33 am #5637

    Hi Team,

    Which way is good to write custom functions interns of code maintenance ,readability, usage of available API etc?

    1. custom HTML – access everything using page.ui
    2. inside inline js in CV
    3. inside inline events of controls like onclick,onchange etc.(the same can be called by a function which is in inline js or custom html)

    Most of the times i observe salient/spark team uses page.ui.get(in customHTML i think) to get the things done. so is it preferred way of doing ? But writing lot of code in custom html will lead to slowness of UI loading.

    Kindly throw some inputs. Thanks in advance

    SPARK Support
    January 23, 2020 at 6:55 am #5638

    Hi Pavan,

    The answer to this really comes down to the complexity of the development.  Personally, I use page.ui for troubleshooting in the console or developing code with a live coach.  For simple implementations, code in the control events may be sufficient.  However, if the code is more than one line, I write functions in the Inline JS and reference those functions from the control events.  If a custom coach view becomes complex enough, and especially if it is a repeated view such as a custom control, the best practice is to save a JS file as a server file and load the JS file on the view.

    Regards,

    Stephen P

    Pavan Kumar
    January 23, 2020 at 10:27 pm #5641

    Thanks for reply Stephen.

    Agreed.

    Please clarify below.

    If we pass the controlId/bpmext/any other addition parameters like data/file etc through function the scope of those is valid in inline JS ?

    Can i do some thing like below? can i access all the methods available for text control and bpmext in inline js function ?

    —code in on click of button —

    var nameControlId   =${Text1}; –Text control in CV

    var BPEXT = bpmext;

    view.testFunction(nameControlId  , BPEXT );

    –function in inline JS—

    this.testFunction = function(nameControlId , BPEXT ){

    console.log( nameControlId.getData() )

    }

    SPARK Support
    January 24, 2020 at 7:24 am #5642

    Hi Pavan,

    Yes, those are valid references to pass.  However, I tend to get references to controls from within the Coach View function by using this.ui.get(“/containerPath/controlName”).  And, all functions of bpmext should already be available to the “this” reference in later BAW versions, such as the aforementioned this.ui.get();

    Regards,

    Stephen P

    Pavan Kumar
    January 24, 2020 at 7:25 pm #5643

    Hi Stephen,

    using exact path of ui control “/containerPath/controlName” approach will make it tightly coupled with UI design. If any changes to UI design in future will require re check of path of controls mentioned in our code. Would like to know your view on this.?

     

     

     

     

    Pavan Kumar
    January 27, 2020 at 6:23 am #5644

    Hi Stephen,

    I am unable to see bpmext functions in coachview ”this”. Could you please help me how to get in CV?

    Thanks in advance.

     

    Pavan Kumar
    January 27, 2020 at 6:52 am #5645

    Hi Stephen,

    able to access bpmext in CV in BAWv19.

    Can you please clarify below.

    using exact path of ui control “/containerPath/controlName” approach will make it tightly coupled with UI design. If any changes to UI design in future will require re check of path of controls mentioned in our code. Would like to know your view on this.?

    SPARK Support
    January 27, 2020 at 2:53 pm #5647

    Hi Pavan,

    One pattern you can use to keep functions associated with a custom Coach View is to create getters and setters like standard object oriented programming.  Add a function to Nested_Coach_View1 such as this.setControlData = function(dataValue).  Then use this.ui.get(“controlName”).setData(dataValue) within that function.  Then from the parent Coach View, use this.ui.get(“Nested_Coach_View1 “).setControlData(dataValue) to call the function on the inner view.

    The trade off here is that you will be able to reuse the nested coach view, but have to code the methods to set the values on each parent view where the nested view is reused.

    Regards,

    Stephen P

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Start typing and press Enter to search