Gazelle Tag Library

We have defined some JSF tags for our needs, find below what they do and how to use them.

Using Gazelle tags

Your project should have a dependency to gazelle-seam-tools module. You can choose gazelle-tools as the parent of your project:

<parent>
	<groupId>net.ihe.gazelle.maven</groupId>
	<artifactId>gazelle-tools</artifactId>
	<version>2.110</version>
</parent>

 

  1. Update the pom.xml file located in your UI project
     <dependency>
    	<groupId>net.ihe.gazelle.maven</groupId>
    	<artifactId>gazelle-seam-tools-war</artifactId>
    	<type>war</type>
    </dependency>
  2. Update the pom.xml file locate in your EJB project
    <dependency>
    	<groupId>net.ihe.gazelle.maven</groupId>
    	<artifactId>gazelle-seam-tools-jar</artifactId>
    	<type>ejb</type></dependency> 
  3. Update the faces-config.xml file locate in your UI project (src/main/webapp/WEB-INF folder) by adding the following lines after the </application> tag
    <component>
    	<component-type>net.ihe.gazelle.common.tag.PDFFont</component-type>
    	<component-class>net.ihe.gazelle.common.tag.PDFFont</component-class>
    </component>
    <component>
    	<component-type>gazelle-link</component-type>
    	<component-class>net.ihe.gazelle.common.tag.LinkComponent</component-class>
    </component>
    
    <component>
    	<component-type>gazelle-imagelink</component-type>
    	<component-class>net.ihe.gazelle.common.tag.ImageLinkComponent</component-class>
    </component>
    
    <component>
    	<component-type>gazelle-date</component-type>
    	<component-class>net.ihe.gazelle.common.tag.DateComponent</component-class>
    </component>
    
    <component>
    	<component-type>gazelle-safehtml</component-type>
    	<component-class>net.ihe.gazelle.common.tag.SafeHtmlComponent</component-class>
    </component>

If you want to use one of those tags in your XHTML, add a reference to the tag library: xmlns:g="http://www.ihe.net/gazelle"

Available tags

Tag Description
g:date Displays a date, time or timestamp according to the time zone set in the database
g:imagelink Displays an image with a link embedded
g:link Builds a permanent link to the specified object and displays a specific label
g:pdffont Used in Seam PDF to set the font to be used (allows a correct display when values are in Japanese for instance)
g:safehtml Displays a string containing HTML tags but only keeps a set of allowed tags
g:column Extend rich:column to integrate a filtering and sorting shortcut (jboss7 only)

Date (g:date)

Displays a date, time or timestamp according to the time_zone set in the database.

Attribute name Type Description Default
value java.util.Date The date to be displayed NULL
date boolean Indicates if we must display the date TRUE
time boolean Indicates if we must display the time TRUE
tooltip boolean Indicates if a tooltip shall be displayed to give the time zone. If set to false the time zone is added at the end of the string FALSE

The value of the time zone is loaded from the database or the local is used. 

You may have an entity which manage the preferences of your application. To know where to look for the time_zone property, the system needs to know how to access those properties. To do so, you need to create a new class which implements the PreferenceProvider interface and be annotated with @MetaInfProvider. Then, do not forget to create an entry in your preference table with key time_zone. (Example of value: Europe/Paris). If you are developing a simulator and use a recent version of simulator-parent, you do not need to create any class, only check the presence of time_zone variable in app_configuration table.

Image Link (g:imagelink)

This tag behaves like the h:outputLink component except that the value attribute refers to an object and that an icon is displayed. The targeted link will be created depending on the type of the object.

Attribute name Type Description Default
value java.lang.Object The object targeted by this link NULL
icon Text The icon to display NULL
fontIcon Text a font flat icon (ex: "fa fa-info-circle text-info") NULL
width Positive integer Width of the icon (in pixels) NULL
height Positive integer Height of the icon (in pixels) NULL
target Text Where to open the link NULL
styleClass Text css class to apply to this component NULL
rendered boolean Indicates whether to render or not the component TRUE

To use this tag, you need to implement a class which will be used by the component to compute the URL of the object to display. To do so, create a new class which implements the LinkDataProvider interface (from package net.ihe.gazelle.common); annotate this class with @MetaInfServices(LinkDataProvider.class).

Below is an example from gazelle-x-validation module.

@MetaInfServices(LinkDataProvider.class)
public class CrossValidatorLinkDataProvider implements LinkDataProvider {
	
	public static final CrossValidatorLinkDataProvider instance(){
		return new CrossValidatorLinkDataProvider();
	}
	
	private static List<class<?>> supportedClasses;

	static {
		supportedClasses = new ArrayList<class<?>>();
		supportedClasses.add(GazelleCrossValidatorType.class);
		supportedClasses.add(Rule.class);
	}

	@Override
	public List<class<?>> getSupportedClasses() {
		return supportedClasses;
	}

