Response indicator for a button
-
- 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
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:
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?
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:
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?
-
- 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
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.
It is important that you only use the response property or the onclick event, never both.
-
- 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
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?
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?
-
- 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
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.)
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.)
-
- 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
Great thanks for helping to learn more!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.)
-
- 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
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:
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:
The back end RPG now sees the value of MapUpdate as "YES" as required.
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();
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');
Last edited by Theju112 on Wed Oct 28, 2020 9:37 am, edited 1 time in total.
-
- 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
Use pui.click() to click the 2nd button, not pui.submit()
-
- 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
Thats what I have already used?
Please see the last but one line of the 1st code snippet.
Please see the last but one line of the 1st code snippet.
-
- 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
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.
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.
-
- 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
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.)
Who is online
Users browsing this forum: Google [Bot] and 4 guests