What is a gadget?

A gadget is an enhancement or addition to your website.

Any gadget will be using a model which will return the data in different formats: arrays, integers, strings, booleans, etc.

Think of a gadget as a module. For example, imagine that you are running a Point of Sale in Jaws, so, to run this Point of Sale you need some sections: once to manage your sales, another for customers, another for accounting, etc. Each of this sections are what we call a gadget.

In our case some gadgets are: Blog, Phoo, FileBrowser?, etc.

What is a gadget from the MVC point of view?

You can get confused with some terms we manage in Jaws. We’ve defined a gadget. Now here comes the definition of a gadget from the MVC point of view (remember that Jaws uses MVC as a design pattern).

If you read the documentation of MVC, you must know that any application based on this pattern must have: controllers, views and models. In Jaws the view for the HTML view (what you see in your browser) is named: gadget.

To be more clear, lets suppose you have a gadget (a section) for your customers:

  • First of all, you need a directory named Customers inside gadgets directory (for example: html/gadgets/Customers).
  • Inside that directory (html/gadgets/Customers) you will have some other files and directories: CustomersModel?.php (the model, CustomersRestWebservice?.php (the REST webservice) and Customers.php, this last one will be the gadget, that you will see JUST in your browser.

As you have seen, the Customers.php will be the gadget file, the HTML view.

If you are going to develop a gadget, there are some rules for gadgets:

  • The directory where you have your gadget must be of the same name. So if your gadget’s name is Customers, then your gadget’s directory is going to be: Customers.
  • Your gadget’s file (HTML view) needs to have the same name, so again, if your gadget’s name is Customers, then your gadget’s file is going to be: Customers.php and must be inside Customers directory (inside gadgets/ directory).