Page 1 of 1

custom widget div value

Posted: Tue Mar 21, 2017 11:00 am
by sfoster
I have searched the forums and I couldn't find anything that matched closely enough to feel like I have a definitive answer to this.

I have created a custom widget that is an <input> element inside a <div> element. I cannot get the value to pass back to the rpg program. I suspect it is because the highest level element is not an <input> type of element - it's a div.

Is there a way to pass this value somehow? (without modifying the proddata files or using a "hacky" hidden field to track the actual value)

Re: custom widget div value

Posted: Tue Mar 21, 2017 2:12 pm
by Scott Klement
How are you trying to get the data to be passed back? You posted this in the Genie forum, can I assume therefore that this is meant to be used on a 5250 display? If so, the only data that is sent back is the data that was on the original green-screen. So you have to copy your data into a I_x_x type field that will be passed back to the original green-screen.

If you're referring to Rich DIsplay, only certain properties (pre-defined by Profound) are bi-directional. For your own custom properties, they will be output-only. You will need to either copy the data to an existing bidirectional widget like a hidden textbox, or you will need to manually insert the data into the response object in an onsubmit event.

Re: custom widget div value

Posted: Tue Mar 21, 2017 2:39 pm
by sfoster
Thank you Scott for your quick reply.

You are correct - I should have posted this in the Rich Display forum.

Here's a snapshot of the custom widget - I can attach the JavaScript used to create it if you'd like.
searchSnap.PNG
searchSnap.PNG (2.2 KiB) Viewed 3028 times
I've associated a 15-character field named 'SEARCH' with it's value in the Profound UI designer, but in debugging the rpg, the value is always passed back as blank. You mentioned that there's a way to tie in to the response object and I see in the documentation that there is a pui.applyResponse() method. Is this what you are referring to? If not can you point me in the right direction?

Thanks.

Re: custom widget div value

Posted: Tue Mar 21, 2017 3:24 pm
by Scott Klement
Why did you bring up Universal Displays? I'm lost.

I asked you if this was 5250 vs. Rich DIsplay. You came back with info about not using Universal Displays.... I'm not understanding why you're bringing them up, as they have nothing to do with this conversation AND you're not using them.

5250 is the old-school type of IBM workstation/terminal that the old AS/400 systems used. They worked like Mainframes where they had one CPU with lots of terminals that people used to work from. Today's IBM i is nothing like the AS/400 (depite that some people still use that terminology), today we use PCs, mobile devices, etc as clients instead of terminals. But, still, a lot of old applications use 5250, using emulation software to let a window on our PCs look like a terminal.

Genie is a 5250 emulation software that will convert the old 5250 terminal output into a web page, and can add additional widgets and customizations on top of that web page.

Rich Display is a whole different type of display that supports a GUI interface (with a high amount of backward compatibility to older RPG paradigms) but does not use 5250 at all. It is pure HTML5/JavaScript/CSS. Genie _also_ supports Rich DIsplays and can switch between 5250 mode and RIch Display mode as required by the application.

But, normally, when someone has a question about RIch DIsplay, they post it in the Rich DIsplay forum despite that Genie can run them. They use the Genie forum for Genie-based 5250 displays.

Since you did not specify which you were using, I first explained 5250 displays, then Rich DIsplays.

None of that has anything whatsoever to do with Universal Displays, which are a completely different animal, entirely.

Re: custom widget div value

Posted: Tue Mar 21, 2017 4:23 pm
by sfoster
I'm well aware of what a 5250 is and I understand what emulation is. I've been working on the AS400 / iSeries since 1994. But I'm still learning Profound and the associated terminology. Genie, Rich Display, Universal Display, etc. etc. Hmmmm.

I only mentioned Universal Displays because I was under the impression that Universal Displays = Rich Displays and that logic led me to post in the Genie forum. The logic was: "since I know it's not this, it must be this". In other words, I knew it was not Universal Display, and since in my mind Rich Displays = Universal Displays it must therefore be Genie.

Unfortunately I was in the middle of editing my previous post when you submitted your response so now the thread may not make as much sense, since it does not even include the bit about Universal Displays.

In any case, I still am looking for a solution. If you see my previous post (now edited), I've included a screenshot of the actual widget. And here I am including a screenshot of the Profound UI Designer.
ProfoundDesigner.PNG
ProfoundDesigner.PNG (355.87 KiB) Viewed 3021 times

Re: custom widget div value

Posted: Wed Mar 22, 2017 10:58 pm
by Scott Klement
I can only guess at this point (since I cannot debug it), but here is what I would guess;

You will need to either copy the data to an existing bidirectional widget like a hidden textbox, or you will need to manually insert the data into the response object in an onsubmit event.

Re: custom widget div value

Posted: Thu Mar 23, 2017 8:36 am
by sfoster
I've copied the data to an existing bidirectional widget and that is working fine.

You mention inserting the data into the response object. I would prefer to do it that way, if it's possible for rich displays.

Would you be willing to provide an example of how to insert data into the response object?

Re: custom widget div value

Posted: Thu Mar 23, 2017 10:19 am
by matt.denninghoff
To insert data into the response object, you'll need to define a global function with one parameter. For example, you might put this in the same file where you define your custom widget:

Code: Select all

window.myCustomWidgetOnSubmit = function(response){
  var data = {"FMTNAME.FIELDNAME", "somevalue"};
  pui.applyResponse(data, response);
}
Then the "onsubmit" property of the screen would be:

Code: Select all

myCustomWidgetOnSubmit;
Note: there must be no parentheses, and no other code, or else "onsubmit" won't call your function.

The tricky part is knowing what the record format name and bound field name are during runtime.

Re: custom widget div value

Posted: Thu Mar 23, 2017 3:10 pm
by matt.denninghoff
Most people use derived widgets to ensure the response is set properly. For custom widgets from scratch, the support for handling the response was limited. With version 5.8.0, we've made it easier. You can read this doc page for details:
http://www.profoundlogic.com/docs/displ ... onse+Value

It was added today.

Re: custom widget div value

Posted: Thu Mar 23, 2017 3:16 pm
by sfoster
That's awesome to see it's in the documentation. Thank you so much for your help.