Waffle Recipes

How-To's and Tutorials for the ActiveWAFL Framework

How to Generate a .phar File

Posted Mar 3, 2015
by Evan de la Cruz
There are a few of ways to generate .phar PHP archives with ActiveWAFL. We'll cover all of them here. To use the examples on this page, you need to install ActiveWAFL . The examples below assume that you have ActiveWAFL installed at /usr/share/Wafl. You may need to modify the path to reflect your environment. Interactive Command-LineIf you are generating a phar by hand, then this is probably the easiest way to do it. Use the Utensils command-line application to generate the phar. continue reading...

How to Select HTML Elements from Javascript

Posted Dec 17, 2014
by Evan de la Cruz
DblEj provides several global “selector” helper functions for selecting elements in Javascript on the client-side. All selector functions begin with one or two dollar-signs ($ or $$). $… = Singular selector $$… = Plural selector Singular selectors (those that start with one dollar sign) will always return the first matching element. Plural selectors (those that start with two dollar signs) will always return an iteratable nodelist of all the matching elements. $q, $$q - Get continue reading...

How to Secure Model Read/Write Operations

Posted Nov 25, 2014
by Evan de la Cruz
ActiveWAFL provides methods on the client-side for loading and persisting data. While this can be extremely convenient, it can also be a security risk.By default, any web client can connect to your application and issue requests to write data to your database. However, you can leverage ActiveWAFL Model Instance Security , Model Property Security , and/or Client-Side Model Access Security to authenticate those requests before acting on them.All models have a protected field continue reading...

How to Read HTTP Get/Post Variables in an MVC Controller Action

Posted Nov 21, 2014
by Evan de la Cruz
ActiveWAFL controller actions all receive an instance of an HTTP Request object as an attribute. This object provides methods for getting information about the request, including any GET/POST variables submitted via a form or the URL.There are several strongly-typed methods for getting the request variables. These methods all begin with GetInput... . For example, there is GetInputInteger , GetInputString , GetInputBoolean , and so on. There is one method, GetInputArray , for continue reading...

How to Store and Retrieve Custom Application Settings

Posted Nov 20, 2014
by Evan de la Cruz
All ActiveWAFL applications have environment specific configurations that are stored in a Syrup file named "Config/Settings.<environment>.syrp". By default, this file is populated with the basic required settings for an application.If you want to add custom settings, you may add them to any section in the Syrup file. You can then access these settings in your application by using the GetSettingsSection and GetSettingValue methods.Setup a Custom OptionExample segment of continue reading...

How to Allow or Restrict the Reading and/or Writing of Data Models

Posted Nov 20, 2014
by Evan de la Cruz
By default, all data models are readable and writable by all users. You can change this behavior by overriding the DoesCurrentUserHaveWriteAccess and DoesCurrentUserHaveReadAccess methods of the corresponding Functional Model.Allow a Model to be Saved by Providing Write AccessExample Functional Model that allows anyone to read/write any instancenamespace MyApp\FunctionalModel ;   class MyModelClass extends \MyApp\DataModel\MyModelClass { continue reading...

How to Submit a Form Asynchronously via AJAX/API

Posted Nov 19, 2014
by Evan de la Cruz
Posting a form to an API handler is similar to sending other information to an API Handler. The general steps are as follows:Define the API call in APICalls.syrpAdd a server-side API Handler file (or use an existing one) and add an API Handler functionCreate an HTML form that collects the data you wish to submit to the APIHandle the form's submit event and, instead of reloading the page, send the form to the APIHandle the response sent back from the APIIn Javascript, continue reading...

How to Make a Call to Your Application's API

Posted Oct 4, 2014
by Evan de la Cruz
You can call the Api asynchronously or synchronously with Javascript using the following two signatures:Note: The symbols you see below as the function names are _ (single underscore) and __ (double underscore)Asynchronous Ajax/Api Call _ ( string call [ , object requestObject, string sendToken, function callbackMethod, string method, boolean useDefaultJsonParser ] )Synchronous Ajax/Api Call __ ( string call [ , object requestObject, continue reading...

How to Create a New Page in ActiveWAFL MVC

Posted Oct 4, 2014
by Evan de la Cruz
In this example, we'll add a new page to a website running an ActiveWAFL MVC Application.In the instructions and code examples we'll assume that an ActiveWAFL MVC Application is installed at /var/www/vhosts/MyApp, it's root namespace is MyApp , and it is deployed at the domain MyApp.com.Create the Presentation TemplateCreate a new file named /var/www/vhosts/MyApp/Presentation/Templates/MyNewPage.tpl with the following contents.MyNewPage.tpl Presentation Template< h1 continue reading...