Layout

Verona utilizes JSF templating APIs and provides a main template.xhtml along with additional topbar, menu, footer fragments for the base layout. These xhtml files must be placed under WEB-INF folder and client pages should reference the template.xhtml as their template. Provided empty.xhtml is a sample content page using the main template.xhtml that defines "content" as the main ui:define placeholder. By default template defines 3 placeholders (page title, header content and actual content)to insert content and you can add more as per your requirements.

Sample page below uses the main template from Verona.

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/template.xhtml">
                
    <ui:define name="title">Test Page</ui:define>

    <ui:define name="content">
        Content goes here
    </ui:define>
</ui:composition>

Other required resources are the css, js and images that are located inside resources/verona-layout folder, simply copy the verona-layout folder to your %WEB-APP-FOLDER%/resources folder so that final path would be %WEB-APP-FOLDER%/resources/verona-layout/. Please refer to demo app or maven project of the demo app as the reference.

GuestPreferences Bean

GuestPreferences is a simple session scoped bean to keep the user customizations of the layout, template xhtml files refer to this bean to dynamically change their behavior such as menu mode or theme. This bean is not necessary to run the Verona and only used for demo purposes. For example template.xhtml includes layout color depending on a user preference using an EL expression.

<h:outputStylesheet name="css/layout-#{guestPreferences.layout}.css" library="verona-layout" />   

In your application, you may also need a similar bean to make the template dynamic or choose a static color with;

Source code of GuestPreferences.

public class GuestPreferences implements Serializable {

    private String layout = "dark";
        
    private String theme = "green";
    
    private boolean overlayMenu = 'horizontal';
                
	public String getTheme() {		
		return theme;
	}
    
	public void setTheme(String theme) {
		this.theme = theme;
	}
    
    public String getLayout() {		
        return layout;
    }
    
    public void setLayout(String layout) {
        this.layout = layout;
    }
        
    public boolean isOverlayMenu() {
        return this.overlayMenu;
    }
    
    public void setOverlayMenu(boolean value) {
        this.overlayMenu = value;
    }
}

Theme

Verona provides 7 PrimeFaces themes out of the box, setup of a theme simple as including the theme jar in your classpath and defining primefaces.THEME context parameter in web.xml such as "primefaces-verona-green". Full list of available themes are;

  • primefaces-verona-amber
  • primefaces-verona-blue
  • primefaces-verona-bluegrey
  • primefaces-verona-green
  • primefaces-verona-purple
  • primefaces-verona-teal
  • primefaces-verona-turquoise

A custom theme can be developed by the following steps.

  • Create a custom theme folder such as primefaces-verona-myown under webapp/resources and place an empty theme.scss inside.
  • Copy the sass folder from the distribution to webapp/resources.
  • Define the variables listed below and import the /sass/theme/_theme.scss file.
  • Build the scss to generate css.
  • Set primefaces.THEME context parameter as verona-myown
  • Either bundle the css in a jar file or serve from webapp/resources/primefaces-verona-myown folder

Here are the variables required to create a theme.

$primaryColor:#9fd037;
$highlightTextColor:#ffffff;
$buttonTextColor:#ffffff;
$inputFocusBgColor:#e0f6b1;

@import '../sass/theme/_theme';

An example sass command to compile the css would be;

sass src/main/webapp/resources/primefaces-verona-myown/theme.scss src/main/webapp/resources/primefaces-verona-myown/theme.css  --sourcemap=none

Watch mode is handy to avoid compiling everytime when a change is made, instead use the following command so that sass generates the file whenever you make a customization. This builds all css files whenever a change is made to any scss file.

sass -w src/main/webapp/resources/ --sourcemap=none

Same can also be applied to layout itself;

  • Choose a layout name such as layout-myown.
  • Create an empty file named layout-myown.scss inside resources/verona-layout/css folder.
  • Copy the sass folder from the distribution to webapp/resources.
  • Define the variables listed below and import the /sass/layout/_layout.scss file.
  • Build the scss to generate css
  • Serve the css by importing it using a link tag or h:outputStylesheet.

Here are the variables required to create a layout

$topbarLeftBgColor:#3b3b48;
$topbarRightBgColor:#3b3b48;
$menuBgColor:#525262;
$menuItemTextColor:#d1d1e4;
$menuItemHoverBgColor:#6a6a7d;
$menuItemHoverTextColor:#d1d1e4;
$menuButtonBgColor:#62626c;
$menuButtonHoverBgColor:#e96d66;
$menuButtonActiveBgColor:#e96d66;
$topbarMenuItemBadgeBgColor:#e96d66;
$topbarMenuItemBadgeTextColor:#f0d1d0;

@import '../../sass/layout/_layout';

In case you'd like to customize the structure not just the colors, the _variables.scss is where the structural variables (e.g. font size, paddings) for the layout are defined.

/******************************/
/*           Common           */
/******************************/
$fontFamily: "Lato","Helvetica Neue",sans-serif;
$fontSize:13px;
$textColor:#2d353c;
$textSecondaryColor:lighten($textColor,25%);
$borderRadius:2px;
$dividerColor:#dce2e7;

/******************************/
/*           Layout           */
/******************************/
$bodyBgColor:#eaeff2;
$footerBgColor:#dee0e3;
$appNameTextColor:#ffffff;
$searchInputBgColor:#f5f8f9;
$searchInputBorderColor:#f5f8f9;
$searchInputFocusBorderColor:#a8b4be;
$menuItemActiveTextColor:#ffffff;
$cardBgColor:#f7f9fa;