	@Override
	public String getLabel(Object o, boolean detailed) {
		StringBuilder label = new StringBuilder();
		if (o instanceof GazelleCrossValidatorType){
			GazelleCrossValidatorType validator = (GazelleCrossValidatorType) o;
			label.append(validator.getName());
			label.append(" - ");
			label.append(validator.getAffinityDomain());
			if (detailed){
				label.append(" (");
				label.append(validator.getVersion());
				label.append(')');
			}
		} else if (o instanceof Rule){
			Rule rule = (Rule) o;
			label.append(rule.getKeyword());
			if (detailed){
				label.append(" (");
				label.append(rule.getVersion());
				label.append(')');
			}
		}
		return label.toString();
	}

	@Override
	public String getLink(Object o) {
		StringBuilder url = new StringBuilder();
		if (o instanceof GazelleCrossValidatorType){
			GazelleCrossValidatorType validator = (GazelleCrossValidatorType) o;
			url.append("/xvalidation/doc/validator.seam?id=");
			url.append(validator.getId());
		} else if (o instanceof Rule){
			Rule rule = (Rule) o;
			url.append("/xvalidation/doc/rule.seam?id=");
			url.append(rule.getId());
		}
		return url.toString();
	}

	@Override
	public String getTooltip(Object o) {
		// TODO Auto-generated method stub
		return null;
	}

Then, you can use the g:imagelink tag as follows:

 <g:imagelink value="#{rule}" icon="/img/icons64/kfind.gif" styleClass="tableIcon" height="22px" width="22px"/>
 <g:imagelink value="#{rule}" fontIcon="fa fa-info-circle text-info"/>

Note that either the icon (+ optionally height and width) or the fontIcon attribute is mandatory. fontIcon attribute is available from version 2.0.2 of gazelle-tools.

Link (g:link)

This tag behaves like the h:outputLink component except that the value attribute refers to an object and that the text displayed is a pre-defined label. The targeted link will be created depending on the type of the object.

Attribute name Type Description Default
value java.lang.Object The object targeted by this link NULL
tooltip boolean Indicates whether to display or not a tooltip FALSE
rendered boolean Indicates whether to render or not the component TRUE
styleClass Text css class to apply to this component NULL
detailed boolean Uses a longer label as displayed text FALSE

This component uses the same mecanisms as the g:imagelink component, that means that you need to implement the LinkDataProvider interface.

PDF Font (g:pdffont)

pdffont component is used in p:document to defined the font to be used. You can also use the p:font component of the PDF Seam library but we created this tag because we encountered some issues when displaying Japanese characters.

Attribute name Type Description
size Integer The point size of the font
style Text The font styles. Any combination of: NORMAL, BOLD, ITALIC, OBLIQUE, UNDERLINE, LINE-THROUGH
color Text The font color
embedded boolean Indicates whether to embedd the font in the final PDF or not

Safe HTML (g:safehtml)

Rendered HTML strings after removing a set of not allowed HTML tags and attributes. Owasp policy is also applied.

Allowed tags are "p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "li", "blockquote", "caption", "center", "cite", "col", "colgroup", "em", "pre", "q", "table", "tbody", "td", "tfoot", "th", "thead", "tr"

Allowed attributes are

  • "href" and "target" for "a" tag
  • "alt", "src", "border", "height" and "width" for "img" tag
  • "border", "height", "width", "cellspacing", "cellpadding", "bgcolor", "fgcolor", "valign"
Attribute name Type Description
value java.lang.String The HTML string to be displayed (HTML tags will be interprated)

Column (g:column)

Provides built-in sorting and filtering to richfaces4 dataTable column.

added attributes are

  • "sortBy", "filterBy" and "sortOrder".
Attribute name Type Description
sortBy java.lang.String Defines a bean property which is used for sorting of a column.
filterBy java.lang.String Defines iterable object property which is used when filtering performed.
sortOrder java.lang.String SortOrder is an enumeration of the possible sort orderings("ascending","descending","unsorted"). Default value is "unsorted"

 

Insert (g:insert)

allows to insert and highlight the file from the application context into the page.

highlighting can be customized by overiding the css present in cdk-tags artifact.

Allowed attributes are

  • "highlight", "content" and "src".
Attribute name Type Description
content java.lang.String Defines the String, inserted with this component
highlight java.lang.String

Highlight is an enumeration of the possible highlighting ("groovy","java","beanshell","bsh","xml","xhtml","lzx","html","cpp","cxx","c++").

Default value is "xml"

src java.lang.String Defines the path to the file with source code.This attribute is alternative to "content" attribute.

 

Spacer (g:spacer)

Spacer is a simple component that renders an invisible image with the given width, height. Usually it is used to separate elements of page design.

Allowed attributes are

  • "height" and "width".
Attribute name Type Description
height java.lang.String The height of the spacer. Default value is "1 px"
width java.lang.String The width of the spacer. Default value is "1 px"