Wednesday, 18 June 2008

Ext Javascript tools

I've always avoided using javascript. I truely hate javascript. Having said that I recenlty found myself having to add a tabbed section to a web page and I really could not be bothered to mess about. So I turned to Ext javascript tools library. It really made a nasty job actually quite easy. I was using the TabPanel, a couple of lines of code from the very good api example got me up and running and the resulting table showed good browser compatability.

write the javascript, include the required library files and stylesheets in the html page and off you go....

Here's my create tab javascript code:

/*
* Ext JS Library 2.1
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/

Ext.onReady(function(){
  // basic tabs 1, built from existing content
  var tabs = new Ext.TabPanel({
    renderTo: 'tabs1',
    width:620,
    activeTab: 0,
    frame:true,
    border:true,
    defaults:{autoHeight: true},
    items:[
      {contentEl:'tab1', title: 'Originating Number(s)'},
      {contentEl:'tab2', title: 'Recurring Charges'},
      {contentEl:'tab3', title: 'Cost Centre(s)'}
    ]]
  });


  function handleActivate(tab){
    alert(tab.title + ' was activated.');
  }
});


Then in my HTML page....

<div id="tabs1">
    <div id="tab1" class="x-hide-display">
    <p>
        tab1 text here...
    </p>
    </div>
    <div id="tab2" class="x-hide-display">
    <p>
        tab2 text here...
    </p>
    </div>
    <div id="tab3" class="x-hide-display">
    <p>
        tab3 text here...
    </p>
    </div>
</div>



Job done. comes all styled up and looks great.


You can mess with the options available in the API and take it from there.

Monday, 2 June 2008

Enterprise Web Apps with JSF, EJB3.0 and JPA

Just got back from a training course on the above. Very cool. I really enjoyed it. Having used Struts for years I've always been irritated that MVC architecture was a complicated as it was. It never really felt as though it had been given the attention it required. JSF on the other hand feels like MVC the way it should be. Navigation rules are simple and obvious. Some people suggest that there's little difference between Struts MVC and JSF. At first glance I agree it does seem that the difference isn't very great. You really notice it when you develop in JSF in production.

I have to say that so far JSF promises a lot but seems under developed, however I'm not sure if this is just my lack of knowledge. So I went out and bought the book "Core Java Server Faces" Prentice hall. Which basically says how to do all the good stuff that wasn't in the course!

Now JSF is officially part of JEE it's popularity is sure to increase faster than ever.

EJB3.0 was a vast improvement on previous EJB versions. I took a look EJB 2.0 a while ago but the overhead was so vast that we deemed it too heavy for our requirements. Now I think that's changed. Although I don't have need of most of it's attributes. If/when I start dealing with more distributed transactional systems I'll certainly re-evaluate EJB as a possible solution.

JPA - great as ever really simplifies the persistence process