Introducing Apstrata

Introducing Apstrata

Cloud based, on demand, Back-end as a Service

Are you tired of re-inventing the wheel? Are you a web developer who would like to focus on solving the business problems and not have to worry about the nitty gritty details for the n-th time? Well this is where Apstrata comes in. Apstrata is a back-end as a service solution, providing the building blocks needed for you to build you application.

What you get out of the box is a Document Based Store which takes care of your database needs and worries, a Messaging system for email and push notifications, a CMS for managing your content and static pages, along with other features that will expedite developing your web or mobile application. For more info check out the wiki. Apstrata is a client-server cross-platform application, kind of a la Lotus Notes (you didn’t expect to hear that, did you?) but for web applications. It also comes with its own Dev Console where you can build and test scripts, schemas, and queries.

The benefits of using a solution like Apstrata is the ability to use the out of the box user management that comes baked in, as well as the widgets such as the login widget and the registration widget that let you get up and running in no time. Apstrata is built on top of Dojo, and provides you an API to use on your client side to hook into. Here’s an example of how you can extend the registration widget to create your own:


dojo.provide("tourtwist.ui.widgets.TwistRegistrationWidget")

dojo.require("dojox.dtl._Templated")
dojo.require("apstrata.ui.forms.FormGenerator")
dojo.require("apstrata.ui.FlashAlert")

dojo.require("apstrata.sdk.Client")
dojo.require("apstrata.sdk.Connection")
dojo.require("apstrata.ui.widgets.RegistrationWidget");

dojo.requireLocalization("apstrata.ui.widgets", "registration-widget")

/**
 * Extended version of User registration widgets. 
 * 
 * @param {Object} attrs
 */
dojo.declare("tourtwist.ui.widgets.TwistRegistrationWidget",
[apstrata.ui.widgets.RegistrationWidget],
{
  // This is the new definition
  definition: {
    label: "User",
    cssClass: "newClass",
    fieldset: [
      {name: "required", label: "", type: "subform", style: "form", cssClass:"column",
        fieldset: [
          {name: "first_name", label: "First Name", type: "string", required: true},
          {name: "last_name", label: "Last Name", type: "string", required: true},
          {name: "email", label: "Email", type: "string", required: true},
          {name: "country", label: "Country", type: "string", required: true},
          {name: "password", label: "Password", type: "password", required: true},
          {name: "confirmPassword", label: "Confirm Password", type: "password", required: true, attrs: {invalidMessage: "Passwords don't match"}},
        ]
      },
    ],
    actions: ['save', 'cancel']
  },


  // override the postCreate function
  postCreate: function() {
    // Let the parent class handle all the creation work
    this.inherited(arguments);

    // FormGenerator class has an "onAction" method that is called when an action is clicked. We connect to it
    // in order to re-route the event to the cancel function we need to add to the parent class
    dojo.connect(this.form, "onAction", this, "_onAction");
  },

  // this function is called every time an action (button) is clicked on the widget
  _onAction: function(action, values) {
    if (action == "cancel") {
      this.cancel(values);
     }
  },

  // cancellation logic.  
  cancel: function(values) {
    this.form.frmMain.reset();
  }

})

In the example above, we define what are the fields that we want to capture in the registration process and Apstrata takes care of the rest by injecting the appropriate form using Javascript on the client side into your page which then submits the data to an Apstrata script that you store on the server side that will handle the registration process (I use the out of the box example script that comes with the SDK, with a minor modification of concatenating the first name and last name into the name field which is required by Apstrata)

N.B.: Apstrata is still a young platform, but as it matures it shows good promise for next generation in the cloud services.

Tags

Like this Article? Share it!

About the Author

Author Gravatar
Youssef Chaker

web developer, problem solver, doer, for everything else follow me at @ychaker

Related Posts

Comments are closed.