Layouts and AJAX support for JSS

I added in layout support, as well as some fundamental AJAX support for JSS. I’ll put in a tutorial later to show exactly how it’s done, but for now a quick description of how to do layouts in JSS:

Layout support

There is a layouts directory under the views directory which contains a list of all your layouts. For example, let’s say you have a layout file called main.jsp. Your layout file might look something like this, though you can do whatever you like with it:

<%@ taglib prefix=”jss” tagdir=”/WEB-INF/tags”%>
<head><title>JSS Recipe Demo</title>
table {
border: 1px solid black;
body {
font-family: verdana;
table {
border: 1px solid black;
body {
font-family: verdana;
br /> body {
font-family: verdana;

Where you want the content to be placed (i.e. your content) put in the tag <jss:content_for_layout/>. At the top of your controller file (e.g. recipe_controller.jss), after the import statement, put in the layout declaration:

layout = “main”;

where main is the name of your layout file.

That’s all! All your views under this controller will be using this layout. If there are any views you don’t want to have a layout, just put anywhere in your view method:

layout = null;

If you want to use another layout just for that view, you can also set the layout to something else e.g.

layout = “report_layout”;

So what does it do? Using a layout for a controller allows you to enforce the same look and feel or have shared data for all the views under the same controller. This extends to the rest of your web application. I’ll talk a bit more about the AJAX support in another post.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s