Netbeans 6.8, good old woodstock!

October 30, 2009

Well, it seems that Netbeans 6.8 does not come with Visual Web/Woodstock

I suspect that Sun (Oracle) are planning to replace it with those really nice ADF components, brilliant but folks it just is not commercial in my view.

People like us who have been using Netbeans with Woodstock to build HUGE applications are left high and dry and can’t move forward or upgrade to the new version. The cost of us converting to the new components is just too great with no financial benefit. We had the same trouble with IceFaces when that came out.

Personally I would like to actually get DHTLMX components and tightly integrate them with Woodstock and Visual Web, using this combination of components we’ve built some really swish AJAX based web apps that run VERY fast.

When you have 300 components on a form, you cannot hope to do it manually and leaving us with a text only option with no layout facilities provides us with no alternative but to stay with Netbeans 6.7.

So here’s my plan.

I plan to develop a tool/plugin/thingy that will allow you to visually design JSP/JSF pages. It will be seperate from Netbeans so we don’t suffer with random upgrade blues.

 

 


FAST way of generating JSP pages using EJB’s to provide the data!

October 4, 2009

Ok firstly sorry I’ve not posted much but had a lot of personal issues.

Anyway – here’s the story, we were using the awesome DHTLMX components with JSP’s feeding the data but we could never get the speed up especially since our source database had 270,000 records or so (and increasing!). The server is a GlassFish server by the way.

So basically the woodstock page replaced the DHTLMX combo boxes, and grid by feeding from JSP’s that opened a database in the standard way. Which is SLOOWWW.

By accident I found that moving the actual routine to an ejb with an entity manager made the code run about a million times faster. In fact when one of the customer’s date entry people tried it they nearly fell off their chair as it was so much faster than their existing system.

This technique can be used with just about any application to call a routine and return data, but it must be java.! Note I’m not a fan of XML because I think it gives back a whole load more data than it needs! But some of the components need it! :-)

Ok – so 3 teirs.

JSP PAGE <—> EJB Remote Interface <—> EJB

Here’s the JSP page that generates the XML in the WAR project (web application)

<?xml version="1.0" encoding="ISO-8859-1"?>
<%@ page contentType="text/xml;charset=ISO-8859-1" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "javax.naming.Context" %>
<%@ page import = "javax.naming.InitialContext; "%>
<%@ page import = "PHJ.JobManagerRemote.*" %>
<%

 PHJ.JobManagerRemote jobManagerBean=null;
 try {
 Context c = new InitialContext();
 jobManagerBean=(PHJ.JobManagerRemote)c.lookup("java:comp/env/JobManagerBean");
 } catch (Exception ne) {
 System.out.println("Could not find Job Manager Bean "+ne);
 }

 String sql = "SELECT TOP 40 tblAddressBook.AddrName, tblAddressBook.AddrNum, tblAddressBook.AddrCity, tblAddressBook.AddrCounty, tblAddressBook.ID ";
 sql=sql+ " FROM tblAddressBook ";
 sql=sql+" WHERE tblAddressBook.LastUsed>DATEADD (day,-60,GETDATE() )  ";

 if (request.getParameter("mask")!=null) {
 sql=sql+" and addrName like '"+(request.getParameter("mask").replace("'","''"))+"%' ";
 }
 sql=sql+" ORDER BY tblAddressBook.AddrName ";

// connect to database

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

 //  Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
 //

 out.println(jobManagerBean.CustomerAddressserverXML(sql));

%>

Look how tiny it is! :-)

Ok So – then I have an EJB in an enterprise applcation called JobManagerBean. In the remote code we have….

public  String CustomerAddressserverXML(String sSQL);

and in the EJB itself…

@Override
 public  String CustomerAddressserverXML(String sSQL) {

 String sSQLTemplate = sSQL;
 List results = null;
 Query q = em.createNativeQuery(sSQLTemplate, TblAddressBook.class);

 try {
 results = q.getResultList();
 } catch (Exception e) {
 return "<complete></complete>";
 }

 String sResult = "";
// output data in XML format
 sResult = "<complete>";
 String sThisFields="";
 TblAddressBook thisCustomer = null;
 for (int i = 0; i < results.size(); ++i) {
 thisCustomer= (TblAddressBook) results.get(i);
 sThisFields=thisCustomer.getAddrName();
 sThisFields=sThisFields+" "+thisCustomer.getAddrNum();
 sThisFields=sThisFields+" "+thisCustomer.getAddrCity();
 sThisFields=sThisFields+" "+thisCustomer.getAddrCounty();
 sThisFields=sThisFields+" - "+thisCustomer.getId();
 sResult = sResult + ("<option value=\"" + (thisCustomer.getAddrName().replace("&","&amp;")) + "\"><![CDATA[" +
 sThisFields + "]]></option>");

 }
 sResult = sResult + ("</complete>");

 return sResult;

 }

Simples!

In a sense ofcourse you could move ALL your JSP code into EJB’s and actually have ONE JSP for your whole web site!