/******************************/
/*           THEME            */
/******************************/

/* Icons */
$iconFontSize:13px;
$iconWidth:16px;

/* Headers */
$headerPadding:6px 12px;
$headerBgColor:#f5f8f9;
$headerTextColor:#2d353c;
$headerHoverBgColor:#dcdfe0;
$headerBorderColor:#dce2e7;
$headerIconColor:lighten($textColor,25%);
$headerIconHoverColor:#2d353c;

/* Contents */
$contentPadding:6px 12px;
$contentBorderColor:#dce2e7;
$contentBgColor:#f5f8f9;

/* Forms */
$inputBgColor:#ffffff;
$inputPadding:4px;
$inputBorderColor:#dce2e7;
$inputHoverBorderColor:#a8b4be;
$inputInvalidBorderColor:#e13131;

/* Buttons */
$toggleButtonBgColor:#c6cbcf;

/* List Items */
$listItemPadding:6px 12px;
$listItemHoverBgColor:#dce2e7;
$listItemHoverTextColor:#525262;

/* Messages */
$infoMessageBgColor:#e0f6b1;
$infoMessageTextColor:#7fb30f;
$warnMessageBgColor:#fff1ae;
$warnMessageTextColor:#f7b000;
$errorMessageBgColor:#f0d1d0;
$errorMessageTextColor:#e96d66;
$fatalMessageBgColor:#afafc0;
$fatalMessageTextColor:#3b3b48;

/* Data */
$paginatorBgColor:#ffffff;
$paginatorHoverBgColor:#dce2e7;
$datableOddRowBgColor:#ffffff;
$datatableHoverBgColor:#dce2e7;

/* Menu */
$menuHeaderBgColor:#dcdfe0;
$menuHeaderHoverBgColor:#c4c6c7;

/* Predefined Colors */
$blue:#3ebaf8;
$orange:#f7cb00;
$purple:#985edb;
$pink:#f18983;
$green:#9fd037;
$black:#525262;

Layout and Theme Combinations

Verona has 14 built-in layout colors and 7 themes, following are the suggested combinations.

  • Dark layout with all themes.
  • Blue layout with amber and blue themes.
  • Turquoise layout with amber, turquoise and purple themes.
  • Green layout with teal, amber and purple themes.
  • Rose layout with purple, green, turquoise and amber themes.
  • Teal layout with green, turquoise, amber and purple themes.
  • BlueGrey layout with all themes.
  • Cosmic layout with all themes except purple.
  • Beach layout with turquoise, amber and teal themes.
  • Flow layout with turquoise, amber, blue and teal themes.
  • Fly layout with purple, turquoise, blue, green and amber themes.
  • Nepal layout with green, turquoise, purple and amber themes.

Menu

Menu is a regular JSF component that supports PrimeFaces MenuModel API allowing both declarative and programmatic approaches.

xmlns:pv="http://primefaces.org/verona"

<pv:menu>
</pv:menu>

Menu has 4 modes, horizontal, popup, static and overlay. Layout wrapper element in template.xhtml is used to define which mode to use by adding specific classes. List below indicates the style classes for each mode.

  • Horizontal: "layout-menu-horizontal"
  • Static: "layout-menu-static"
  • Overlay: "layout-menu-overlay"
  • Popup: "layout-menu-popup"

For example to create a static menu, the div element should be in following form;

<div class="layout-wrapper layout-menu-static">
    ...
</div>

Icons

Verona Layout uses font awesome icons for layout so enable font awesome support in PrimeFaces by setting primefaces.FONT_AWESOME context parameter in web.xml as true. If your PrimeFaces version does not have the font awesome integration, include the font-awesome manually in your application.

Card

Card is a section to group content and layout provides a built-in css for it. Apply .card style class to your container to use it. If the card has a title defined with h1 tag, add card-w-title to adjust paddings.

<div class="card">
    Content here
</div>

<div class="card card-w-title">
    <h1>Card with Title<h1>
    Content here
</div>

Grid CSS

Verona uses new PrimeFaces Grid CSS (ui-g-*) throughout the samples, we strongly suggest using Grid CSS as your layout framework as it is well tested and supported by PrimeFaces. Grid CSS is automatically included on newer versions however if your PrimeFaces version is older than 5.3.14, add the provided grid.css file under /verona-layout/css/ folder to your template manually.

Enhanced Focus

Enhanced focus changes the background of some input components when they receive focus, apply ui-ef class to activate this utility.

<p:inputText placeholder="Enhanced Focus" styleClass="ui-ef"/>

Tips

  • Familiarity with SASS is required to make customizations to the layout and theme.
  • Demo application war and the maven project tag are included in distribution however you don't necessarily need them to install Verona, the actual artifacts required are the layout zip file and the theme jar.
  • Sample demo application war includes the JSF libraries so it is suggested to remove them from the war file when you deploy to an appserver.
  • When running the maven project, you need to build the sass with (sass --update src/main/webapp/resources/ --sourcemap=none) command.

Migration Guide

2.1.0 to 2.1.1

  • Update layout css files
  • Replace theme jar with new jar

2.0 to 2.0.1

  • Update layout css files
  • Replace theme jar with new jar