mORMot and Open Source friends
View Ticket
Not logged in
2014-11-12
15:06 Fixed ticket [bd94c11ab1]: Implement MVC model (like RoR) in mORMot, for the exact purpose of serving WEB content plus 4 other changes artifact: f1568d1362 user: ab
2014-10-27
15:21
{413} updated MVC/MVVM [bd94c11ab1] documentation check-in: 0d4110cd46 user: User tags: trunk
2014-10-24
19:40
{393} finishing documentation about MVC - [bd94c11ab1] feature request check-in: cdc7ed74b7 user: User tags: trunk
13:25
{392} enhanced thread-safe of our MVC process as requested by [bd94c11ab1] check-in: a068f606ca user: User tags: trunk
2014-10-23
21:28
{387} small fixes about sample 30 for MVC request [bd94c11ab1] check-in: 7369b698b8 user: User tags: trunk
21:27
{386} documentation refresh - including latest mORMot MVC features - see request [bd94c11ab1] check-in: c697a47dc2 user: User tags: trunk
16:05
{383} in our MVC [bd94c11ab1] model, {{TSQLMyRecord.HtmlTable MyRecord}} Mustache tag will now create a HTML table containing all information about the supplied MyRecord fields (from the current data context), with complex field handling - see e.g. {{{TSQLAuthor.HtmlTable Author}}} in AuthorView.html check-in: c802573c64 user: User tags: trunk
2014-10-22
11:39
{374} allow URI level redirection for mORMot MVC - [bd94c11ab1] check-in: 0ed1ebfc44 user: User tags: trunk
2014-10-21
21:11
{371} added some views to the mORMot MVC sample for [bd94c11ab1] - not yet finished check-in: 812812e29e user: User tags: trunk
20:13
{370} fixed cache implementation and added /root/.static pseudo URI to server some static content needed by the views for feature request [bd94c11ab1] check-in: d5f9dbfe1a user: User tags: trunk
2014-10-20
21:05
{363} added cache for mORMotMVC.pas as requested by [bd94c11ab1] check-in: b889a76d6c user: User tags: trunk
17:26
{360} next step for mORMot MVC implementation - for feature request [bd94c11ab1] check-in: 92eb245754 user: User tags: trunk
10:05
{358} mORMot MVC implementation refactoring - for feature request [bd94c11ab1] check-in: 725e2262b1 user: User tags: trunk
2014-10-19
08:08 Ticket [3a79adc10f] FPC support status still Open with 6 other changes artifact: 673112afbb user: ab
2014-10-18
07:58
{354} enhanced mORMot MVC implementation - for feature request [bd94c11ab1] check-in: 0d31663d3b user: User tags: trunk
2014-10-17
16:07
{350} introducing mORMotMVC.pas unit able to implement full MVC web applications, using mORMot ORM for the Model, Mustache templates for Views, and a pretty unique interface-driven way of defining a Controler (just take a look at MVCViewModel.pas unit in sample 30) see feature request [bd94c11ab1] (not yet finished) check-in: fae587bc9d user: User tags: trunk
2014-08-23
14:49 Fixed ticket [48e30e0e05]: Allow incoming parameters to be encoded as a JSON object plus 4 other changes artifact: 4bb669e6cf user: root
14:49
TServiceMethod.InternalExecute() now allows incoming parameters to be encoded as a JSON object, alternatively to a JSON array - see feature request [48e30e0e05] - will also be used probably to implement our MVC model - see [bd94c11ab167] - updated documentation, about this enhancement of transmission content, and about using a CDN service for hosting and scaling check-in: 85b9c26c5e user: User tags: trunk
12:52 Ticket [bd94c11ab1] Implement MVC model (like RoR) in mORMot, for the exact purpose of serving WEB content status still Open with 4 other changes artifact: 38239f651d user: root
08:01 Ticket [bd94c11ab1]: 4 changes artifact: c36224af08 user: root
2014-06-27
10:12 Ticket [bd94c11ab1]: 3 changes artifact: ec26e8c780 user: root
10:12 New ticket [73c1da3c40] UI automatic mapping (via "Mediator" or "MVVM" patterns). artifact: 06b2a4c4a7 user: root
2014-06-10
09:17 Ticket [bd94c11ab1] Implement MVC model (like RoR) in mORMot, for the exact purpose of serving WEB content status still Open with 1 other change artifact: ef63953260 user: ab
2014-04-26
14:33
added {{mustache}} template support for mORMot - high speed pure Delphi logic-less template system, with unique extensions - see feature request [bd94c11ab1] about implementing straight MVC model (like RoR) in mORMot, for the exact purpose of serving WEB content check-in: c3effdb5a0 user: User tags: trunk
2013-11-07
14:17
  • interface-based services will now avoid to transmit the "id":... value when ID equals 0
  • interface-based services can now return the result value as JSON object instead of JSON array if TServiceFactoryServer.ResultAsJSONObject is set: it can be usefull e.g. when consuming services from JavaScript, as will be implemented for feature requests [651c13009b] and [bd94c11ab1]
