Custom Page with a Table created with the information of a resultSet.

1 Create the REST endPoint listener

First of all, a Java Rest method must be created in the Java. To do that a document with the endPoint object will be created and registered to the application. Something like the code that appears below.

Copy
package deister.axional.frontend.impl;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.HashMap;

/**
 *
 *
 *
 */
@Path("/custom_table")
public class CustomTableFrontendImpl extends  AbstractFrontendImpl {
	//Here we load the page
	@GET
	@Path("/page")
	@Produces(MediaType.TEXT_HTML)
	public Response custom_table() throws Exception
	{

		HashMap<String, Object> variables = new HashMap<String, Object>();
		ArrayList<String> css = new ArrayList<String>();
		ArrayList<String> js = new ArrayList<String>();
		ArrayList<String> html = new ArrayList<String>();

		return createCustomPage(variables, css, js, html);
	}
}

Register the new File

Remember that once this document is created, it must be registered before being able to use the endPoints definitions that the document contains.

To do that go to the document called FrontendResourceConfig.java and register it with the following line register(DOCUMENT_NAME.class);

The path defined for the new endPoint will be /custom_table/page.


2 Define the variables and the templates

For the Custom Table example only a variable is needed, the resultSet Data that will be displayed in the table.

However we also have to define the name of the FreeMarker Templates that we want to call, these templates will be created in the following steps

This time we are not going to add extra JavaScript or extra CSS, so we will send these values as null or empty lists.

Resultset

To get the resultset we call: m_soap_client.getResultSetData("custom_table_code", null);

The first parameter is the code of the SQL inside the SQL catalog, and the second is the dataBase where to do the Query, "null" means that the query is done to the dataBase of the Configuration

Extra information about how to catalog SQL calls here

Copy
//Here we load the page
@GET
@Path("/page")
@Produces(MediaType.TEXT_HTML)
public Response custom_table() throws Exception
{

	HashMap<String, Object> variables = new HashMap<String, Object>();
	ArrayList<String> css = new ArrayList<String>();
	ArrayList<String> js = new ArrayList<String>();
	ArrayList<String> html = new ArrayList<String>();

	SQLResultSet rs = m_soap_client.getResultSetData("custom_table_code", null);

	variables.put("resultSet" , rs);
	html.add("custom_table_html");

	// No css or js added for this example
	return createCustomPage(variables, null, null, html);
}

Result:

3 Create the template documents

Here we can find the folder structure with all the documents created or modified along this example:

  • main
    • java.deister.axional.frontend
      • boot
        • Modified: FrontendResourceConfig.java
      • impl
        • Added: CustomTableFrontendImpl.java
    • resources.deister.axional.frontend.resources.app.custom
      • Added: custom_table_html.ftl