-
Notifications
You must be signed in to change notification settings - Fork 0
First Steps
You can find here some first steps to get how to use this framework.
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.
Please see [this document](Quick Install) to install the framework and setup the project.
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.
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>
Please see the Wiki documents for more advanced usages.