Knowledge Base
  • Introduction
  • Events and Actions
  • Action Panel
  • sending email
  • calling a SQL action from a client side js action
  • Accessing to translations form a server
  • Executing SQL statements from within an action
  • How to invoke a generic SQL statement defined through a SQL action
  • How to show a message dialog
  • checking for "undefined" values
  • How to add spaces to the right of a text
  • How to create a docx report and show it on the web browser Enterprise Edition only
  • How to get or set a value from the graphics control
  • How to invoke a generic SQL query defined through a business component
  • How to remove spaces to the left and right of a text
  • How to support multiple themes in a single application, accoding to a rule
  • How to set content to a Google Map linked to a grid or form
  • How to replace all occurences of a pattern from a text
  • Utility methods
  • Link auto login
  • Creation of a link for the first access of a new user without give the user a password and forcing
  • Forgot password
  • setting up default values from values coming from a filter panel
  • identifing the modified record after the alteration
  • enabling/disabling checkboxes in a grid
  • Filtering a Lookup
  • formatting a column
  • using checkboxes to select rows in grid
  • showing a summary row in grid
  • Disabling a toolbar button
  • Configuring grid exports
  • Adding filter conditions to a grid
  • Filtering the grid content from a tree
  • Filtering the tree content, starting from a filter panel linked to a grid
  • collapsing a panel
  • validating a lookup
  • accessing the authorizations set for a specific grid
  • How to design a web service
  • How to remotelly invoke an action or business component or perform a write operation through a Restf
  • how to feed a grid from a JS business component
  • converting a JS object to a JSON string
  • executing a query
  • passing parameters to a server side JS action
  • return value
  • scheduling and frequency
  • finding the right filter panel
  • checking out if a component has been defined
  • Deploying an application
  • Enquiring a table belonging to the Platform repository
  • Adding a where clause to a business component linked to grid
  • Integrating Mailchimp lists
  • Formatting a number as a currency value to use it inside an email template
  • sending email from a template
  • How to send an email
  • Error 'smtpHost' is empty
  • Linking two windows
  • How to open manually a window from another window
  • How to open manually a popup window
  • How to hide a panel in a window dinamically
  • How to manage folder panels
  • How to manage card panels
  • Predefined variables supported by Platform
  • Accessing the application parameters
  • Application Log
  • How to design a web service
  • How to import java classes in server
  • How to import java classes in server
  • How to dynamically set a value on a combo
  • 4WS.Platform
  • How to listen to events in a mobile HTML panel
  • Issues with HTTPS requests
  • How to manage row totals in grid
  • How to send to the UI a notification to execute code automatically
  • How to filter a chart by date interval
  • How to filter a grid by date interval
  • How to read a text or csv file and save data on the database
  • How to write text or csv files
  • Reading an xls file stored in the specified path
  • How to create a report with Jasper Report
  • How to customize the alert message content
  • Setting up a cluster
  • Uploading and downloading files
  • How to listen to user definition changes
  • How to auto-show a window from login
  • How to manage encrypted fields
  • How to change CSS settings for a grid row
  • Customizing a Tree Panel
  • How to execute complex queries on Google Datastore
  • Theme customization
  • Retrieve and send the log of a mobile app
  • Import Roles and Users
  • How to synchronize multiple Form panels in the same window
  • Anchor buttons
  • Properties of subpanels
  • Bulk import
  • How to display the data not found message in a grid
  • How to setup an LDAP based authentication
  • How to synchronize data from Datastore to BigQuery
  • How to synchronize data from Datastore to Google Spanner
  • How to synchronize data from Datastore to CloudSQL
  • Scrollable form list
  • How to setup SAML authentication
  • How to export data from BigQuery in streaming
  • Update Google Spreadsheet
  • How to setup OAuth2 authentication
Powered by GitBook
On this page

Was this helpful?

How to design a web service

Platform allows you to create web services which can be invoked externally. A web service is implemented through a server-side js action. In order to access it, an authentication task is needed: only when the authentication step passessuccessfully, the server-side js action is called. The default behavior of a Platform web service is to load also parameters and authorizations connected to the logged user. That means that an overhead is required to fetch additional information and several seconds are spent for that activity. You can by-pass this additional task through the “onlyLogin” parameter (see How to remotelly invoke an action) which reducesthat overhead to the minimum. That means the invoked web service will act as a stateless web service. Every additional data required by the web service must be passed as an input parameter or fetched internally to the service. The perk of this solution is that the web service will be very fast. The drawback is that additional data needed by the web service to work must be included within the web service and this will reduce its performance. A good web service design passes through the use of stateless web services, combined with the data retrieval of additional information, stored in a cache, so that the additional data is retrieved only once and then stored in such a cache, whichcan be accessed any number of times in the future, to speed up the data retrieval. Platform provides a global mem-cache, composed of a setof key-value couples. You can store up to 1000 different entries. That limit is needed to ensure thatthe cache will not consume too much memory. The problem with a cache is the memory consumption: a better performance is achieved through a higher consumption of memory and this usage must be carefully managed. Platform mem-cache must be managed programmatically, through a series of js methods available within the server-side js action:

  • utils.addValueInCache(String varName,Object value) –Add a value to the shared web cache, with no expiration time for that variable

  • utils.addValueInCache(String varName,Object value,Long expirationTime) –Add a value to the shared web cache. Optionally, specify an expiration time for that variable, expressed in minutes. In this way, the content of the cache will reduce automatically

    utils.removeValueInCache(String varName) – Remove an entry from the cache

var value = utils.getValueInCache(String varName)– Read a valore from the cache. If the variable is stored in cache, it returns the corresponding value, otherwise an exception will be fired var value = utils.getValueInCache(String varName,String alternativeFunctionName) –Fetch a value from the shared web cache. In case the specified variable name is not found in cache, then execute the js function and get back the returning value, which is also stored in cache. The alternativeFunctionName must be a string value, not directly the function (see the example below) var value = utils.getValueInCache(String varName,String alternativeFunctionName,Long expirationTime) –Fetch a value from the shared web cache. In case the specified variable name is not found in cache, then execute the js function and get back the returning value, which is also stored in cache. The alternativeFunctionName must be a string value, not directly the function (see the example below). An expiration time is also specified

Important note: it is up to you ensuring the correct contentof the cache. For instance, if an application parameter is changed externally, the cache is not able to figure it out and it could contain not up-to-date content. This is not a wrong behavior of the cache: you have to take into account this chance and apply the correct management for such event, such as setting an expiration time for every data fetched and stored in the cache.

This is an example of how to use the cache:

var getParam1 = function() {
  return utils.getParameter("PARAM1");
}

var param1 = utils.getValueInCache("P1","getParam1",60);
/* a param P1 is stored in cache, initially set with the value of the PARAM1 parameter, fetched as a parameter defined externally (global or application level parameter). An expiration time is set to one hour */

// now I can use param1...
PreviousApplication LogNextHow to import java classes in server

Last updated 5 years ago

Was this helpful?