Page 1 of 1

Miscellaneous Response object issues and custom widgets

Posted: Fri Jul 07, 2017 11:53 am
by shelfos
I have two issues related to custom widgets and sending back a response to the IBM i.
  • Issue 1:
    • Scenario: Using more than one kind of custom widget in the same record format requiring multiple functions in the onsubmit() event.
    • Example:

      Code: Select all

      window.myCustomWidgetOnSubmit1; window.myCustomWidgetOnSubmit2;
    • Problem: The first function is evaluated; the second one is not.
    • Potential Solutions:
      • 1. Use the same function for all custom widget types (append code to this function whenever a new widget type is created)
      • 2. Expose the response object so that values can be appended directly to it from within the custom widget's code (removing the need to call a function in the onsubmit() event that handles it)
      • 3. Expose a custom response object that gets appended to the main response object on form submission (custom widget code would include assignments to this custom response object)
      • (ProfoundLogic would have to enhance their code for solutions 2 and 3)
  • Issue 2:
    • Scenario: Using pui.submit() in the onclick event of a custom widget (where the onclick event is attached in the custom widget code itself)
    • Problem: pui.submit() does indeed submit the form, but when done this way seems to bypass calling any custom widget functions listed in the onsubmit() event of the record format itself.
    • Hopefully someone has some ideas how to solve this issue.
Thanks!

Re: Miscellaneous Response object issues and custom widgets

Posted: Tue Jul 11, 2017 11:42 am
by Scott Klement
Right now, you will need to use a single function for onsubmit. It is possible to write a generic one that will work with any/all custom widgets on the display without changes when more custom widgets are added/removed. There is an example of this in the documentation.

PLEASE, never modify the profound ui runtime code. Not only would this require you to make changes each time you upgrade or install a patch, but it'd also make it nearly impossible for us to support you.

pui.submit() is ONLY for when you are not using our displays, but instead driving your own custom HTML with the open access handler, or for handling offline situations in mobile apps. You should not be using it in a Rich Display like this. Please use pui.click() to submit displays.

Re: Miscellaneous Response object issues and custom widgets

Posted: Tue Jul 11, 2017 1:21 pm
by shelfos
Scott,

Would you and others at Profound consider the option of having a custom Response object available to append values to, for merging with the main Response object? It would be nice to encapsulate the functionality for each custom widget without having to worry about calling a function on the onsubmit() event. This would shield future designers/developers from having to always remember that.

I don't think it would be terribly difficult to accomplish. An object could be created at runtime, something like:

Code: Select all

var customWidgetResponses = {}; 

Custom widget developers would have to add values to this object in the custom widget's code, e.g.

Code: Select all

customWidgetResponses["RECF0001.FLD0001"] = "some value";
Upon form submission, Profound would merge any values in the customWidgetResponses object with any main response values.

Re: Miscellaneous Response object issues and custom widgets

Posted: Tue Jul 11, 2017 1:28 pm
by Scott Klement
If you want to place a feature request, you can do so my e-mailing support@profoundlogic.com

Re: Miscellaneous Response object issues and custom widgets

Posted: Tue Jul 11, 2017 4:09 pm
by shelfos
I just now submitted this feature request to support@profoundlogic.com

Thank you.

Re: Miscellaneous Response object issues and custom widgets

Posted: Wed Jan 27, 2021 1:31 pm
by matt.denninghoff
This has long been in the works, but we've implemented a way for users to create custom widgets that are treated like native Profound UI widgets: their values get submitted to the server-side program (including when they are in subfiles), and they work with most Profound UI widget API methods.

The feature will be available with the next release of Profound UI, Version 6 Fix Pack 12.0.

Please see the documentation page about pui.BasicWidget for the specifications and an example: https://docs.profoundlogic.com/x/UgFKB

Using this class vastly simplifies the implementation of custom widgets; there's no more need to code "onload" code or "beforeSubmit". Values get formatted automatically according to their bound date type and formatting options. Values are automatically applied to the correct format, so there's no more need to divine the format name from the screen.

Widgets from 3rd party frameworks can be wrapped in instances of pui.BasicWidget, allowing them to be used like native Profound UI widgets.

I hope you find this useful!