Getting Started

To use Tiefaces web sheet, please follow the steps below:

  1. Add Tiefaces dependency.
  2. Define an Excel template.
  3. Define namespaces and use the websheet tag in a JSF web page.
  4. Create a WebSheet bean and process the template.

Adding Tiefaces dependency

The easiest way to add Tiefaces libraries to your project is to use Maven and specify the required libraries in pom.xml.

<dependency>
	    <groupId>org.tiefaces</groupId>
	    <artifactId>tiefaces</artifactId>
	    <version>1.0.2</version>
</dependency>
	

Alternatively you can download Tiefaces distribution from the download page and use the jars from the distribution. See the download page for deail.

Define an Excel template.

A template is an excel file which uses a special markup to specify how Tiefaces should build the component.

Tiefaces supports Apache JEXL as an expression language in the excel template.

For example, if you want to input/output employee name in a cell, you can put ${employee.name} in the cell (assuming the employee object is avaliable in the context). As you can see, the definition is JEXL expression warpped with ${ and }.

Tiefaces also use special commands in the cell comment to support enhanced features:

  • Form command (tie:form): define form format
  • Fach command (tie:each): populate recusive data
  • Widget: difine widget name and attributes

The example template screenshot:

getting start feature 1

For more details, please see the reference pages.

Define namespace and use the websheet tag in a JSF web page.

Use the namespace below to define tiefaces:

...
xmlns:tie="http://tiefaces.org/tiefaces"
...

Use tie:websheet tag in the JSF web page to define the component:

...
<tie:websheet id="sheet1"
....
>
</tie:websheet >
...

Create WebSheet bean and process the template.

As you can see the snip code below, it needs the following steps:

  1. Create the bean by extend the TieWebSheetBean
  2. Populate data into context (if no data needed, then skip this step).
  3. Retrieve Excel template.
  4. load the web sheet with the template and context.
...
@Named
@ViewScoped
public class WebSheetDataAnnotation extends TieWebSheetBean {

    private static final long serialVersionUID = 1L;

    @Override
    public void initialLoad()  {
        Map<String, Object> context = new HashMap<String, Object>();
        List<Department> departments = WebSheetDataDemo.createDepartments();
        context.put("departments", departments);
        InputStream stream = this.getClass().getClassLoader().getResourceAsStream("websheet/datacommentdemo.xlsx");
        loadWebSheet(stream, context);        
    }
}
...