4.5 client-serverside scripting

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

HarryDeBoer
Ebase User
Posts: 118
Joined: Tue Oct 23, 2012 7:01 am
Location: The Netherlands

4.5 client-serverside scripting

#1

Postby HarryDeBoer » Tue Jul 23, 2013 9:41 am

Hi,

I really like the concept of 4.5 for client-server js interaction. Read the docs, but the implementation I find a little hard (it's new :)). I have a button which must fire an event to update a table. On error -invalid input- I want a (eg jqueryui) dialog to show what's wrong. The validation is a serverside script function which must return the error (or if it's valid a confirmation) message to be used in the dialog.

How to achieve this?

Kind regards, Harry
0 x
Kind regards,

Harry

LKirby
Ebase User
Posts: 37
Joined: Wed Mar 13, 2013 11:33 am
Contact:

#2

Postby LKirby » Tue Jul 23, 2013 12:27 pm

As you're already looking at using a JQuery UI dialog why not do it the normal way before 4.5? :P (assuming you've attached the JQuery core + UI js files and a ui stylesheet)

Have a look at this post:
http://forum.ebasetech.com/forum/viewtopic.php?t=409

Or here's another example:

create a field and under the HTML element properties, under the editor tab, give it the class 'dialogText'
in a server side script attached to your update table button, after doing the validation and find theres an error, add the following:

Code: Select all

fields.result.value = "Message you want to display";
fields.RESULT.getFieldControl().show(); // show the control displaying the field. you could also use controls.FIELDCONTROLx.show(); 
In the HTML properties for that field, (with a css property of display: none;)

Code: Select all

$('.dialogText').dialog({
        title: "My Super Awesome Dialog",
        modal: true,
        buttons: {
            "Yes": function () {
                $( this ).dialog( "close" ); // closes the dialog
               $('#updateForm').trigger('click'); // triggers another button on the form with an id of updateForm
            },
            Cancel: function () {
                $( this ).dialog( "close" );
            }
        }
    });
Whether you use Wai's example (http://forum.ebasetech.com/forum/viewtopic.php?t=409) or the one above, they should both do the trick ;)

Or using 4.5's new features:
Have you looked at the Client API tutorial at: ?
http://dev-docs.verj.io/ufs/doc/Working ... y_Step.htm
You could follow tutorial that but create a client callable server side script that validates the user input, return an error message if there is one or the string "success" if the input was valid, and use this to create a dialog based on that using something like:

Code: Select all

var result = $eb.executeFunction("validateUserInput", ...); 
if(result !=="success"){
	$&#40;"<p>" + result + "</p>"&#41;.dialog&#40;&#123;
			 modal&#58; true,

			 buttons&#58; &#123; 
				"Ok"&#58; function&#40;&#41; &#123; 
					$&#40;this&#41;.dialog&#40;"close"&#41;;
				&#125;, 
				Cancel&#58; function&#40;&#41; &#123;
					$&#40;this&#41;.dialog&#40;"close"&#41;;
				&#125;	
			&#125;       
			&#125;&#41;;
&#125;
Hope this helps!
Luke
0 x


Who is online

Users browsing this forum: No registered users and 6 guests