Monday 8 December 2014

AikFaces User Guide

AikFaces is a JSF 2.2 component library extracted from AIK CMS project. This is my little contribution to Open Source community.

Let's start up ;).

Downloads:

https://sourceforge.net/projects/aikfaces/

Dependencies:

All libraries are included inside lib folder in aikfaces-showcase application.

Other requirements.
All components have to be nested inside <h:form> with property prependId set to false. The same rule you have to use for instance in PrimeFaces component like <p:accordionPanel prependId="false"/>

This component is used for fetching and creating atuomatically data from any databas from given SQL query.

Usage.



   
   


aik-cms:sqlResultSetDataTable.

sqlResultSetDataTable has default implementation for MySQL database. In order to use other databases you have to extends AbstractConnectionFactory class and add to classpath Jdbc driver. The code below is MySQL implementation.
public class MySqlConnectionFactory extends AbstractConnectionFactory
{
 /**
  * Serial version UID
  */
 private static final long serialVersionUID = 4689387254824026857L;
 /**
  * Logger object
  */
 static Logger logger = Logger.getLogger(MySqlConnectionFactory.class);
 /* (non-Javadoc)
  * @see aik.cms.database.AbstractConnectionFactory#createConnection(aik.cms.database.DatabaseConnectionData)
  */
 @Override
 public Connection createConnection(DatabaseConnectionData data)throws ClassNotFoundException, ParameterException, SQLException
 {
  if(data == null)
   throw new ParameterException("Parameter: data is null");
  if(data.getHost() == null)
   throw new ParameterException("Parameter: host is null");
  if(data.getDatabase() == null)
   throw new ParameterException("Parameter: database is null");
  if(data.getUser() == null)
   throw new ParameterException("Parameter: user is null");
  if(data.getPassword() == null)
   throw new ParameterException("Parameter: password is null");
  
  Connection con = null;
  
  try
  {
   Class.forName("com.mysql.jdbc.Driver");
   String url = "jdbc:mysql://" + data.getHost() + "/" + data.getDatabase() + "?user=" + data.getUser() + "&password=" + data.getPassword() + "&useUnicode=true&characterEncoding=UTF-8";
   logger.debug("Connection url: " + url);
   con = DriverManager.getConnection(url);
  }
  catch (ClassNotFoundException | SQLException e)
  {
   logger.error(e.getMessage());
   throw e;
  }
  
  return con;
 }
}