Using Jasper Reports with Icefaces and Visual Web

April 20, 2009

Ok here’s how to do it.

Firstly you’ll need a Jasper Reports Engine Class.

Create a new class in your project.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package PHJ;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.sql.ResultSet;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRPdfExporter;

/**
 *
 * @author paulc
 */
public class PHJJasperReportEngine {

        private databasesettings MyDB=new databasesettings();

    // private static final String PREFIX = "/WEB-INF/reports/";
    private static final String PREFIX = "";///faces/";
    /**
     * <p>Suffix to the resource name for compiled reports.</p>
     */
    private static final String SUFFIX = ".jasper";
    /**
     * <p>Valid content types for reports that we can produce.</p>
     */
    private static final String[] VALID_TYPES = {"text/html", // Standard HTML representation
        "application/pdf", // Adobe Portable Document Format
        "application/rtf"};

     public byte[] iceFacesjasperReport(String sBaseURL,String sSQL,String name, String type, Map params) throws IOException {
        URL url=null;
        ByteArrayOutputStream returnStream=new ByteArrayOutputStream();

        System.out.println(sBaseURL);
        try {
            url = new URI(sBaseURL+"/"+name+SUFFIX).toURL();
        } catch (URISyntaxException ex) {
            Logger.getLogger(PHJJasperReportEngine.class.getName()).log(Level.SEVERE, null, ex);
        }

             ResultSet data=null;
        try {
            data = MyDB.getDataFromMYSQL(sSQL);
        } catch (ClassNotFoundException ex) {
            System.out.println("Class not found "+ex);
        }
             if (data==null) {
                 System.out.println("Error in SQL "+sSQL);
                 return null;
             }

        // Validate that we recognize the report type
        // before potentially wasting time filling the
        // report with data

        boolean found = false;
        for (int i = 0; i < VALID_TYPES.length; i++) {
            if (VALID_TYPES[i].equals(type)) {
                found = true;
                break;
            }
        }
        if (!found) {
            throw new IllegalArgumentException("Invalid report type '" + type + "' requested");
        }

        // Look up the compiled report design resource
        InputStream stream = url.openStream();

        if (stream == null) {
            throw new IllegalArgumentException("Unknown report name '" + name + "' requested");
        }

        try {
            data.beforeFirst();
        } catch (Exception e) {
            throw new FacesException(e);
        }

        // Fill the requested report with the specified data
        JRResultSetDataSource ds = new JRResultSetDataSource(data);
        JasperPrint jasperPrint = null;
        try {

            jasperPrint = JasperFillManager.fillReport(
                    stream, params, ds);

        } catch (RuntimeException e) {
            System.out.println(e);
            throw e;
        } catch (Exception e) {
            System.out.println(e);
            throw new FacesException(e);
        } finally {
            try {

                stream.close();
            } catch (IOException e) {
            }
        }

        // Configure the exporter to be used, along with the custom
        // parameters specific to the exporter type
        JRExporter exporter = null;

         // PersistentFacesState response=(PersistentFacesState)econtext.getResponse();
        //FacesContext fcontext = FacesContext.getCurrentInstance();
        try {
          //  response.setContentType(type);
            if ("application/pdf".equals(type)) {
                exporter = new JRPdfExporter();

            //    response.setHeader("Content-Type", "application/download");
              //  response.setHeader("Content-Disposition", "attachment; filename=" + name + ".pdf");

                exporter.setParameter(JRExporterParameter.JASPER_PRINT,
                        jasperPrint);
                exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,
                        returnStream);

            }
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new FacesException(e);
        }

        // Enough with the preliminaries ...
        // export the report already
        try {
            exporter.exportReport();
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new FacesException(e);
        }

        // Tell JavaServer Faces that no output is required
        return returnStream.toByteArray();

    }

        public static byte[] toByteArray(InputStream input) throws IOException {
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        byte[] buf = new byte[4096];
        int len = 0;
        while ((len = input.read(buf)) > -1) output.write(buf, 0, len);
        return output.toByteArray();
    }

}

