jaxfront logoVersion 3.0

API Integration Sample

This demo shows how you may embedd JAXFront into your own servlet using the API class. Clicking on the button below will call your own servlet (APIDemoServlet.java) and generate a JAXFront html ui. This example shows the usage of an own action controller (MyOwnDOMActionController) to demonstrate the usage of own server side button implementation to interact with the JAXFront dom. Click on the button called "own action" after you have created the UI.

  • Add the file jaxfront-ajax.js (found in jaxfront-demo.war) into your html head section
    <script language="JavaScript" src="js/jaxfront-ajax.js" type="text/javascript"></script>
  • Call the javascript function 'createHTML' to render a JAXFront HTML form
    createHTML(elementRef, 'serverAddress', 'servletName', 'htmlTargetID', 'optinalURLParams', 'language');
    We used this params in this example:
    createHTML(this, null, 'APIDemoServlet', 'VISUALIZER_CONTENT', '&action=api-go', 'de');
  • Copy the following content (found in jaxfront-demo.war) to your web project root directory:
    WEB-INF/lib/jaxfront.tld (for JSP usage only)
  • Add the JAXFrontRequestFilter in your web.xml
  • Implement your own java servlet (see APIDemoServlet.java)
    public class APIDemoServlet extends HttpServlet {
    	public void service(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
    		String action = request.getParameter("action");
    		if (action != null && action.equals("api-go")) {
    			apigo(request, response);
    		} else {
    			super.doPost(request, response);
    	private void apigo(HttpServletRequest request, HttpServletResponse response) {
    		response.setContentType("text/html; charset=UTF-8");
    		StringBuffer formContentXHML = new StringBuffer();
    		String language = request.getParameter("language");
    		String xsdURL = JAXFrontServletAdapter.getRealPath("examples/purchaseOrder/po.xsd");
    		String xml = null;
    		String xuiURL = JAXFrontServletAdapter.getRealPath("examples/purchaseOrder/po.xui");
    		DOMActionController actionController = new MyOwnDOMActionController();
    		String id = API.buildForm(formContentXHML, request, URLHelper.getUserURL(xsdURL), URLHelper.getUserURL(xml), URLHelper.getUserURL(xuiURL), actionController, language);
    		// keep this id to get the JAXFront Document later on to serialize XML > dom.serialize();
    		DOMHandler domHandler = API.getFormDOM(request, id);
    		if (domHandler != null) {
    			Document jaxfrontDOM = domHandler.getDOM();
    		try {
    		} catch (IOException e) {}
This demo servlet will generate an interactive XHML form based on the following resources:

JAXFront by xcentric technology & consulting GmbH [*].
(c) 2001-2015 Copyright. All rights reserved.