Skip to content
joris hermans edited this page Jan 25, 2015 · 4 revisions

ForceMVC is a serverside application stack that helps you with creating model view controller logic.

Basically you can create a server.dart file with the following content.

library my_new_force_mvc_app;

import 'dart:io';
import 'package:forcemvc/force_mvc.dart';

void main() { 
  // Create a force server 
  WebApplication webApp = new WebApplication();
  
  // Start serving force with a randomPortFallback 
  webApp.start(fallback: randomPortFallback);
}

Then you can start working on your controller.

part of my_new_force_mvc_app;

@Controller
class AboutController {
  
  @RequestMapping(value: "/about/")
  String aboutPage(req, Locale locale, Model model) {
    model.addAttribute("locale", locale.toString());
    return "about";
  }
  
}

Add AboutController as part of my_new_force_mvc_app in server.dart.

part 'controller/aboutcontroller.dart'

In your web folder or your view folder create the about.html file. You can put {{locale}} into the page to display the locale to the user. The "locale" variable sits in your model so you can use it on your page.

Please run 'pub build' or go to 'Tools > pub build (generate js)' before you continue. It will then generate a build/web folder that will be consumed by ForceMVC!

Advanced

Clone this wiki locally