Page 1 of 1

Temporarily disable buttons on Jade Web Forms

Posted: Wed Aug 18, 2010 2:36 am
by Rich Cassell
Hi,

One of our screens on our web application (Jade Web Forms) allows a user to type monetary values against a person and a payment, this is displayed in a grid-like layout. The screen only contains 5 items and 15 people so we have used up, down, left and right buttons to move over to further pages. Pressing these buttons temporarily saves the values on the current page and then finally pressing the "OK" button saves all values from all accessed pages into the database. We have done this as table objects have limited functionality in Jade Web Forms.

The problem we are having is that a user has starting entering values in one screen then pressing the "Right" button to move over a page, then before the screen has finished loading they have pressed the "OK" button. This is saving the values in the first screen as required, but then saving the same values into the grid on the second page.

To stop this, i have attempted to use a Boolean object as a soft-lock. So that when any button is pressed, the lock is set to true to stop the user from pressing subsequent buttons. My issue, is how to unlock this lock! I have tried adding the code (currentSession.softlock := false;) to various parts of the populate method but it still runs the OK code. It appears to be the HTML displaying of the data which is causing the delay, and not the Jade source creating the grids. I have tried unlocking it in the "Reply" method of the WebSession subclass as this is the latest point i know of in the process, but again, this did not work.

Has anybody else had a similar problem to this? Sorry if my description above is unclear! It's a simpler system than i have made it sound! If any further details are needed then let me know.

Cheers,

Rich

Re: Temporarily disable buttons on Jade Web Forms

Posted: Fri Aug 20, 2010 5:03 pm
by andy-b
Hi there,

I have done a little bit of Jade but have had no experience with using Jade Web Forms - however I have done a bit of web development.

Is it possible to add custom javascript files to Jade Web Forms?? - if so it seems like you just need some javascript to run in the browser and when the user navigates away from the page (to fetch the next page of data), this can hide or disable the button.

If you can't add custom javascript files to Jade Web Forms then sorry, I haven't helped you at all :(

Cheers
Andy

Re: Temporarily disable buttons on Jade Web Forms

Posted: Fri Aug 20, 2010 8:17 pm
by Rich Cassell
Hi Andy!

Thanks for your reply.

You can define a userScript in a Jade method which i believe can be used for this (anybody know if that is 100% correct...?). Assuming that this can be done, is there any chance you could send me the Javascript for enabling/disabling a control, such as a button? As you may have gathered, i am savvy with Jade but not so great with the web development side! :?

Cheers,

Rich

Re: Temporarily disable buttons on Jade Web Forms

Posted: Mon Aug 23, 2010 9:14 am
by andy-b
Hey Rich

Just did a quick search through the Jade 6.3 documentation (not sure which version you are using but if earlier, hopefully this method is available) and there is a method addWebEventMapping you can probably use in your Jade code.
So to disable an 'OK' button when you click the 'Right' button try this Jade code: (I guess in the load event on your form)

Code: Select all

btnRight.addWebEventMapping("onClick", "document.getElementById('btnOk').disabled = true;");
Just something to be aware of...the getElementById('btnOk') part of the code above, you should replace the btnOK with the id of the button you want to disable, which if you are lucky is the actual id as it is named on your Jade Web Form. But if Jade 'fiddles' with these ids during building the html files it may not actually be the value you want. To double-check, browse to the webpage with the button on it, right-click and view source of the page - search through there until you see the html of the button in question (probably easiest to search for the text on the button), you will hopefully see the button markup, something like <input type="button" id="thisIsTheIdValueYouWant" value="OK" />

Also this assumes that Jade Web Forms follows a postback model and when once clicking the 'Right' button, when the next page of the table is refreshed then the whole page is updated and the OK button will be enabled again - if not will need some other script to re-enable the ok button on the client once the next page of data has been returned. Will probably worry about that when the time comes :)

Would be interested to see if the above script to disable the button works anyway, so let me know how that goes.

Thanks
Andy.