Polymer - Call a service as part of custom field validator

Hi,

We have a Cuba application that we want to add Polymer UI. In the Cuba application we have a created a service method that is called as part of custom data validation on input fields.

I’ve added the service and the method to the polymer edit screen (using the cuba-service). I can display the output to elements on the screen (as described in the documentation).

My question is: How do I use the method (of the service) as part of a custom validation on input elements ?

Regards.

Martin Oosthuizen

Hi,
You can call a service method imperatively in the following way:

<paper-button on-tap="_validateAndSave" ... 

... 
Polymer({ 
... 
  _validateAndSave: function() { 
    this.app.invokeService('serviceName', 'validationMethodName', this.params, {handleAs: 'json'})
    .then(function(validationResult) { 
      if (validationResult.passed)  { 
        this._save(); 
      } else { 
        //show error 
      } 
    }.bind(this)); 
  } 
2 Likes