Smart-Web tutorial

Full Database driven example using Smart-Web-App

1- Create new maven project with “jk-faces-test" as the artifact id

2- Edit pom.xml to be :
<project xmlns=""  xmlns:xsi="" 



                <!-- -->

3. Create new JSF test page src/main/webapp/test.xhtml
<html xmlns="" xmlns:h="" xmlns:jk="" xmlns:p="">
    <title>JK-Faces test with JK-DB</title>
        <p:panelGrid columns="1">
            <p:growl autoUpdate="true" />
            <p:inputText value="#{}" placeholder="Enter id here" />
            <p:inputText value="#{}" placeholder="Enter name" />
            <p:inputText value="#{mb.salary}" placeholder="Enter salary" />
            <p:commandButton value="Add" action="#{mb.add}" ajax="false" />

This will produce the following output :example21

Important: don’t click add yet , you need to write the below manage bean 🙂

4. Create new JSF Managed bean src/main/java/test/MBEmployee
package com.jk.example.faces;

import javax.faces.bean.ManagedBean;

import com.jk.faces.mb.JKPlainDataAccessManagedBean;

@ManagedBean(name = "mb")
public class MBEmployee extends JKPlainDataAccessManagedBean {
    Integer id;
    String name;
    Double salary;

    public String add() {
        execute("INSERT INTO employees (id,name,salary) VALUES (?,?,?)", id, name, salary);
        success("Added successfully");
        return null;

    public Integer getId() {
        return id;

    public void setId(Integer id) { = id;

    public String getName() {
        return name;

    public void setName(String name) { = name;

    public Double getSalary() {
        return salary;

    public void setSalary(Double salary) {
        this.salary = salary;

5. Create new JK-DB Config src/main/webapp/WEB-INF/

*Important: * The above examples assumes the existence of employees with id,name,salary as fields , please refer to JK-DB project to get the script for the table.