Focal Point
[SOLVED]How to prevent onClick() execution using AppStudio

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1047062486

October 17, 2016, 01:58 PM
MartinY
[SOLVED]How to prevent onClick() execution using AppStudio
Hi,
Here a question for a newbie user of AppStudio : how can I prevent the execution of my report when the onClick() event is triggered and validation failed ?

Let's explain.

I have an HTML page that provide a bunch of controls to assign filters/parameters for a report, when I press the "Run" button, I want to apply some validations.
Up to there all works fine since I can have alerts telling me which field is invalid.

I'm applying js validation on field and all goes well and perform validation as it should be but the report is still launch even if one of the fields is invalid.

Here a sample of the onClick() event for the Run button that I want to implement:
function buttonRun_onclick(event) {
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;


    if (IsNumeric(GPMIN.value) == false)
    {
        alert("This is not a valid number");
        GPMIN.focus();
        return false;
    }
}


Within WF7 having a "return false;" in the onClick() event prevent the report to be launch.
How can I achieve the same result in WF8 using AppStudio ? Can't find the option to prevent execution.

And even an IBI consultant that I have here don't know how...

Thanks to help

This message has been edited. Last edited by: MartinY,


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
October 17, 2016, 02:26 PM
Francis Mariani
I create a separate function that performs the validations and returns true or false.

//Begin function validateParams
function validateParams(ctrl)
{
    if (blah... blah...)
    {
        alert('blech... blech...');
        return false;
    }
    else
    {
        return true;
    }
}
//End function validateParams


In the onclick function, I do the following:

//Begin function btnRun_onclick
function btnRun_onclick(ctrl)
{
    // TODO: Add your event handler code here
    if (validateParams(this))
    {
        // run report
        OnExecute(ctrl);
    }
}
//End function btnRun_onclick



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
October 17, 2016, 03:33 PM
MartinY
Thanks Francis,

This is quit similar as I did but it doesn't work; the report is still launch even with an error.

I see the HTML passing and setting the good things. It find the error and set the variables accordingly, but the report is still executed.

If I remove the runButton associated task, nothing is executed when no error found.

It's sure that I'm missing something somewhere, but can't figure it out.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
October 17, 2016, 03:38 PM
Francis Mariani
Martin, I thought this would work - regardless of which GUI was used to develop the page. I used Dev Studio, not App Studio - sorry about that.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
October 17, 2016, 03:41 PM
Francis Mariani
Try the suggestion in this post:

[SOLVED] Date validation and stop processing


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
October 18, 2016, 10:45 AM
MartinY
Thanks Francis.

I've been able to make it work using the stopPropagation() function.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007