Then create a new page. You then need to add an OUTPUT RESOURCE component. I do this in the JSP tab because it doesn’t have any properties.

  <ice:outputResource attachment="true" fileName="subcontractorsummary.pdf" id="pdf-button" label="Output to PDF" mimeType="application/pdf"
                            resource="#{FRIMICESUBCONTRACTORSUMMARY.pdfResource}"
style="height: 24px; left: 24px; top: 168px; position: absolute; width: 119px" type="button"/>

In this case the page is called FRIMICESUBCONTRACTORSUMMARY so you’ll need to change that to match.

Now in the Java backing bean.

    private Resource pdfResource;

    public Resource getPdfResource() {
        return pdfResource;
    }

    public void setPdfResource(Resource pdfResource) {
        this.pdfResource = pdfResource;
    }

    class MyResource implements Resource, Serializable {
        public String sURL;
        private String resourceName;
        private final Date lastModified;
        private ExternalContext extContext;
        private PHJJasperReportEngine thisEngine = new PHJJasperReportEngine();

        public MyResource(ExternalContext ec, String resourceName) {
            this.extContext = ec;
            this.resourceName = resourceName;
            this.lastModified = new Date();

        }

        /**
         * This intermediate step of reading in the files from the JAR, into a
         * byte array, and then serving the Resource from the ByteArrayInputStream,
         * is not strictly necessary, but serves to illustrate that the Resource
         * content need not come from an actual file, but can come from any source,
         * and also be dynamically generated. In most cases, applications need not
         * provide their own concrete implementations of Resource, but can instead
         * simply make use of com.icesoft.faces.context.ByteArrayResource,
         * com.icesoft.faces.context.FileResource, com.icesoft.faces.context.JarResource.
         */
        public InputStream open() throws IOException {
            try {
                // getrequestservletpath retruns the page url
                // getRequestContextPath=/CourierSystem

                HttpServletRequest thisRequest=(HttpServletRequest) extContext.getRequest();
                sURL="http://"+thisRequest.getServerName()+":"+thisRequest.getServerPort()+extContext.getRequestContextPath();
                Map param = new HashMap();

                /***********************************************/
                /* THIS IS THE BIT YOU NEED TO CHANGE FOR YOUR */
                /* REPORT - Make sure the filename.jasper is in*/
                /* the same place as your icefaces pages       */
                /* lastly, make sure the SQL matches           */
                /***********************************************/

                String sReportFileName="RPTCUSTOMERJOBSUMMARY";
                String sSQL = "SELECT * FROM TBLCUSTOMERS";

                /************************************************/
                return new ByteArrayInputStream(thisEngine.iceFacesjasperReport(sURL, sSQL, sReportFileName, "application/pdf", param));

            } catch (Exception e) {

                System.out.println("Error " + e);
            }

            return null;
        }

        public String calculateDigest() {
            return resourceName;
        }

        public Date lastModified() {
            return lastModified;
        }

        public void withOptions(Options arg0) throws IOException {
        }

    }

And then add to the init()  phase of the page.

 try {
            FacesContext fc = FacesContext.getCurrentInstance();
            ExternalContext ec = fc.getExternalContext();
            pdfResource = new MyResource(ec, "report.pdf");

        } catch (Exception e) {
            e.printStackTrace();
        }

Bingo!


One Line of code confirmation on a button – visual web

March 24, 2009

Here’s one of those teeny tips that saves a lot of building screens etc. Let’s say you have a Visual Web button that you want the user to confrim before it proceeds through to the actual code at the back end.

In the onClick javascript property simply add

return confirm(”Are you sure”);

Then when the user clicks the button if they click OK the system will carry on and submit to the back end, if not, it will simply do nothing. Ofcourse we could expand this to add other messages by putting a function in some javascript in the head tags and the call it from the onClick.


