Super Basic functionality advice

Forum to discuss the new web client version of Servoy.

Super Basic functionality advice

Postby Gordon McLean » Thu Nov 26, 2015 4:20 pm

I am looking for some super basic advice on how NG Components interact with Servoy

1) I want to call a Servoy form function from a component

2) I want to pass a variable or call a function within a service

In various posts I have seen things like "svyServoyapi" are these items built in and if so is there a list anywhere as I have thus far hit the wall on finding anything in the wiki.

I guess the fundamental problem is my understanding of the concept of NG Client and components is not yet at a point the wiki is making any sense. Ironically I can do all of this is raw angular which rather defeats the object of Servoy sadly

help much appreciated


I have a simple button component that outputs a message to the console - so this function works

html:
Code: Select all
<div><button class="btn btn-info" ng-click="onClick($event)">test</button></div>


Spec:
Code: Select all
{
   "name": "gordon-test-Button",
   "displayName": "testButton",
   "version": 1,
   "definition": "gordon/testButton/testButton.js",
   "libraries": [],
   "model":
   {
      "yourName" : {"type": "string", "default":"World"}
   }
}


JS File:
Code: Select all
angular.module('gordonTestButton',['servoy']).directive('gordonTestButton', function() { 
    return {
      restrict: 'E',
      scope: {
         model: '=svyModel',
        handlers: "=svyHandlers",
          api: "=svyApi",
          svyServoyapi: "="
      },
      controller: function($scope, $element, $attrs) {
      },
      link: function (scope, element, attrs) {
        
          scope.onClick= function (event) {
             console.log('Button clicked')
             //scope.svyServoyapi.apply('dataProviderID');
        };
      },
      templateUrl: 'gordon/testButton/testButton.html'
    };
  })
Gordon McLean
Clickdigital.com
Gordon McLean
 
Posts: 253
Joined: Wed Aug 03, 2005 12:24 pm
Location: UK

Re: Super Basic functionality advice

Postby sbutler » Thu Nov 26, 2015 6:16 pm

I'd suggest reviewing the source code of the components that are included with Servoy: https://github.com/Servoy/servoy-client ... client/war
I've also made a sample on Servoy Forge: https://www.servoyforge.net/projects/se ... nents/wiki

In your model, you need to define some handlers, like the "onActionMethodID" here: https://github.com/Servoy/servoy-client ... utton.spec

Then in your HTML, you can use
Code: Select all
svy-click='handlers.onActionMethodID($event)'
like this: https://github.com/Servoy/servoy-client ... utton.html

By defining it in the Model, it will show up in the Properties area in Servoy Developer. So you can assign whatever function you want to that onActionMethodID. Then it gets triggered in the HTML.
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: Super Basic functionality advice

Postby Gordon McLean » Fri Nov 27, 2015 9:21 am

goldcougar wrote:I'd suggest reviewing the source code of the components that are included with Servoy: https://github.com/Servoy/servoy-client ... client/war
I've also made a sample on Servoy Forge: https://www.servoyforge.net/projects/se ... nents/wiki

In your model, you need to define some handlers, like the "onActionMethodID" here: https://github.com/Servoy/servoy-client ... utton.spec

Then in your HTML, you can use
Code: Select all
svy-click='handlers.onActionMethodID($event)'
like this: https://github.com/Servoy/servoy-client ... utton.html

By defining it in the Model, it will show up in the Properties area in Servoy Developer. So you can assign whatever function you want to that onActionMethodID. Then it gets triggered in the HTML.


Thanks Scott and Paolo@servoy, I had forgotten, or more to the point not fully understood, that a custom component was a stand alone object in its own right. This custom object is not part of your Servoy solution more an enhancement that is added to Servoy developer that you can incorporate in all your solutions. As an example this could be a multi function custom button with your own design tweaks.

For the benefit of others Servoy 8 and the NG Client can be used in exactly the same way as Servoy 7 with the massive advantage its a LOT more versatile, easier to debug and potentially a lot faster.

Thanks again guys appreciated and REALLY looking forward to @ServoyUniversity training for version 8 !!

Gordon
Gordon McLean
Clickdigital.com
Gordon McLean
 
Posts: 253
Joined: Wed Aug 03, 2005 12:24 pm
Location: UK


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 1 guest

cron