Skip to content

First Steps

Christophe Brasseur edited this page Oct 15, 2016 · 7 revisions

You can find here some first steps to get how to use this framework.

Considerations

This framework adds a better Controller layer into the MVC concept. The standard JEE platform provides servlets and JSP, but not the concept of pages that you'll find in any websites.

A "Controller" in this framework is simply a page. A controller could be inherited to encapsulate some mechanics of specific pages, like pages that requires a login from the user. It allow the wrap of generic considerations of your website inside inheritances of pages.

First step : Install the framework

Please see [this document](Quick Install) to install the framework and setup the project.

Second step : Create a welcome page

Let's tell you want to create a "welcome" page. Create a new class that extends Controller :

@CPath(path = "index.html")
public class WelcomePage extends Controller
{
  @Override
  public void build(Template tpl)
  {
      tpl.display("/WEB-INF/welcome.jsp");
  }
}

This way, you tell the system to link the "index.html" page to this class. In the build method, we tell the system to use the welcome.jsp file to render the result. This file is a standard JSP, where you can use JSP static or dynamic includes, JSTL, etc.

Third step : Link a variable between the page class and the JSP

If you want to link a variable value and display it into the JSP file, let's make a small modification.

@CPath(path = "index.html")
public class WelcomePage extends Controller
{
  @Override
  public void build(Template tpl)
  {
      tpl.assign("maVariable","Hello World!");
      tpl.display("/WEB-INF/welcome.jsp");
  }
}

In your JSP file, just call the ${} token :

<html>
  <head></head>
  <body>
    <h1>${maVariable}</h1>
  </body>
</html>

Fourth step : Advanced usage

Please see the Wiki documents for more advanced usages.

Clone this wiki locally