Woodstock and AJAX with DHTMLXGRID (Netbeans 6.5)

March 13, 2009

Did you know that you can use the great woodstock components with DHTMLXGRID (and all the other components), this is the first of a series of articles to show you how. (http://www.dhtmlx.com/)

Before you start – if you are coding Javascript like this you best switch to Firefox and install the FIREBUG plugin, this lets you see whats going on with javascript pages like you’ve never done before. It will also help you identify the id’s of components before you use them and see if you get any problems.

The first thing to do is to copy the DHTMLXGRID javascript and CSS code into your Resources directory of your web project. Copy the whole of the codebase directory including the subdirectories, just drag and drop them.

Now create a new page and add a layout panel called it grdJOBDISPLAY Stretch it out to the size you want.

One of the problems we have is that we want to do some javascript that runs after the component tree is loaded, this happens after the page is loaded, I found that doing onload didn’t work, so you have to create a Static Text box, turn of ESCAPE and then in the text box put

<script language=”javascript”>
initgrid();

</script>

Now switch to your JSP it’s time to implement the javascript for the grid.

First, between the <head> tags we’ll add the code to load the grid support

<webuijsf:link id=”link91″ url=”/resources/dhtmlxgrid.css”/>
<webuijsf:script id=”link29″ url=”/resources/dhtmlxcommon.js”/>
<webuijsf:script id=”link39″ url=”/resources/dhtmlxgrid.js”/>
<webuijsf:script id=”link49″ url=”/resources/dhtmlxgridcell.js”/>
<webuijsf:script id=”link59″ url=”/resources/ext/dhtmlxgrid_srnd.js”/>
<webuijsf:script id=”link69″ url=”/resources/ext/dhtmlxgrid_filter.js”/>
<webuijsf:script id=”link71″ url=”/resources/ext/dhtmlxgrid_splt.js”/>
<webuijsf:script id=”link331″ url=”/resources/ext/dhtmlxgrid_hmenu.js”/>

And finally a section of script that will run to initialise the grid. In this case you can see my code for a real screen this is more complex that you will use, here I’m using the dynamic loading grid but you can adjust the code for your own use. Note that if you are going to use the dynamic loading grid with a SQL server you should be using some paging code to return the pages of data that is required, this is easy with SQL 2005 and MYSQL (LIMIT) but with SQL 2000 it is a complete dog.

To do paging with SQL Server 2000 I use http://esersahin.wordpress.com/2008/11/24/efficient-and-dynamic-server-side-paging-with-sql-server-2000/ this works like a dream and more than makes up for the lack of it working otherwise.

Also in this code I stretch the grid to be the width of the screen.

                        getElementByIdCompatible('form1:grdJOBDISPLAY').style.height=(pageHeight()-200)+"px";
                        getElementByIdCompatible('form1:grdJOBDISPLAY').style.width=(pageWidth()-30)+"px";

And in fact I make it the height of the screen – 200 pixels.

Note that here I also have a couple of other hidden fields (HIDDEN boxes) I use to pass data from the javascript at the front to the code at the back end.

form1:layoutPanel1:txtTABLENAME – stores the tablename to pull from, I dynamically set this when searching etc. It is bound to a variable stored in the session bean so I can set it or read it from the backing bean OR javascript.

form1:layoutPanel1:txtSQL- stores the WHERE statement that I’m going to use to filter the data in the grid. Again, bound to a session bean variable means that I can have a button you click on that changes the where statement.

<webuijsf:markup id="gridscript">
                        <script language="javascript">

                        var gridQString = "";

                        // called from a javascript function

                        function init() {
                        getElementByIdCompatible('form1:grdJOBDISPLAY').style.height=(pageHeight()-200)+"px";
                        getElementByIdCompatible('form1:grdJOBDISPLAY').style.width=(pageWidth()-30)+"px";
                        mygrid = new dhtmlXGridObject('form1:grdJOBDISPLAY');
                        mygrid.imgURL = "img/";
                        mygrid.setHeader("Job No, Job Date,POD,Hist, Svc,Sub,Haz,Pcs,Wgt,Acc No,Customer,Co Name, Town, Driver, Hdlg Dep,Close Time,Status,Print ");
                        mygrid.setInitWidths("100,100,60,60,50,50,50,50,50,100,200,200,200,100,200,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100");
                        mygrid.setColAlign("left,left,center,left,left,left,left,left,left,left,left,left,left")
                  //      mygrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro");
                        mygrid.setColSorting("str,date,str,str,str,str,str,str,str,str,str,str,str,str")
                        mygrid.setSkin("light");
                        mygrid.setDateFormat("%d/%b/%Y");
                        mygrid.enableHeaderMenu();
                        mygrid.setAwaitedRowHeight(25);

                        // mygrid.attachHeader("#text_filter,#combo_filter,#numeric_filter");

                        // NOTE YOU NEED TO INSTALL A STORED PROCEDURE IN THE SQL SERVER TO MAKE THIS WORK

                                        mygrid.attachHeader("#text_filter,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#text_filter,#rspan,#rspan,#rspan,#text_filter,#text_filter,#rspan,#text_filter");
                        mygrid.init();
                        // mygrid.splitAt(1);
                        gridQString ="../jobscreendriver.jsp?tbl="+getElementByIdCompatible("form1:layoutPanel1:txtTABLENAME").value+"&amp;whr="+getElementByIdCompatible("form1:layoutPanel1:txtSQL").value;
                        mygrid.loadXML(gridQString);
                        mygrid.enableSmartRendering(true);

                        var sLastSQLWhere='';

                        mygrid.attachEvent("onFilterStart",function(cols,vals) {

                        var sAND='';
                        var sSQLWhere='';
                        if (vals[0]!='') {
                            sSQLWhere="jobno LIKE 'PERCENT"+vals[0]+"PERCENT'"
                            sAND=" AND "
                        }
                        if (vals[1]!='') {
                            sSQLWhere=sSQLWhere + sAND+" accountno LIKE 'PERCENT"+vals[1]+"PERCENT'";
                            sAND=" AND ";
                        }
                        if (vals[2]!='') {
                            sSQLWhere=sSQLWhere + sAND+" isporfleetid LIKE 'PERCENT"+vals[2]+"PERCENT'";
                            sAND=" AND ";
                        }
                         if (vals[3]!='') {
                            sSQLWhere=sSQLWhere + sAND+" handlingdepot LIKE 'PERCENT"+vals[3]+"PERCENT'";
                            sAND=" AND ";
                        }
                        if (sLastSQLWhere!=sSQLWhere) {
                        sLastSQLWhere=sSQLWhere;
                        mygrid.clearAll();
                        getElementByIdCompatible("form1:layoutPanel1:txtSQL").value=sSQLWhere;
                        mygrid.loadXML("../jobscreendriver.jsp?tbl="+getElementByIdCompatible("form1:layoutPanel1:txtTABLENAME").value+"&amp;whr="+ sSQLWhere);
                        mygrid.enableSmartRendering(true);
                        }
                        return false;  //block default filters
                        });

                        }

                        function getElementByIdCompatible(the_id) {
                        if (typeof the_id != 'string') {
                        return the_id;
                        }

                        if (typeof document.getElementById != 'undefined') {
                        return document.getElementById(the_id);
                        } else if (typeof document.all != 'undefined') {
                        return document.all[the_id];
                        } else if (typeof document.layers != 'undefined') {
                        return document.layers[the_id];
                        } else {
                        return null;
                        }
                        }

                        // Process the clicked Job button
                        function editJob(sJobNo) {
                        getElementByIdCompatible("form1:layoutPanel1:txtJOBNO").value=sJobNo.id;
                        getElementByIdCompatible("form1:layoutPanel1:cmdEDITJOB").click();
                        return false;
                        }

                        </script>
                    </webuijsf:markup>

Now then. You will need a JSP file to deliver the data to the grid -

            mygrid.loadXML("../jobscreendriver.jsp?tbl="+getElementByIdCompatible("form1:layoutPanel1:txtTABLENAME").value+"&amp;whr="+ sSQLWhere);

Here I have a JSP file that creates some xml – this is more complex than you might need for your applications but it does some interesting things with being able to filter data. You will have to adjust this to your database and situation, note that it uses the paging stored procedure to provide the data back to the grid on an SQL 2000 server.  Also I change the colour of the row to reflect the status of the record.

Lastly before I send the sql statement I replace the % signs with PERCENT and then convert it back in the code – you also need to filter out & signs in the xml and replace with &amp; otherwise you’ll get the “invalid XML statement”

<?xml version="1.0" encoding="ISO-8859-1"?>
<%@ page contentType="text/xml;charset=ISO-8859-1" %>
<%@ page import = "java.sql.*" %>
<%
        String db_ipp_addr = "insert ip address";
        String db_username = "insert username";
        String db_password = "insert password";
        String db_name = "insert database";

// set content type and xml tag

//   out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
// response.setContentType("text/xml");
// define variables from incoming values
        Integer posStart = 0;
        if (request.getParameter("posStart") != null) {
            posStart = new Integer(request.getParameter("posStart"));
        } else {
            posStart = 0;
        }

        Integer count = 0;
        if (request.getParameter("count") != null) {
            count = new Integer(request.getParameter("count"));
        } else {
            count = 20;
        }
        if (posStart.equals("0")) {
            posStart = 0;
        }

// connect to database
        Connection connection = null;
        Statement statement = null;
        Statement history = null;
        ResultSet rs = null;
        ResultSet Historyrs = null;

        String connectionURL = "jdbc:sqlserver://" + db_ipp_addr + ":1433;databaseName=" + db_name;

        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
        connection = DriverManager.getConnection(connectionURL, db_username, db_password);
// connection.setCatalog("dbo");
// query to products table
        String sTableName = "dbo.tbljobs";
        if (request.getParameter("tbl") != null) {
            sTableName = request.getParameter("tbl");

        }

        String sql = "SELECT * FROM " + sTableName;
        String sCancelled = " Cancelled=0 AND ";

        if (request.getParameter("whr") != null) {
            if (request.getParameter("whr").toLowerCase().contains(" cancelled")) {
                sCancelled = "";
            }
            sql = sql.trim() + " WHERE " + sCancelled + " JobNo Not Like 'CR%' AND " + request.getParameter("whr");
        } else {
            sql = sql.trim() + " WHERE " + sCancelled + " JobNo Not Like 'CR%'";
        }
        sql=sql.trim();
        if (sql.substring(sql.length()-3,sql.length()).equals("AND")) {
            sql=sql.substring(0,sql.length()-3);
            }
        sql=sql.replace("PERCENT","%");
// if this is the first query - get total number of records in the query result
        String totalCount = "";
        if (posStart == 0) {
            String sqlCount = "Select count(*) as cnt from (" + sql + ") as tbl";
            statement = connection.createStatement();

            rs = statement.executeQuery(sqlCount);
            rs.next();
            totalCount = rs.getString("cnt");

            rs.close();
        } else {
            totalCount = "";
        }

        CallableStatement getData = connection.prepareCall("{call returnpage(?,?,?,?)}");
        getData.setString(1, sql);

        getData.setInt(3, posStart);
        getData.setInt(4, (posStart + count));
        try {
        getData.executeQuery();

        rs = getData.getResultSet();
        } catch (Exception e) {
            System.out.println (sql);
        System.out.println ("Error Getting Record "+e);
          }
// output data in XML format
        out.println("<rows total_count='" + totalCount + "' pos='" + posStart + "'>");
        String sThisColor;
        String sStatus;

        while (rs.next()) {

            sStatus = rs.getString("status").trim();

            sThisColor = "#ffffff";
            if (sStatus.equals("XXXX")) {
                sThisColor = "#ff0000";
            } else if (sStatus.equals("YYYYY")) {
                sThisColor = "#ffcc00";
            } else if (sStatus.equals("EEEEE")) {
                sThisColor = "#ffcc00";
            } 

            out.println("<row style=' border-width: 1px; border-style: solid; border-color: rgb(253, 253, 253) rgb(147, 175, 186) rgb(147, 175, 186) white;padding:1px;height:22px;background-color:" + sThisColor + "' id='" + rs.getString("jobno") + "'>");

            out.println("<cell>");
            out.println(rs.getString("field1"));
            out.println("</cell>");
            out.println("<cell>");
            out.println(rs.getDate("field2"));
            out.println("</cell>");
            out.println("<cell>");
            out.println(rs.getString("field4") + "");  // value for product name
            out.println("</cell>");
            out.println("</row>");
        }
        out.write("</rows>");

        rs.close();

%>

Have fun!

Further Ubuntu Intrests — is it a Mac? Is it Vista?

February 28, 2009

Well it’s been a few days since I defected from the dictatorship of Windows Vista to Ubuntu – I do have to confess going back into Windows once. But that was just to get a document – I’ve not configured openoffice to read Office 2007 docs.

My Ubuntu now looks like a Mac, I have always loved those “scrolly bar at the bottom” thing that macs have. and I was delighted to find not one but TWO of them for Ubuntu.

Everything works faultlessly. Including a printer we have at work which would not install under Windows Vista without crashing the spooler whenever you went to Print. Not only did Ubuntu find the  printer, it correctly identified it, installed the driver and worked out of the box. Actually much better than windows Vista did.

There seems to be an interesting passion amongst Ubuntu users. There’s a strange feeling you’ve just got your computer back. All my apps are still running about 5 or 6 times faster than under windows. Partly because Ubuntu is running in 64 bit on here – and unlike Windows still runs all the 32 bit apps like Second Life seamlessly.

I’m feeling slightly silly though because I was working with Ubuntu 6.10 over a year ago – it was fine but you had to be a programmer to use it. Now I reckon it’s an IDEAL platform for anyone – especially with  the ability to change it to look how YOU want and not be dictated by the OS.

What was strange was when I went on to the Canal World IRC I use a lot to find I wasn’t the only one who has been redeemed.

Freedom is a nice feeling.


The return to UBUNTU!

February 26, 2009

I made a radical decision with my team today.

I used to live on UBUNTU and only use Windows for things that wouldnt work under Ubuntu.

Recently my latest new developer was singing Ubuntu’s praises so I thought I’d go back for a revisit.

Netbeans runs in Ubuntu about 50 times faster than Windows. My machine under ubuntu has got a new lease of life.

- The graphics are astounding – I installed the compiz package.
- We used some sort of install that ran under windoze and creates a host folder with all my windows stuff. – This meant I could just load up and work on the netbeans projects from my windows directory.
- The install of ubuntu including all the setting up only took a couple of hours, most of the stuff was installed automatically.
- I had problems with VPN’s not connecting but that was quickly fixed

I can’t see myself returning to Windows any time soon, I simply don’t see the point.

I have got all the developers moving to Ubuntu now as it is simply better than Windows for development of java apps.


Icefaces Good news and Bad News!

February 25, 2009

NEW RELEASE CANDIDATE

You may have remembered that I wrote about Icefaces tabset not working in NetBeans.. A new release is out (Release Candidate).

USING COMPONENTS ON A LAYOUT PANEL AND BEING ABLE TO LAY THEM OUT!

Well the goodnews is that you can now see components you drag and drop on to the tab set or layout panel.

However laying out is nigh on impossible. That was until I realised that when you drag and drop components to the page or a layout box of any  type, icefaces (or visual web) doesn’t assign a style to it – this may be by design, but by setting the components style to

position:absolute

I am then able to move and position them around the screen.

THE TABSET COMPONENT

However, the tabset itself is more complicated.

The tabset is made up of  TABS (which are some form of layout), with PANELLAYOUTS as a child under each tab. The panellayout, don’t ask me why is set to inherit it’s position from the parent and this seems to drive it crazy.

To make it so you can layout components on the tabset:-

In the style to the panellayout style

height: 500px; left: 12px; top: 35px; position: absolute; width: 800px

You’ll notice that the tab immediately shrinks in size to just the top – don’t worry about that – it will still work.

Now each component use the above “trick” of setting the style of the components to position:absolute and you are done.


My application won’t deploy!

February 24, 2009

You know one of those problems that makes you kick yourself when you find out the solution!

I’ve got this Solaris server running Glassfish, the application runs fine locally, but when deploying it just hangs.

I THOUGHT it was a problem with a slow network, so just sat there waiting but nothing – had the network checked as well. Then one of my guys was dealing with a different problem (Uthay!) and started talking about JDK versions.

The application I had was configured as JDK 5, so I changed it to JDK 6 and guess what – it deployed straight away.

THere are two morals to this story:-

a. Listen to what is going on around you if you work in a programming team as someone elses solution might be yours as well.
b. Make sure the version of the JDK you are running on the development environment MATCHES the one on the server!


Great Bug Tracking Software

February 23, 2009

We’ve been looking around at bug tracking software for our ever growing dev. team.

Found this. It’s BRILLIANT http://www.thebuggenie.net/ and free although we will look to adding it to our supported software after a trial.


Not wishing to sound like Victor Meldrew but….

February 9, 2009

I don’t beleive it.

Finally we get our selves migrated all the way to netbeans 6.5 and then we discover that the icefaces plugins which don’t work with 6.1 don’t work properly with 6.5.

The problem is that if you use any of the panels Like the tab control you drop controls on the tab and they just dissappear.

We *ARE* considering buying Icefaces support but actually I think they need to get it working first, I mean you wouldn’t buy a car if only half of it worked would you?


Using Jasper Reports with Visual Web in Netbeans 6.5

February 5, 2009

Firstly Infragistics let us down – you can only use Infragistics for JSF with Netbeans 5.5 (Although the website just sasy “NETBEANS”) ,… Refund please.

So our requirements:-

Netbeans 6.5
Jasper Reports
Visual Web – Woodstock/Icefaces

1. DO NOT INSTALL the Jasper Reports Plugins into Netbeans 6.5 – it breaks Visual Web
2. to Edit Reports use the stand alone Jasper Reports applciation

Secondly we need to add Jasper Reports ENGINE only to the Netbeans project so that we can run the jasper reports without upsetting visual web.

Now we can install the icefaces plugins and use them with our project.

To do this, simply download the Jasper Reports JAR file and then create a library “JasperReports” and add it to your web project – this will give you the support you need.

Save your reports into the WEB folder and then use the other code I have on this blog to execute the reports you create in your external IReport application.

Important: http://facestutorials.icefaces.org/tutorial/woodstock/PortingGuidePart1.html < Read this first before adding icefaces to your project.

 Also you’ll find this 2 page crud useful as it contains both Icefaces and JSP pages. http://facestutorials.icefaces.org/tutorial/woodstock/TwoPageCrudTable_Part2.zip

 Page Locations

Your old JSP pages (Woodstock) will be located at http://localhost:8080/Project-war/faces/pagename.jsp

IceFaces Pages are at http://localhost:8080/Project-war/pagename.iface  

You will also find your project runs index.html which you should redirect to where you want by changing it to:-

<meta http-equiv=”refresh” content=”0;url=faces/Page1.jsp”>