check-in: baf1521dc9 user: abouchez tags: trunk
2013-11-06
16:48 Ticket [bd94c11ab1] Implement MVC model (like RoR) in mORMot, for the exact purpose of serving WEB content status still Open with 3 other changes artifact: 971325ad54 user: ab
16:48 New ticket [651c13009b] Implement method/interface-based services in JavaScript. artifact: 0e3d3a4a34 user: ab
14:50 Closed ticket [8c8a2a880c]: Custom Authentication classes plus 2 other changes artifact: bb48cc960b user: ab
14:49 New ticket [bd94c11ab1] Implement MVC model (like RoR) in mORMot, for the exact purpose of serving WEB content. artifact: a7f97fce37 user: ab

Ticket Hash: bd94c11ab167d0a075fa1c3918b60f2c2fdd0b85
Title: Implement MVC model (like RoR) in mORMot, for the exact purpose of serving WEB content
Status: Fixed Type: Feature_Request
Severity: Important Priority: High
Subsystem: mORMot Resolution: Implemented
Last Modified: 2014-11-12 15:06:39
Version Found In:
Description:
We would like to introduce a new MVC model (like RoR) in mORMot, for the exact purpose of serving WEB content.

Note that a generic caching mechanism should be made available, to improve service responsiveness. This cache may be handled at View level, and/or at Controller level, depending on the business logic.

Model

The MODEL would be the main mORMot's ORM model.

Controller

The CONTROLLERS would be dedicated classes (inheriting from an abstract TMVCController class), which will compute the data to be viewed within:

  • method-based services (published methods of the controller class);
  • or interface-based services (implemented by the controller class).

Output of the controller would be a JSON object, similar to the Mustache HASH:

{
  "header": "Colors",
  "items": [
      {"name": "red", "first": true, "url": "#Red"},
      {"name": "green", "link": true, "url": "#Green"},
      {"name": "blue", "link": true, "url": "#Blue"}
  ],
  "empty": true
}

To compute this JSON object, we would expect the following:

  • For method-based services, it may be directly emitted as raw JSON;
  • For interface-based services, this object may be created from the list of OUT parameters of the method (i.e. the interface should be able to serialize its result not as a JSON array, but as a JSON object including the parameter names).

All server-side methods (ORM and services) would be usable to compute the resulting JSON object.

View

The VIEWS would be dedicated classes (inheriting from an abstract TMVCView class) for rendering the JSON object as computed by the CONTROLLERS into HTML or any other mean.

We propose to implement:

  • JavaScript kind of view (via our SpiderMonkey integration), which would be able to generated e.g. HTML or PDF reports (via a dedicated service publishing the most common methods of TGDIPages via an interface);
  • Mustache kind of view (implemented at first via JavaScript library, potentially in a more optimized way - pure Delphi - in the future, even if the JavaScript implementation is pretty powerful, since it allows inlined scripting) - both ORM operations and interface-based services would be available within Mustache;
  • any custom kind of view model, e.g. Razor-like or Lua-like - but I guess that such kind of rendering would be unneeded, since high-level scripting tends to put some logic in the View, which should better stay within the Controller.

Typical Mustache template may be:

<h1>{{header}}</h1>

{{#items}}
  {{#first}}
    <li><strong>{{name}}</strong></li>
  {{/first}}
  {{#link}}
    <li><a href="{{url}}">{{name}}</a></li>
  {{/link}}
{{/items}}

{{#empty}}
  <p>The list is empty.</p>
{{/empty}}

Which may be rendered as such:

<h1>Colors</h1>
<li><strong>red</strong></li>
<li><a href="#Green">green</a></li>
<li><a href="#Blue">blue</a></li>
<p>The list is empty.</p>

Mustache has some nice features, like partial templates (which are some kind of "include"), and the ability to execute a function (see lambdas in its manual) before rendering the content.


ab added on 2014-06-10 09:17:12 UTC:
Some feedback and proposals in forum thread. Worth the discussion.

User Comments:
root added on 2014-06-27 10:12:54:

Linked to [73c1da3c401eccaf0c], which is similar to this feature request, but for Delphi VCL/FMX UI.


root added on 2014-08-23 08:01:12:

This model is pretty close to the MVC implemented in AngularJS.

Our data context is indeed the same "glue" between the view and the controller.
The AngularJS' $scope has the same exact purpose.

See the Angular official tutorial for details about it.


root added on 2014-08-23 12:52:35:

[48e30e0e05] feature request did let TServiceMethod.InternalExecute() incoming parameters be encoded as a JSON object, alternatively to a JSON array.

Here, the same rules applies all all routing mode:

  • Any missing parameter will be replaced by its default value;
  • Properties order is not sensitive any more;
  • Unexpected parameters will just be ignored.

This feature request may be used directly in our MVC model: the incoming parameters of the controllers or the view may be defined as a JSON object, and TServiceMethod.InternalExecute() will use only the needed parameters.

Since the MVC feature would most of the time be executed in the same process, on the server side, having a whole context supplied to the method won't be a problem. Process cost on the server side will be negligible, since our implementation will just ignore those unexpected properties, without allocating any memory for them.


ab added on 2014-11-12 15:06:39:

I suspect we reached some point of stability of this feature request.

See the corresponding documentation available online.

Any further modifications may be handled as separate bug fix or feature request tickets.