Focal Point
[SOLVED] Frustrated to no end with AppStudio and getting validation bef...

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

May 08, 2015, 12:10 PM
CoolGuy
[SOLVED] Frustrated to no end with AppStudio and getting validation bef...
Hey all!

So, I've been fighting AppStudio for some time now trying to get basic form validation to work. The 'Selection & Validation' property for input elements fails to work in AppStudio 8.1.04 (using). I've also made several attempts to find adequate documentation for this (found what you can in the online docs). I've also opened a case w/o any solution returned as of yet (in regards to the 'Selection & Validation' property). I've spent time trying to figure out where my event handler code for the submit button should go and what if any IBI API functions I should be using, where to place code, etc. For some reason AppStudio won't even let me create .js (from the tool) or add .js files (from my desktop that I've created in Notepad++) to my Content folders. It is quite infuriating. I REALLY REALLY REALLY despise the individual who thought it was a good move to axe the ability to access the HTML for your apps. I'm motivated to move on from IBI products all together if they think the majority of us are too stupid not to mess with tool generated code. I understand the importance of not touching the tool generated code. I've coded in C# with Visual Studio where they (far more intelligently) place the tool generated code within collapsible #region tags with comments letting you know that area is off limits. But no... IBI treats us like children.

Here's my current code from the 'Embedded JavaScript/CSS' tab. I've had different versions with onIntitialUpdate(), etc. in there as well. Can anyone here help me see what I'm doing wrong? I'm very frustrated.

  
if(typeof(bRuntime) != 'undefined') {
    // TODO: Add your inline runtime code here
}


//Begin function window_onload
function window_onload() {


    UpdateData();


    // TODO: Add your event handler code here


    //Begin function form1Submit_onclick
    function form1Submit_onclick(event) {
        var eventObject = event ? event : window.event;
        var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;


        function checkInput() {
            if(document.form1.edit1.value == "") {
                alert("You must enter a car brand!");
                return false;
            }
            else {
                return true;
            }
            document.form1.submit();
        }
    }
    //End function form1Submit_onclick
}
//End function window_onload

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


8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.
May 08, 2015, 05:27 PM
eric.woerle
So, most of this seems to be merely a rant against the design of App Studio (which I agree with mostly by the way), but in all that ranting, I couldn't quite understand what it is that you are experiencing as your issue? What is failing? and how is it failing?

Personally I don't use App Studio because in version 8.0.08, I can't even add a graph to the page without App Studio crashing. So I use Developer Studio (At least there I can still get to the HTML where I know the code is written correctly ie proper use of div v span tags etc. because I wrote it). But assuming the form creation works the same way in App Studio as it does in Developer studio, the report will fire off using onSubmit. That is where you want your function to be. You want to replace the current call which in DS is created as onSubmit="onExecute(this);return false;" and replace that with your function. in this case form1Submit_onclick(event). From the naming of that function, I'm assuming that you have assigned it to the onclick event of the Submit button for form 1.

Also you can use the document.form.submit function, but I generally prefer to use onExecute("FormID");. Using the OnExecute command will invoke all of the JS that IBI has already built that includes form validation etc. where I'm not sure that document.form.submit will.


Eric Woerle
8.1.05M Gen 913- Reporting Server Unix
8.1.05 Client Unix
Oracle 11.2.0.2
May 10, 2015, 06:31 PM
Waz
You have coded functions within functions.

They should be separate, then call the function.

e.g.
//Begin function window_onload
function window_onload() {


    UpdateData();


    // TODO: Add your event handler code here


}
//End function window_onload

    //Begin function form1Submit_onclick
    function form1Submit_onclick(event) {
        var eventObject = event ? event : window.event;
        var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;


    }
    //End function form1Submit_onclick

        function checkInput() {
            if(document.form1.edit1.value == "") {
                alert("You must enter a car brand!");
                return false;
            }
            else {
                return true;
            }
            document.form1.submit();
        }



You may need to do a lot more to the javascript to implement validation.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

May 11, 2015, 10:30 AM
CoolGuy
Thank you eric.woerle and Waz for your insights. I didn't know that you couldn't define functions within functions with Js. I come from Java where that is allowed. Good thing to know, right? haha Sorry about my rant on AppStudio last Friday. Had a long week last week. Need to spend some time with Js to get myself acquainted with it.


8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.
May 11, 2015, 10:45 AM
jgelona
CoolGuy, you're not alone. I don't much care for it either. I dread the day when IBI no longer supports Dev Studio. I may keep using Dev Studio forever unless I absolutely can't do something any other way.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
May 11, 2015, 06:24 PM
Waz
You may be getting confused at the js level with creating methods for objects, which you can do with prototyping, but in this case no, they have to be separate.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!