Example 003: Variety of requests

In this example you can see different types of requests used in Pomegranate Framework. In order for this example, to work properly, you need to follow the first and second steps and the remaining of steps can be used in any order desired.

  1. Requesting a controller:
  2. Controllers are active parts of a system. They hold the logic of the aimed functionality. Each controller may have serveral other child controllers or views within it. Controllers are responsible for creating and populating views and also showing them. They retrieve data from services and also call them for sending data to the server.

  3. Requesting a view:
  4. A view is a user interface mostly written in HTML. Views show the data ingested to them by controllers and gather user data and pack them for controllers to be sent to the server. Each view is a child to eactly one cotroller and each controller may have zero to many views.

  5. Requesting a model:
  6. Models are data transfered between server and client. Even though they can be in any form, we mostly send them in JSON format. Model data are passive in Pomegranate Framework, which means they have no methods or routines. They just have data in one of the following types: string, numeric, arrays or objects. Arrays and objects are compond types which may contain several other named types.

  7. Requesting multiple models at the same time:
  8. As a special case, you may want to load model from serveral different services before you proceed. This way of calling services is identical to calling each service separately and calling the 'proceed' routine with all their responses, once they are all retrieved.

  9. Sending a command:
  10. Sending a command is a service call just like retrieving a model. They only differ logically, as model calls aim to retrieve data while commnad aim to send them. They are also different in the way framework treats them. Model requests might be packed into one requests if the corresponding option is enabled, which may delay their retrieval. But command requests are always sent immidiately and individually.

  11. Requesting a resource:
  12. A resource is a file loacated on the server. It might be an image file or a javascript. Resources are meant to be cached unless it is specified otherwise.