Response indicator for a button

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Response indicator for a button

Post by Theju112 »

Dear Team,

My second question for the day.
I am attempting to understand the correct usage of the response property of button elements. The way I understood is that, if we bind the response property of a button to a variable whose data type is set to indicator, the bound variable value would get set to *ON, when the button is clicked.

But it seems this isn't the case. For example:
mapind.JPG
mapind.JPG (22.19 KiB) Viewed 3645 times
So, I was expecting that the value of MapUpdate would get set to *ON on clicking the button to which it is bound. But it doesn't work that way I guess.

So If I want to execute an action based on the button clicked on a rich display, how should I proceed?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Response indicator for a button

Post by Scott Klement »

Yes, that is correct, the variable bound to the response property will be set to '1' (which can be referred to as *ON in RPG). Also, the screen is submitted back to the server when a button is clicked that has a response property set.

It is important that you only use the response property or the onclick event, never both.
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Re: Response indicator for a button

Post by Theju112 »

Hi Scott,

As you seem to have guessed correctly, I had used the onClick property in addition to the Response property.

Does the response indicator not work if onClick is set as well?

I needed to run some client side validations which I included in the onClick property. If that would not work, what approach can be followed in this scenario?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Response indicator for a button

Post by Scott Klement »

Add a second button and set its visibility to "hidden" so the user never sees it. Bind the reponse to this hidden button.

Remove the response from the first button. Have the onclick do whichever validations are needed, and then run pui.click() to click the 2nd button and submit the screen.

Or, alternately, remove the "onclick" and put the validations in the screen-level onsubmit event. (That will run the validations for all things that submit thee screen rather than just the one button, however.)
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Re: Response indicator for a button

Post by Theju112 »

Scott Klement wrote:Add a second button and set its visibility to "hidden" so the user never sees it. Bind the reponse to this hidden button.

Remove the response from the first button. Have the onclick do whichever validations are needed, and then run pui.click() to click the 2nd button and submit the screen.

Or, alternately, remove the "onclick" and put the validations in the screen-level onsubmit event. (That will run the validations for all things that submit thee screen rather than just the one button, however.)
Great thanks for helping to learn more!
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Re: Response indicator for a button

Post by Theju112 »

Hi Scott,

I think I am missing something trying to implement the hidden button "trick" you told me.

So, as you mentioned I removed the response indicator from my first button and added a second hidden button.

Below is the onClick js of the first button:

Code: Select all

//**PAVT Get the MAP iframe reference
var iframe = document.getElementsByTagName("iframe")[0];

//**PAVT Get the marker Latitude and Longitude values
var mapLat = iframe.contentWindow.document.getElementById("latitude").innerHTML;
var mapLong = iframe.contentWindow.document.getElementById("longitude").innerHTML;

//**PAVT Assign the marker Lat and Long values to the Hidden Latitude/Longitude fields on screen
changeElementValue("MAPLATH",mapLat);
changeElementValue("MAPLONGH",mapLong);

//**PAVT Update indicator to indicate that user wants map marker address to be used

pui.click('mapUpdBtn');
pui.submit();
The response of the mapUpdBtn has been bound to an indicator variable by the name mapUpdate.

But even after I click on the first button and control goes to the RPG (from pui.submit()), when I do an eval of mapUpdate in debug mode, it is blanks.

I am not sure what is being missed. One thing I noticed is that in the DDS of the file, the mapUpdate is a hidden character field not an indicator as I expected. Do you suspect something?


For now, I have changed the code to this in the onClick JS of the original button:

Code: Select all

//**PAVT Get the MAP iframe reference
var iframe = document.getElementsByTagName("iframe")[0];

//**PAVT Get the marker Latitude and Longitude values
var mapLat = iframe.contentWindow.document.getElementById("latitude").innerHTML;
var mapLong = iframe.contentWindow.document.getElementById("longitude").innerHTML;

//**PAVT Assign the marker Lat and Long values to the Hidden Latitude/Longitude fields on screen
changeElementValue("MAPLATH",mapLat);
changeElementValue("MAPLONGH",mapLong);

//**PAVT Update indicator to indicate that user wants map marker address to be used
changeElementValue("MAPUPDATE","YES"); --> Hidden output field.
pui.click('btnSubmit');
The back end RPG now sees the value of MapUpdate as "YES" as required.
Last edited by Theju112 on Wed Oct 28, 2020 9:37 am, edited 1 time in total.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Response indicator for a button

Post by Scott Klement »

Use pui.click() to click the 2nd button, not pui.submit()
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Re: Response indicator for a button

Post by Theju112 »

Thats what I have already used?

Please see the last but one line of the 1st code snippet.
Theju112
Profound User
Posts: 48
Joined: Fri Jul 10, 2020 8:35 am
First Name: Thej
Last Name: Pav
Company Name: Confidential
Phone: 00918310800134
Address 1: Chennai
Address 2: India
City: Chennai
State / Province: Outside Canada/USA
Zip / Postal Code: 673592
Country: India
Contact:

Re: Response indicator for a button

Post by Theju112 »

Hi Scott,

Thanks for helping. I get your point now.

I was confused because only now did I come to know that binding a response indicator to a button causes it to submit somehow when clicked?

Works now.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Response indicator for a button

Post by Scott Klement »

Yes, when you click a button that's bound to 'response', it submits the screen. (We use that word, "Response" in several places to indicate that something returns control back to the server.)
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests