December 04, 2008

Smile in the sky!

I took this snap on monday using my mobile. Two stars and moon gave this beautiful formation! :)























November 30, 2008

Building a simple OSGi Service

I have been experimenting with this technology and the main inspiration came from SpringSource's dm Server. Like other OSGi evangelist,I am beginning to see OSGi technology as technology that will transform Java development. I would like it to be more on the enterprise side. In this session, we will see how to build a simple service and consume it.

I started of my OSGi quest with Equinox and Eclipse IDE. But for the tutorial that we have today, we do not need Eclipse as it's a simple application (bundle). You may also use other OSGi runtime like Apache Felix or Knopflerfish. Knopflerfish even gives you are good GUI to work with. I will not be explaining fundamentals of OSGi technology. You may refer the technology overview, technical whitepaper and business whitepaper for more information.

What's OSGi service?
In very general terms, a service is a repeatable task. When it comes to business, any repeatable task in your business process is a service. Similarly in a application, you can have generic tasks (even specific tasks) that are repeatedly used can be represented as service. Representing and using these tasks as services is what SOA is all about! But that' at an enterprise level. When it comes to OSGi services, it is the same concept but applied at JVM level.

In OSGi, a service is a plain java object which is published to a registry. A consumer can consume the registered service through lookup. A service a be registered and unregistered at any point of time. Service is built using interface-based programming model. To implement or build a service you basically provide implementation to a interface. To consume, you only need the interface for the lookup and there is no need to know about the implementation. The service registry is the "middle man" who help producers and consumers to get in touch with each other.

Building HelloWorld service
The first step would be to create our interface or "front end" of our service. For our service, we will have a simple interface named IHelloService:
package org.tp.service.helloservice;

public interface IHelloService {
public String sayHello();
}
And here is our service implementation.
package org.tp.service.helloservice;

public class HelloService implements IHelloService {
public String sayHello() {
return "Hello World";
}
}
That's it! Our service is ready for use. But, we need to inform consumers that the service is ready to serve. For this, we will have to register our service with the OSGi service registry.

OSGi framework provides us with standard APIs to register and unregister service with the registry. We will use the registerService method to register as shown below:
serviceRegistration = context.registerService(IHelloService.class.getName(),helloService,null);
I am sure for beginners this is not enough. Let's explain the stuff little further.To register our new service, we will build a simple bundle that will call registerService method.
package org.tp.service.helloservice;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

public class Activator implements BundleActivator {

private ServiceRegistration serviceRegistration;
private IHelloService helloService;

public void start(BundleContext context) throws Exception {
System.out.println("Starting HelloService Bundle..");
helloService = new HelloService();
serviceRegistration = context.registerService(IHelloService.class.getName(),helloService,null);

}

public void stop(BundleContext context) throws Exception {
serviceRegistration.unregister();
}

}
Our Activator class implements BundleActivator. Basically, its a simple OSGi bundle with start and stop methods. We will register our service with the bundle starts up and unregister when the bundle is uninstalled from the framework.

Now lets have a closer look at start method. We create a instance of our service and then use registerService method. The first argument is service name which is obtained using InterfaceName.class.getName(). Its a best practice to use this method instead of specifying the name as string (org.tp.service.helloservice.IHelloService). The second argument is the instance of the service itself. And the final argument is Map wherein developers can pass additional properties to the service.

To unregister the service, we simple call unregister method when we stop the bundle. So now we have a running service on our OSGi runtime. Lets see how to consume it.

Consuming a service
To consume a service, we first create serviceReference object form the BundleContext. This can be achieved by calling getServiceReference method. The method takes the class name as a argument. Once you have the serviceReference object, we will use getService method to finally get the service. We will have to typecast the object returned by getService method before using it.
helloServiceRef = context.getServiceReference(IHelloService.class.getName());
IHelloService serviceObjectHelloService = (IHelloService)context.getService(helloServiceRef);
System.out.println("Service says: " + serviceObjectHelloService.sayHello());
Implementing the service and consumer is the same package is easy. Because, the interface is available. When you have your service and consumer bundle separate, there are some important points to note. OSGi provides the capability of specifying the packages they can be exported or imported. With this facility you can expose your service interface and hide its implementation from the public. The configuration details are specified in the MANIFEST file. Have a look at our HelloService's MANIFEST file:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: HelloService Plug-in
Bundle-SymbolicName: HelloService
Bundle-Version: 1.0.0
Bundle-Activator: org.tp.service.helloservice.Activator
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0"
Export-Package: org.tp.service.helloservice;uses:="org.osgi.framework"
Notice that we have exported org.tp.service.helloservice package. Similarly, we import this package in our consuming bundle.

You may download the complete code of this tutorial. I have two eclipse projects, HelloService – implementation of the service and HelloBundle – will consume the service. And to add some notes; The code used for consuming the service is not the best way. I have made the code very simple and easy to understand without involving Exceptions handling,Null pointer checks and ServiceListeners. We will have a look at ServiceListeners next.

November 14, 2008

Gift from Jimdo, or just a Spam?

I am not sure if you know about Jimdo. I had blogged about the service some time back but, this time around I have a different reason to write about Jimdo. For an intro, Jimdo is a free web site creation tool. The service allows you to build your pages integrating images, video with different designs.The service also boost about the feature of copying themes and design of other sites in simple steps. Recenlty, I got a mail from one of the employees from Jimdo (atleast he looked like) and that's when all things started!

This was an unusual mai. Basically, the content was posted through my Jot Form. The message was from some one named Till and claimed to have the mail id "till@jimdo.com". There is the message:
We from Jimdo would like to send a little "Thank you" to all who have been spreading the Jimdo news online throughout the past 1.5 years.

Therefore we would appreciate if you could send us your address as soon as possible.

With regards,
Till
And my response to this mail not with a mail with my address, but a simple note to know if this was genuine! And so far no reply. So was this whole thing fake? Or is somebody making trouble for Jimdo?

November 06, 2008

Sun Introduces OSGi based Server: Glassfish V3

Sun Microsystems announced the availability and support of the their latest application server: GlassFish version 3 Prelude. The application server is a lightweight and based on modular architecture. The new server is also a preview to the next version of java enterprise edition (JEE 6). Let's have look at Gfv3's features.

GlassFish is one of the leading open source application server. Sun claim to have more than 14 million downloads of the server. But I wonder how many are used in production environment and not by students and developers (I have a regirstered version of Gfv2 on my laptop)? The new version of server was redegined from top to bottom to run on the popular modular runtime called OSGi runtime. Glassfish makes use of Apache Felix, an open source OSGi runtime from Apache. Sun claims that, the application server can also run on Eclipse's Equinox runtime.

The server brings in lots of changes in how an application sever works. The server startup time is drastically reduced compared to the pervious version. This was acheived by the way how classes are loaded in the server. At startup a full fledged application server do not start, instead only the necessary modules (containers) get loaded.Containers do not get loaded unless they have a component to execute. For example, EJB container do not start untill I have a EJB depoyed.

The server comes with a full web container that can host servlets 2.5, JSP and JSF. JSF 2.0 is provided as preview. Developers can also have a first look at EJB 3.1. They can also make use of the JPA for persistence. Sun introduces the concept of a update center from which you can download other modules like web service stack or Jersey . The server also introduces containers that support native jRuby/Rails, Groovy/Grails.

The major advantage for a development team from GlassFish is that it provides the ability to maintain the sessions active even during deployment. This feature helps both developers and testers to test the code, refine them if need and test it rather than going through the long cycle that we currently go through. So next time you find a bug when testing your code, all you need to do is change your logic, deploy and start testing with the same session. Netbeans 6.5 is said to have good integration with the new server, providing deployment of new code on the server as and when you save the code and its compliation error free! Other advantages includes the availability of easy to use admin and cofiguration tool and server being available for all major platforms.

Now we have SpringSource,IBM and Sun implementing application servers on OSGi technology, are we seeing the tsunami of OSGi support and implementation? Even thought these changes do not provide a visible change to the end users, JEE seems to be adopting OSGi technology at a large scale. I am sure Oracle will come up with an implementation using their (orginally BEA's) mSA technology, which is based on OSGi.

November 02, 2008

Introducing SpringSource dm Server

Spring framework has been an unofficial standard for buliding java based enterprise applications. SpringSource, the company that developed Spring framework recently launched SpringSource dm Server, a completely modular, OSGi-based Java server to run enterprise Java applications. dm server brings simplicity to both developers and operations team.

Since I am a developer, I will start with advantages of have a OSGi based application server. I did play around with the dm server release 1.0. The startup time for the server is very small (15 seconds with my web web applications installed). Major advantage would be the deloyment of new application do not need a server restart. This reduce the development team's development,deplyment and test cycle and provide a platform for Agile development. SpringSource Tool Suite, the IDE from SpringSource is very tighly coupled with the server. My first application and its deployment was seamless. Even though the server supports deployment of application as war file, the company has come up with a different strategy to bundle the application. The application development is also bit different. Application is more OSGi oriented and most of your application's configuration goes into the manifest file and not into web.xml

Onto operations team, they can forget application server restarts on each deployment. Keeping tack of all the lbraries are easy and the server is very configurable. But these are the statements all the other server's boast about right? But other application servers do not provide the flexibity that dm server provides. I would say the server is still young. Currently, the server do not support clustering. But when you have these features built-in, with other features like capability to run EJBs and other java enterprise component it would be great.

The dm Server
The dm server is build on Eclipse Equinox and based on SpringSource Dynamic Module Kernel (dm-kernel). The kernel provides a modular tomcat, spring and other OSGi based technologies. The server is licensed under GPLv3 but some components are EPL and spring framework is licensed under Apache software license. You are free to download the server and its tightly integrated IDE from SpringSource. I would say all J2EE developers should have a look at this server and its programming model.

SpringSource and Its business perspective
Look at all other application server providers: IBM,JBoss,Oracle (Weblogic) or even Apache. All have their own application sotfware stack like Seam of Jboss, ADF of Oracle. Spring framework had the application stack but didn't have a complete product range – Application server and IDE. And now they have it! But the difference they brought in is that they didn't follow the same arhitecture as other companines. They brought in OSGi technoloy into main stream java enterprice basically. With the evolution of dm server, I am sure there will not lot of stuff pushed into OSGi. SpringSource have already recommed new features for OSGi. Now, they have a whole range of product to sell: application server,IDE and of course support for spring framework.

Some developers using Spring are not so happy with how SpringSource handle the support (as far as I understood from the forums). But I see that they have a business model in place to compete with other application servers.

Now, thats one perspective. The other part is, SpringSource being asquired by Microsoft. I don't see much news on it except in InfoQ. In an interview with Rod Johnson and InfoQ they talk about how SpringSource and Microsoft team are working on integrating spring into Windows products like Office, Visual Studio and the OS itself. Will Windows 7 have Spring pre installed? What will its main contribution be to the OS? We still have time to find out!

October 19, 2008

Yahoo Introduces Y!OS, opens up itself!

Yahoo recently launched what is called "Rewriting of Yahoo", Y!OS: Yahoo! Open Strategy. The strategy is to open up everything to developers including content,traffic and Yahoo's user base. Developers will be able to use all the open assets, build application on them and even display them on their web site. The platform is being introduced with the introduction of social suite or more popularly Social API.

Y!OS is built on three things:
  • Yahoo! Social Platform
  • Yahoo! Query Language
  • Yahoo! Application Platform
The social platform enables yahoo users to experience the socializing of web. Yahoo has been experimenting with web socialization using Y!360 and then Mash. But both of this products did not click. The new platform will aggregate relationships in Mail, Messenger, Address Book, and other social areas of Yahoo! to recommend connections to our users. For this Yahoo profiles is also revamped! For developers, all these profile data will be accessible using RESTful APIs.

YQL is the single point entry for developers to query, filter and combine data from Yahoo. It will provide SQL like statements in its query language. Apart from this developers will also have access to RSS and HTML pages to get information. You can get more information from YQL documentation.

YAP brings the front end! It will allow the developers to easily author and publish application across Yahoo network. developers will have Java script, server side scripting (YML) and flash at their disposal for developing applications. These application can be easily embedded into Yahoo Mail, Yahoo Front Page etc. This is many made possible using Yahoo's SearchMonkey platform.

All in all, yahoo is opening up like Google, integrating applications available for users and basically socializing. But I see most of these things are already available with Google. So will these platforms give Google a competition?

September 18, 2008

Introducing Brainwave application framework

Brainwave is a web based web application development and deployment stack built around the following principles:
  • Product centric
  • Design oriented
  • Technology driven
  • Mecca for developers
It comes with a built in Database, web server, widget library and security stack and enables rapid application development. The application suite is a product of “The Sureka Group” and I am going to take you into this application suite today.

Brainwave enabling developers in creating a rapid application development environment by reducing the amount of time spend on each life cycle of application creation. This is said to be achieved by having all the three layers (UI, Middle and DB) of the same vendor. Thus reducing the amount of time spent on integrating different layers of an application. Its database does not require you to create schemas for storing data. Instead, can put different information onto the database and link them.
Architecture
The entire application suite is split into 6 parts namely; Aphrodite, Iris, Gaea, Poseidon, Cerebus and Hermes.
Iris is the communication engine that connects all the components together and forms the application server. It’s designed for easy deployment and supports multiple application deployment.

Poseidon is another unique component of Brainwave platform. It is the schema less database that hold the information.

Gaea provides the mechanism to plug and play third party application from different vendors.

Cerebus provides necessary security around the Poseidon database.

Aphrodite takes the responsibility of application development mechanism. Developers can make use of templates that speed up development of their application and they need not code from scratch.

Hermes helps in implementing web service and exposing other web service to Brainwave application.

The entire system runs as a service on the OS. Another important aspect of the suite is that, it’s written in Python which is a very powerful OOP language. Here is the complete list of features provided by the development platform. If you need to have a feel of the platform try the online demo.

So that’s the introduction to Brainwave application development platform and it’s time for me to take a break.

September 15, 2008

Tim Berners-Lee's World Wide Web Foundation

Sir Tim Berners-Lee, inventor of the world wide web, announced a new web foundation called World Wide Web Foundation. The foundation will aim at:
  • Creating "One" web that is free
  • To expand the Web's capability and robustness
  • To extend the Web's benefits to all people
The new foundation is planning to rope in business leaders, technology innovators, academia, government, NGOs, and experts in many fields to tackle challenges.

So what's WWWF going to do different compared to W3C or Open Web Foundation? Lee identifies three avenues — technology innovation, Web Science, and the application of the Web for the benefit of underserved communities. W3C will continue building standards that so that the Web remains accessible to people with disabilities, and does not have an inherent bias towards any particular language, writing direction, or culture.

The foundation promises to accelerate the Web's advancement and growth around the planet and is calling for fund donors. You can read Lee's speech on WWWF site (I am still waiting to see the video).

September 06, 2008

Acronyms that bind business and technology

This is might not be new to you but each day I learn an new acronym thats connected closely with business and information technology. It all about enterprise utilizing the computing power that have to get maximum profit, compete with others and and of course a better visibility of the entire business in real time.

Let me start with BPM: (first one I came across)

BPM (Business Process Management) is about defining, managing and controlling the business processes that underpin your business.

BI (Business Intelligence) refers to technologies, applications and practices for the collection, integration, analysis, and presentation of business information.

CPM (Corporate Performance Management) is a set of processes that help organizations optimize their business performance. It is a framework for organizing, automating and analyzing business methodologies, metrics, processes and systems that drive business performance. Its also know as Business Performance Management (BPM). (Yet another BPM acronym)

EDA (Event-driven architecture) is a software architecture pattern promoting the production, detection, consumption of, and reaction to events.

CEP (Complex Event Processing) is primarily an event processing concept that deals with the task of processing multiple events from an event cloud with the goal of identifying the meaningful events within the event cloud.

BAM (Business Activity Monitoring) is software that aids in monitoring of business activities. It alerts businesses to problems, issues, goals met or other indicators of how well a process is executing, typically in real-time.

EDM (Enterprise Decision Management) deals with all aspects of managing automated decision design and deployment that an organization uses to manage its interactions with customers, employees and suppliers.

Well along with this we also have SOA which an important software architecture and have enabled implementation and integration of all the concepts I mentioned above.Integration is the key word here. All these implementations working need to work together to bring a big picture to BAM. It will alert the manager when a goal is achieved, when to take a decision and status of a process. Its also possible to make EDA take decision when a event occur rather than just notifying people of the event occurrence.

So if you are a developer or architect or business analyst, you really need to look into all these!

August 23, 2008

Creating custom menu in Documentum 6

WDK of Documentum 6 brings in come major enhancement for developers. The new library is Section 508 compliant and has also undergone user testing for accessibility and usability by the NFB (National Federation for the Blind). The list of new features is a big list including change to UI like right-click context menus, XML-based fixed menus that can be modified or extended, Configurable keyboard shortcuts etc. In this post we will see how to add a menu to the menu bar using configuration elements rather than extending menubar component.

In previous versions on WDK, you would have extended the menubar component and placed the xml in custom/config folder. You would also move the menubar.jsp with your new menu and menu items. In D6, things are little different. Let me quote from WDK tutorial PDF:
In earlier versions of the Web Development Kit, you would extend and override the configuration information files that come with the product as shipped. That approach still works. However, in Version 6, you have the option of modifying the user interface by adding, removing, or replacing individual configuration elements.
And this is exactly what we are going to do today. The concept of configuration elements is a great advantage to developers. By just changing XMLs you can modify the component. There is no need to extend each component for a minor change. This concept also makes the customizations more manageable and developer friendly.

WDK introduces component modification instead of extending it. To modify a specific component all you have to do is create a XML file in custom/config and specify the component you need to modify using modifies attribute of component element. Have a look at the below XML where I simply add a new menu item in tool menu of the webtop:
<config>
<scope>
<menuconfig modifies="menubar_tools_menu:webcomponent/config/library/menubar/menubar_component.xml">
<insert path="menu[name=tools_menu]">
<actionmenuitem dynamic = "genericnoselect"
name = "hello_world_menu_item"
id = "hello_world_menu_item"
value = "Hello World"
action = "hello_world_action"
showifinvalid = "true"/>
</insert>
</menuconfig>
</scope>
</config>
The XML is simple and clean. In earlier versions, you will have used the “extends” attribute and specified the component you are extending. Here we just specify the component you want to modify and specify the section (in the above case menubar_tools_menu). WDK offers five different configuration elements: insert, insertafter, insertbefore, replace and remove. You can use these elements to modify any component.

An important change to notice is the way how menu component works. If you open menubar_component.xml in /webcomponent/config/library/menubar you will notice that all the menu and menu items are declared as part of the component.In previous versions, this would have been part of the JSP. Also notice each menu is defined by the tag menuconfig. These entire menus are declared in menuconfigids element as shown below:
<menuconfigids>
<id>menubar_file_menu</id>
<id>menubar_edit_menu</id>
<id>menubar_view_menu</id>
<id>menubar_tools_menu</id>
</menuconfigids>
To add a new menu, we will have to modify the menuconfigids and our custom menu into it. Let’s see how we will insert a new menu into menuconfigids:
<component modifies="menubar:webcomponent/config/library/menubar/menubar_component.xml">
<replace path="menuconfigids">
<menuconfigids>
<id>menubar_file_menu</id>
<id>menubar_tools_menu</id>
<id>my_tools_menu</id>
</menuconfigids>
</replace>
</component>
And to define the menu and one menu item:
<menuconfig id="my_tools_menu">
<menu name="Level1" value="Level One">
<actionmenuitem dynamic = "genericnoselect"
name = "hello_world_menu_itemx"
id = "hello_world_menu_itemx"
value = "Hello World"
action = "hello_world_action"
showifinvalid = "true"/>
</menu>
</menuconfig>
So finally we have a single XML containing the above two fragments:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<config version="1.0">
<scope>
<menuconfig id="my_tools_menu">
<menu name="Level1" value="Level One">
<actionmenuitem dynamic = "genericnoselect"
name = "hello_world_menu_itemx"
id = "hello_world_menu_itemx"
value = "Hello World1"
action = "hello_world_action"
showifinvalid = "true"/>
</menu>
</menuconfig>
<component modifies="menubar:webcomponent/config/library/menubar/menubar_component.xml">
<replace path="menuconfigids">
<menuconfigids>
<id>menubar_file_menu</id>
<id>menubar_tools_menu</id>
<id>my_tools_menu</id>
</menuconfigids>
</replace>
</component>
</scope>
</config>
A simple WDK refresh will make your menu appear on webtop! That's all and it's time for a hot tea :)

August 01, 2008

Experience with Cuil

Cuil, the new search engine seems to be a big buzz on internet this week. This is mainly for two reasons: One, they claim to have indexed more web sites than Google and second that it was developed by ex-Google employees. Even with these claims, I feel the search engine poor to Google or other competing search engine. The only stand out being the way they display search results. Here is my experience using cuil.

Starting with the name “cuil”, which is pronounced cool, does not sound good! This might be very personal comment and might sound irrelevant compared to other experience I had. Google has become an english word we commonly say “I am going to google it”. But “I am going to cuil (cool) it” sounds little wired.

Leave apart the silly issue, I found cuil delivering me irrelevant data and redundant once. My first test on the search engine was to search for my-self! Interesting thing is showed me pictures of someone else. It also to me to an explicit site when safe search was turned on! Regarding the redundant results entries, the engine displayed the same entries on far pages.

Other issue with the engine is that they do not have much of a preference. You can only can only turn on/off the safe search and typing suggestions. There is no search by file type, date, etc.

Major advantage is how the results are displayed. On searching “java programming”, the engine provided me an accordion on exploring by categories. But it’s sad that cuil do not suggest word if you miss spell!

So, what do you think? Can a product developed by ex-Google employees be so badly written? Or is it just the beginning of a new search engine? Because Google was not built in a day!

July 22, 2008

I am frustrated with Geronimo!

For those who don’t know, Geronimo is a project from Apache aimed in creating a Java EE 5 application server using open source. It is also certified by Sun for its compatibility with java EE specification. Apache claims the server to be very developer friendly, easy to use and easily integrate with IDEs like Eclipse. All my hopes failed when in installed it on my Vista!

Yes, I am a frustrated developer now! My laptop comes with Vista Home and I am simply not able to start the Geronimo server on it. At the same time, I am able to run the server and play with it on other Microsoft OS like Windows XP, Windows Server 2003.
So what did I do? I contacted the Geronimo user group at Nabble forums. After one week I still have no solution! Its not that I got a reply.. Its simply that none of the options work out. Here is what I have tried so far:
  • Try running the server from C:\geronimo
  • Try running the server from C:\user\\geronimo
  • Try running the server from another Drive
  • Try running the server from C:\Program Files\geronimo
  • Try running the server after disabling firewall in the above mentioned locations.

Does anybody have a solution???

July 09, 2008

What is Cross Site Scripting (XSS)?

Web sites have become quite complex and dynamic in nature these days. They have incorporated features that increase user experience and make browsing enjoyable. With new features come new troubles too. One major and popular threat is "Cross Site Scripting" but security professionals call it XSS. In this article, I will explain what it is and how as a netizen, avoid an attack.

So, what is XSS? Cross Site Scripting (XSS) is said to occur when a web site collect malicious data from a user. The attacker adds the malicious code in a form or link. Usually the code is encoded in HEX or other encoding methods. For a normal user the link or form appears normal and part of the web site. On accessing these links, the data about the user collected. Along with this, the code creates an output that looks genuine. For example, Orkut user would have received java script that can be executed through the Orkut scrap box. The script gives interesting output that look harmless but, it is easy for the attacker to hijack my session and use it.

XSS can be in the form of JavaScript, VBScript, ActiveX, HTML, or Flash. And using XSS you can hijack accounts, manipulate with user settings, steal cookies or poison them, and also do false advertising. This attack can even occur on a secured site too. The lock on your browser does not mean that you are secure for XSS!

So what do we do? As a common user here are few things that you can do to prevent XSS attack:
  • Always follow links from the main website. For example, if you see link to news article of site X on site Y. It is better to open site X, use its menu or search feature to get the news or article.
  • Think twice before you click on ads placed on less know web sites. If an ad interests you, google it and view the site!
  • Be careful in opening your emails, its attachments etc.
  • Keep internet security at high level in your browser.
These actions might help you from XSS attack. At the same time, browser vendors like Mozilla and Microsoft have started their war against this attack. IE8 team recently demonstrated their XSS filter on IEblog. From Firefox, you already have add-ons that help you detect and prevent XSS.

June 25, 2008

Nokia to open source Symbian and start a new revolution

Big mobile players Nokia, Sony Ericsson, Motorola and NTT DOCOMO anounced they are all set to open source the Symbian mobile OS. Nokia will buy 52% of Symbian. This acquisition will be the first step in the establishment of the 'Symbian Foundation'. And Nokia will join two other major platforms; Google's Android operating system and Apple's OS X iPhone.

The new foundation will provide unified platform with common UI framework. Initially, they will release selected components as open source and gradually make the complete software open source. The platform is intended to be released under Eclipse Public License (EPL) 1.0. Nokia had recently acquired Trolltech which also provide a mobile software platform. But now, they will have the most widely used mobile OS unified and taking on Android and iPhone!

June 05, 2008

Using XSL-FO to create PDF files

Libraries like iText,PDFBox are some of the best libraries available for PDF creation and manipulation. But these libraries have its disadvantages. One such disadvantage is templating the PDFs you create. In a enterprise where reports (PDF files) are generated automatically and routed to work-flows or stored in content management repositories. These reports follow an enterprise level style and pattern which can be reused, can change and will require proper management. Hardcoding styles and formats of reports into your application can cause lots of issues in future. That's when XSL-FO and Java (or other language) come into picture. In this article I will introduce XSL-FO and Apache FOP.

Let me intoduce XSL-FO first. XSL-FO stand for Extensible Stylesheet Language Formatting Objects and is a language for formatting XML data. It was initially part of the XSL W3C recommendation. So W3C has come up with XSLT for transforming XML documents and XSL-FO for formatting. XSL-FO documents are XML files that contain information about the output layout and output contents. But they do not specify the content type of the output. This output can be any document type; all you need is a transformation library that transform the XSL-FO to the appropriate content. In this article I will make use of Apache FOP, which is part of Apache XML Graphics Project.

First look at XSL-FO:
Here is a sample XSL-FO file. Like any other XML file, its starts with XML declaration:
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>
<fo:simple-page-master master-name="A4">
<fo:region-body margin="2cm" />
<fo:region-before/>
</fo:simple-page-master>
</fo:layout-master-set>

<fo:page-sequence master-reference="A4">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello World!</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
The element is the root element of XSL-FO document. contains one or more template pages and master-name attribute specify the name for the template. elements describe the page contents. contents are not directly placed, they are placed inside a flow which in turn hold block. Each block can hold the data that is displayed. For further details please go through the tutorial.

Apache FOP:
Apache FOP (Formatting Objects Processor) claims to be the first processor that reads a formatting object (FO) tree and renders the resulting pages to a specified output. The primary output format is PDF but the following formats are supported:
  • PDF (Portable Document Format)
  • PS (Adobe Postscript)
  • PCL (Printer Control Language)
  • AFP (MO:DCA)
  • SVG (Scalable Vector Graphics)
  • XML (area tree representation)
  • Print
  • AWT/Java2D
  • MIF
  • RTF (Rich Text Format)
  • TXT (text)
Using the FOP library, you will be able to process any XSL-FO and render it to PDF. The library is very simple and straight forward. Since all the details of formatting is in the XSL file, all we need is to make use of the transformation API to transform and generate the output. This content is stored as file on your file system. FOP makes use of JAXP. Have a look at the Java application to transform a simple XSL-FO document into PDF.
OutputStream outputPDF = new BufferedOutputStream(new FileOutputStream("hello.pdf"));

FopFactory ff = FopFactory.newInstance();
Fop fop = ff.newFop(MimeConstants.MIME_PDF, outputPDF);
TransformerFactory factory = TransformerFactory.newInstance();

Transformer transformer = factory.newTransformer();
Source src = new StreamSource(new File("hello.fo"));
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
For your reference, you may download the sample application. Like I mentioned, the main advantage will be to use XSL for formatting and designing the templates of different and simple use the API to generate the complete report. This way, all reports will have consistency and it will be easy to modify the reports style if necessary.

May 28, 2008

Google Introduces AJAX Libraries API

With plenty of open source AJAX libraries out there (and increasing), Google has come up with the idea of host the most popular once. This will developers instant access to AJAX libraries like jQuery, Dojo etc. Web developers ; I would say mostly people who have blogs and wikis hosting on free services like blogger, wordpress etc, will now be able to use these libraries by just loading them using the new API.

AJAX Libraries API will simply help you to loading architecture for the most popular open source Java Script libraries. These libraries are hosted on Google's servers. Developers can use Google's API loader's google.load method to load the library. Presently, Google hosts the following Java Script libraries:
  • jQuery
  • Dojo
  • prototype
  • script.aculo.us
  • MooTools
And Google promises to keep the list growing! Google has struck a deal with all these libraries to host the latest versions as they release. But I am not sure for how long they will retain the old versions. The major advantage of using this API will be the ability to access these open source libraries even without hosting them. Also, you will be able to use features from multiple libraries in your blog or web site. I am the major reason for Google to come up this library API and hosting them is to enable these Java Script libraries to their App Engine. With these libraries at developers disposal developers will be able to embed lot of UI and client side features to the web applications they develop.

All these look good, but did Google miss somebody? Or did they ignore them? I am talking about Ext JS. Ext has been recently "hot" on web for wrong reasons! I was just wondering Google really missed them or ignored them? And I don't have to comment on YUI. I am sure, Yahoo's java script library is not going to make to the list!Polities aside; lets have look at how to use this library!

Introducing google.load() Method
Google with its vast API set, has a very simple API loading technique. To use the basic API you need to load a JS from the URL http://www.google.com/jsapi. Some API will require you to have the Google API key. But the AJAX library do not require one. Developers load the necessay Java Script files on the client side using a simple method google.load(). For example; if we need to load jQuery version 1.2.3:

<script src="http://www.google.com/jsapi"></script>
<script>
// Load jQuery
google.load("jquery", "1.2.3");
</script>

Ok, so now I have the jQuery library load. How do I use it? Google also provides a callback function which is invoked once the module (library) is loaded. The callback method is specified by google.setOnLoadCallback(myMethod) method. And finally, myMethod will have all my logic!

Trying an example!
To have a feel of the need API, I just tried out some simple tasks using jQuery. Here is the example and its source:
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.2.3");

google.setOnLoadCallback(function() {

$("a").click(function() {
alert("Hello world!");
});

$("#sam").click(function() {
alert("display");
$("#hidden").show();
});

});
</script>
</head>
<body>
The content begins.. <br/>
<div class="divStyle newStyle">
<a href="http://www.google.com">This</a> is a test </div> <br/>
<div id="sam"> This is another Test <div id="hidden" style="display:none">hidden text</div></div>
The content ends.. <br/>
</body>
</html>

I will give a demo on adding some useful components and widgets from these libraries later. Till then bye!

May 15, 2008

JavaFX still has a long way to go!

I am not sure when it was launched but I just happened to see JavaFX site! One look things are quite impressive, but as you navigate I just lost the impression. I must agree that the effects are great but it was slow at certain point of time. Even made me feel that my browser had hung! But Firefox handled everything smooth. The site do not feature any demo on available widgets but have really good videos and access to preview SDK. Comparing JavaFX to its competitors, Flex and SilverLight are way ahead. Even though the FX coding seems very simple Sun needs to have a look at trimming JRE. They have been doing this with the lastest Java SE which is still in beta stage. JavaFX

May 14, 2008

Using Ext JS library in Documentum

Documentum provides a very good framework for web applications called WDK. If you have worked with WDK, I am sure you must have come across the Ajax and webtop examples. When ExtJS 2.1 was released I needed to test it features, and the idea of using Ext in Documentum struck me! Here we will integrate Ext and Documentum in a simple WDK application. We will use WDK widgets to build the regural forms but add Ext Slider widget (not available in WDK) to the form.

Integrating or mashups are not always easy. As web developer we all would think that just adding the Ext java script files to the WDK application folders will be enough to get things started. But that turned out to be wrong. So lets start with troubled water.

Troubled Water
We will have few questions first and try answering them. Where will be deploy our Ext files? Where will we access Ext files from (container JSPs or our custom component JSPs)? I will answer these questions collectively. I assume you already have a skeleton WDK application on your server and I am sure you know our customizations will go into to custom folder.

We will hold all Ext related files in customjs folder under the custom folder. And as any normal WDK application, I will have my configurations in config and create appropriate JSPs. Now lets come to the second question. We will access these files from component JSP and will use complete context path to access the java script files. The reason to use complete context path is that, container JSPs access all java script files from /wdk/include folder. Now you know the folder structure, let move to programming.

Setting up Ext
Like any other Ext enabled application I will have a appjs which hold my custom Ext files. In customjs folder I have two folders : appjs and extjs. extjs will hold all the Ext library and appjs will hold our application.js file. In our application we will just be adding a slider to the Documentum form. My application.js will look like this:
app = function() {   
var sampleSlider; 
var sliderClick = function(slider,event) {

sobject = document.getElementById("agetxt");
sobject.value = slider.getValue();

sobject = document.getElementById("sliderval");
sobject.value = slider.getValue();

}
return {
init:function() {        
sampleSlider = new Ext.Slider({renderTo:'sample-slider',width: 200,minValue: 0,maxValue: 100});
sampleSlider.addListener('dragend',sliderClick);

}   
}; 
}();
Note that I have simply initialized Ext.Slider object and rendered it to "sample-slider". I also have added a listener to listen clicks on the slider. We will come back to this later.

Programming your WDK component
I will just create a simple component with a JSP and a behaviour class. The JSP will have a form that will request Name, Age and a slider with which user can select a value. The user will be able to select his age using the slider. But the demo I have displayed a text field for the Age. Ideally we will not need this and we will use a hidden field to hold data. But why do we need hidden fields? In the behaviour class you will not have direct access to the Ext widgets. But you have access to all WDK widgets. This is where hidden field comes to rescue. From the behaviour class you will be able to access the values user sets using the slider. The listener methods that we attached to the slider helps in storing the slider value to the hidden field in the JSP page.

Finally on running the WDK application you will get a good looking Ext widget. You can download all the files (I only have the components & ext js files). But you will have to build the skeleton by yourself. Let me know if you have better ideas or problems.

May 13, 2008

Google introduces Friend Connect

Google launched its new Data portability platform called Friend Connect. The service that helps website owners grow traffic by enabling any site on the web to easily provide social features for its visitors. This these features enabled on your blog or site you will be able to attract more visitors, add social networking features with no or very less programming.

This is Google's next step in social networking. Initially they launched OpenSocial an API for social applications. Then Google profile was launched and integrated with Google Reader. Recently they added commenting (notes) feature in Google reader. Plus they have API that I need not mention (Google Calendar Data API,Google Contacts Data API etc). So with Google Friend you will be able to integrate social features like user registration, invitations, members gallery, message posting, and reviews other other applications built on openSocial. You will also be able with other social networks like facebook, hi5, Plaxo, LinkedIn etc. So, you will be able to connect people from different networks and broadcast activities to friends in their social networks.


I went through an example and was able to login using my Google ID. The application gave me options to connect with my facebook and orkut accounts. With this Google will stay way ahead in social networking and intergration. With OpenSocial around these platforms, I am sure facebook and Yahoo have lots to learn from this.

May 09, 2008

Yahoo and SearchMonkey invitation!

My week long Websphere training kept me away from mails and I was not so surprised to see a mail from Yahoo with the subject line - "Invitation : SearchMonkey Developer Launch Party 5/15". So, they are ready to launch their new approach to searching. The launch party is at Yahoo HQ on May 15th. Apart from the live demos you will get tasty food & beer.

For those who don't know SearchMonkey - Its a new open developer platform that allows developers and site owners to use semantic web standards and structured data to enhance Yahoo! Search results and make them more useful, relevant, and visually appealing.

You can register for the event at upcoming!

April 28, 2008

Adding Spry widgets to blogger

In my previous article I introduced you to Adobe's Spry framework for Ajax and explained its pros and cons. In this article, we will implement Spry into a blog and see how beautifully it works. Our aim will be to add an accordion in the right column. We will display a panel of badges, and widgets like Blog Rush and Feedjit in this accordion.

Spry provides widgets that are independent to one another and this makes it very easy to implement it restrictive environment. Another plus point is that your implementation of accordion is going to be very small. And the implementation is very simple. Once you have the downloaded Spry framework, you need unzip it and get hold of just two files located at \widgets\accordion. You need SpryAccordion.css and SpryAccordion.js files to build your project. If you want to make come changes, you can modify the CSS file. The file contains all the necessary style classes required for the accordion widget.

Once your custom modifications are done. Its time we move it on to the web! To host these two files, I will be using Google Pages. Many of you will be wondering why I am using Google pages and not other services that are specifically used to host files on web. The reason is, majority of these hosting services are bocked at corporate gateways and offices. I am not willing to mess up by blog when professionals access my blog. So, I will be using Google Pages. Coding a Spry widget is very simple. The accordion we are building will be represented as DIV tags. We will have a main DIV tag denoting the widget and each accordion panel will be represented as separate DIVs inside the main one. Each panel is further divided into panel heading and content. Both these parts are also denoted using DIV. So our widget code will look like this on completion:
<div class="Accordion" id="sampleAccordion" tabindex="0">
<div class="AccordionPanel">
<div class="AccordionPanelTab">Panel Heading</div>
<div class="AccordionPanelContent">
All the blog badges, images, will go in here.
I can have multiple para tags and other tag here.
</div>
</div>
<div class="AccordionPanel">
<div class="AccordionPanelTab">Panel Heading next</div>
<div class="AccordionPanelContent">
Content for Panel 2 goes here!
</div>
</div>
<div class="AccordionPanel">
<div class="AccordionPanelTab">Final</div>
<div class="AccordionPanelContent">
Content for the last accordion panel goes here!
</div>
</div>
</div>

Spry framework will not render the above code as accordion. We need to initialize the widget using Java Script. The initialization is also simple and straight forward as creating a object in Java using constructors. Have a look at how we initialize the widget:
<script language="JavaScript" type="text/javascript">
var sampleAccordion = new Spry.Widget.Accordion("sampleAccordion");
</script>
You can add this code into blogger template or use a HTML page element to hold the widget. Last modification to the blog is to add the CSS and widget JS files to the blogger template. This can be as simple as:
<link href="http://araotest.googlepages.com/SpryAccordion.css" rel="stylesheet" type="text/css" media="all" />
<script src="http://araotest.googlepages.com/SpryAccordion.js" type="text/javascript"></script>

You can see the demo on my testing blog where I build templates and test different functionalities. I am sure you will be confident enough to implement any other Spry widgets on a blog or site. Watchout for some interesting widgets to appear on my blog soon.

April 26, 2008

Spry framework : A less cared framework?

I wonder how many Ajax developers know about Adobe Spry? I too feel, I have ignored it for long. Everything apart, lots of question arises about a Ajax framework from Adobe. The reason? Adobe is one of the tough competitor to Ajax. With its Flex and AIR technology to build RIA, they are still ahead in RIA technology. Still in prerelease, Spry offers a way to incorporate XML, JSON or HTML data into pages using HTML, CSS, and a minimal amount of JavaScript. Lets have a look at this framework and unearth its pros and cons.

Spry claims to be "Ajax for Everyone". It provides a set of easy to implement set of widgets, effects and data handlers. The main advantage is each component in the framework can be used independently of one another. So, developers need only to include what they need! Other frameworks have lots of files and folder structure to implement widgets like accordion, tabbed panels etc. The major disadvantage of these hierarchical and dependency oriented frameworks are:
  • The framework becomes big and complex.
  • To implement a single feature, you require to host the entire framework.
  • Implementing a small feature might have a big learning curve.
  • Difficult to deploy the framework in a restrictive environment.

Spry framework is the solution to all these plus other advantages. It makes implementing features to the existing web pages very easy. The widgets created into the HTML tags and the framework do not create its own tags. This increases debugging capabilities and readability of the displayed HTML. Dojo toolkit also uses the same methodology to embed widgets. But Spry takes things further to reduce the amount of Java script involved. Advantages does not end here. Each widget is coded independent and developers need to include only the widget files he is going to use. Developer has to use the appropriate CSS and JS files. All he has to do is copy these files to his existing web site folder structure, link them from the page and all the code.

Another advantage with Spry is its ability to work in restrictive environment. Let me explain a restrictive environment. Lets assume I need a accordion in my blog which is hosted on blogger. I am going to host my external java script files in google pages and not any file sharing service available on web; the reason - many corporates blocks these sites and if I host my external files, I am guaranteed of getting my blog messed up for some users. And adding accordion can be made possible by keeping Spry files in google pages and using it in my blog. I will soon demonstrate this feature on my blog.

So why is Spry not so popular? The main reason for this could be Adobe's RIA technology using Flex and AIR. You will also notice that they have not given much UI effects to the widgets in the Spry framework. So, Flex technology itself is shadowing Spry. But Spry can be very helpful when developers need only certain functionality in their web page or application. So if you are an web developer looking to add some features to your pages, have a look at Spry framework!

April 12, 2008

Introducing Java Kernel...

Sun recently released Java SE 6 Update 10 Beta, and this release has some interesting updates to Java SE 6! With the stiff competition on the web application and RIA arena, all players are "in" to provide the best of their platform at the earliest. With this release, Sun is all set to provide some major improvements on Java Applets which has been ignored for quite long.

So, what's so great with this release? The new beta focuses on three major improvements:
  • Enhanced Java deployment
  • Improved performance and look & feel
  • Next-Generation Java Plug-In

Java, for quite long has been one of the most preferred programming language even though the size of JRE has been a issue. Once a Java application is up and running, the sailing is smooth. New JRE has been stable, fast and more reliable. But, the bottle neck was getting the application up and running. Some of the major challenges faced presently are:
  • Difficult to detect JREs, especially from a web browser
  • Difficult to automatically install new JREs
  • Large download size of JREs
  • Poor cold start performance
  • Little overlap between applets and Web Start programs
And the new beta release is aimed in solving these challenges sooner than later.

Java Kernel
The JRE provides many different APIs: Swing, AWT, ImageIO, SQL, CORBA, RMI, XML and much more. The new distribution is aimed at getting Java software up and running faster. So we have,Java Kernel which divides JRE libraries into small bundles. The kernel will include only the most commonly needed JRE components. Additional components are downloaded as needed, and the JRE will download remaining components in the background and then reassemble itself.


Java Delopyment Toolkit
Client using Java have different variety or flavor of JRE installed. Also, there JREs run on different operating systems. Detecting the JRE version is one of the major challenge and deployment toolkit will help in a consistent Java content to all these clients. The deployment toolkit will provide a powerful JavaScripts library that will help in automatically installing Java Platform for Java Plug-in applets and Java Web Start applications.

New Look and Feel
With this new release comes a new cross-platform Swing look & feel called Nimbus. It provides a polished look to applications which choose to use it. And because Nimbus is drawn entirely using Java 2D vector graphics, rather than static bitmaps, it's tiny (only 56KB!) and can be rendered at arbitrary resolutions.

Performance
This release includes improvements to patch downloading and installation. The new download engine can resume interrupted downloads automatically. It also uses a new patching algorithm which will significantly reduce the size of future updates.

Well that's all about the new release. If you want to try out these features, I suggest you quick get the early access download and have a look!

April 08, 2008

Google launches App Engine!

Google's introduces its new avatar: Google App Engine. It lets you to build your web application on Google's infrastructure. The web applications are built using
Python, BigTable and GFS. Even though the launch is just a preview release, Google promises to make web application development more simple and fun!

The App engine, once fully launched will be all set to transform the web application. Even though they are targeting existing solutions like Amozon's S3 and Zoho, the developer community is going to have lots of platforms at their disposal. With App engine, there will be no server maintenance. All you have to do is built the application and deploy it. The rest is in Google's hand. With this Google has started a new sub domain : appspot.com , just like blogspot.com. Developers will also be able to control access to the application they create. And important part is, all these are free with a storage capacity of 500 MB. I am sure Google will have a commercial part of this engine.

The application environment consist of Python runtime, Datastore API, Users API, Mail API and URL Fetch API. For now the App engine will support only Python but other runtimes are being considered. The environment includes the following features:
  • Creating of dynamic web pages.
  • Data storage with queries,sorting and transactions.
  • Automatic scaling and load balancing.
  • APIs for authenticating users and sending email using Google Accounts.
  • A SDK to develop applications on your computer.

You can download the SDK (available for all platforms) or browse through the application gallery.

April 07, 2008

Techno Paper gets its 2008 look!

Let me present you the new look of Techno Paper. The new blogger theme is built on Blueprint CSS framework, and I will call this template BluePrint. Its built on 0.7 version of the framework and I would like to thank all people behind the framework. I started learning the CSS framework by building this blogger template. And I have come up with some better features compared to my previous theme.

When starting out to build a new template, I had few things in mind. Make the template simple (less graphics and images) , provide new sections to the blog and retain existing functionalities of old template like Social Bookmarking, Peek-a-Boo, etc.And I have achieved the same with this new template. I have added two new sections to the template and they are: "Featured Article" and "From the Archive". You will see these sections on top of the article. I hope these sections become useful to readers. I am sure rest of the features will be familiar to you and needs no explanation. Let me know your suggestions about this template.

:)

April 06, 2008

db4o : Introduction to Object Oriented Database

All computer graduates must be familiar with a paper named DBMS (where we cramp about RDBMS, relational model etc). I am sure majority of you must have come across the book “Database System Concepts” authored by Silberschartz, Korth and Sudarshan. The book has one or two chapters on Object Oriented Database which most of use just skim through or doesn’t even bother to read. Even though the book only introduces the basic concepts… it was dumped deep in memory until I found db4o.

March 21, 2008

CRUD application using ExtJS and Java

Finally I have the CRUD application built on ExtJS and Java. CRUD stands for Create Read Update and Delete. This application will show how to build a simple but complete web application. I have used Java as my server side and Oracle XE to store my data. You can use any server side technology and persistence technology. Now let’s look at the application.

March 13, 2008

GNOME 2.22 Released!

The GNOME community announced the release of GNOME 2.22 after six months of development. With its aim to provide ease of use, stability, and first class internationalization and accessibility support, let’s see some of the new features of this release.

Like any other release, this release also has new features, improvements, bug fixes, and translations. New application named Cheese. Cheese lets you take photos and make videos using your computer's webcam. It’s an open-source clone of Apple's Photobooth. Vinagre is a new remote desktop client that supports multiple simultaneous connections.

Some newly introduced features include window compositing on capable platforms. By default, this feature is disabled. GNOME has also added live previews when switching windows, transparency effects, simplified keyboard settings, improvements to tomboy and much more. Evolution, GNOME’s messaging and calendar application has also evolved to support Google Calendars and custom message labels (tagging) for your email.

So far we discussed about UI and utilities enhancement, but GNOME comes with some architectural changes as well! Two major changes include: GVFS and GIO. GVFS is the replacement for GNOME-VFS and GIO, a new shared library that is part of GLib and provides the API for GVFS. GVFS will provide a network-transparent virtual filesystem layer for GTK+ and provide better APIs for developers.

I just started GNOME 2.22 VMware Live Demo download which is around 1G and can’t wait to get it downloaded. As of now, Live CD is still not available. New version will be available for installation in Fedora 9 and Ubuntu 8.04. And I am looking forward to move from Ubuntu 6.06 to 8.04! :)

March 06, 2008

Microsoft Releases IE8 beta 1

A surpise move from Microsoft! They have released the new version of Internet Explorer, IE8. And its available for download. This shows the software giant is
not going to allow Firefox creep into its market share. You can download the latest version (beta 1) but now lets have a look at what features will IE8 provide.

Microsoft had promised the availability first beta version in first half of 2008. They also promised that it will have full support for web standards. With this beta release, Microsoft is looking at web developers and designer community and detailing some of the investments in the product for this audience. That means, They are trying to avoid broken pages! IE7 broke pages that used to work in IE6, so did the other older versions.

With IE8, Microsoft wants to improve the standards conformance of the browser and bring it up to a level that's comparable to Firefox and others. Plus make it backward compatible! IE8 will have three rendering engines, two of which are the already familiar "quirks mode" and "(not so) standards mode." used in IE7 and a new engine. This mode will be activated through
<meta> tag. So you will have to add:
<meta http-equiv="X-UA-Compatible" content="IE=8" />

IE will claim to be faster and will have some exciting features like

Activities
Activities are contextual services to quickly access a service from any web page. Some commonly use tasks like "Add to Digg", send as email etc.Activities are services that the user can install and manage. They are some what like add-ons in Fire fox, but with a specific use.

WebSlices
This is a new feature for where users can get information by subscribing to content directly within a web page. They behave like feeds in short! Internet Explorer 8 Users can discover WebSlices within a web page and add them to the Favorites bar(just like fire fox).

Favorites Bar
In IE7, User where able to access their favorite with a single click. Now you will get dedicated bar on top of tabs.The favorite bar can have links, feeds, WebSlices and even Word, Excel and PowerPoint documents.

Automatic Crash Recovery
Another new feature that is already present in IE's competitors. A crash recovery functionality to prevent the loss of work and productivity in the event of the browser crashing or hanging.

Phishing Filter
This is not a new feature, but Microsoft says its improved and will have some new features added to phishing filter.

IE8 doesn't bring much of a innovation. Its competitor like Firefox 2.0 and Opera already have these features. Microsoft is bound to loose its browser market if IE8 can't make up to the features provided my others.

March 04, 2008

Getting started with Ext HtmlEditor

This is in response to the first comment I received for my previous post: All about Ext.FormPanel. My reader had requested for an example where HtmlEditor are used. And here is the response! We will learn to create forms that use the WYSIWYG editor provided by Ext.

The Basics
Ext provides developers with a good WYSIWYG editor under Ext.form.HtmlEditor. But making use of it can be bit tricky. The editor provided, is simple yet very powerful. It even has option for source editing apart from other normal options like font size, font family, colour, links etc. The library provides enough options to customize the components to user needs. Below are the important configuration options for the editor:
  • createLinkText – The default text for the create link prompt.
  • defaultLinkValue – The value for the create link value. By default the value is http://
  • enableAlignments – Enable alignment buttons.
  • enableColors – Enable foreground and highlight colour buttons.
  • enableFont – Enables font selection.
  • enableFontSize – Enables the option of increasing font size.
  • enableFormat – Enables the formatting buttons like bold and italic.
  • enableLinks – Enable links button.
  • enableLists – Provides the facility to create numbered and bullet list.
  • enableSourceEdit – Provide provision for source editing.
  • fontFamilies – Used to specify the supported font families. This is an array of font names.

Options like enableAlignments, enableColors are boolean variables and are all set to true by default. A default for will have all the options enabled. In one way, these default values cause trouble. I will explain about the troubles soon.

Now let’s create our first HtmlEditor. Out approach will be to create a simple feedback for where will ask users to enter name, email address and suggestion. This suggestion field will be represented as a rich editor. Have a look at the code:
formObject = new Ext.form.FormPanel({applyTo:Ext.getBody(),
title:'Sample form',
bodyStyle:'padding:10px',
labelWidth:60,
items:[new Ext.form.TextField({id:'tf',
name:'uname',
inputType:'text',
fieldLabel:'Name',
allowBlank:false 
}), new Ext.form.TextField({id:'ema',  
name:'email',
inputType:'text', 
fieldLabel:'E-mail'
}), new Ext.form.HtmlEditor({id:'sug',  
name:'suggest', 
fieldLabel:'Suggestion' 
})], 
buttons:[{text:'Submit',handler:buttonHandler}]     
});

Everything looks good and planned? On execution of this code, you will get javascript errors saying tip.register is null!!

The Trouble
We just failed in creating our form. What is the solution to this error? Another problem is that I didn’t get much help from documentation either. But later I figured out the problem was because we didn’t initialize the tool tip.

What is the relation between tool tip class and our editor? A simple fact: the buttons in editor’s tool bar make use of tool tips. We need to initialize QuickTip as follows:
Ext.QuickTips.init();
First HtmlEditor
All you need to do is initialize the QuickTip and then create the form. The tool tip initialization can be done in init method of your class. Here is the final working code:
app = function() {
var formObject;

var buttonHandler = function(button,event) {
alert('You clicked the button!');
};   

return {

init:function() {

Ext.QuickTips.init();  

formObject = new Ext.form.FormPanel({applyTo:Ext.getBody(),
title:'Sample form',
bodyStyle:'padding:10px',
labelWidth:60 ,
items:[
new Ext.form.TextField({id:'tf',
name:'uname',
inputType:'text',     
fieldLabel:'Name',
allowBlank:false  
}),
new Ext.form.TextField({id:'ema',
name:'email',
inputType:'text',
fieldLabel:'E-mail'
}),                
new Ext.form.HtmlEditor({id:'sug',
name:'suggest',
fieldLabel:'Suggestion'                  
})
],
buttons:[{text:'Submit',handler:buttonHandler}]            
});
} 
};
There you go! You have your HtmlEditor and forms working smooth.

The final comments
Ext forms have lots of features and forms are important part of web application. I personally feel Ext’s documentation should provide more explanation on the form elements, submitting and load of forms.

March 02, 2008

All about Ext.FormPanel !

Forms are very important part of a web application. As they play a major role in date collection and manipulation, designing a fully functional form becomes a challenging task. Ext provides all necessary widget required to build complex forms in a simple way. It also has a good validation, submit and data load functionality. I will cover creating and submitting of forms.

February 22, 2008

Implementing Section 508

One fellow programmer raised this question in jGuru forum; "if a user logs-in to my web application written in PHP in Firefox, Java Script should simulate doing 'Ctrl+' so that the screen size increases". For me it sounded like implementing one of the points mentioned in Section 508. Section 508 was an amend to US congress which says electronic and information technology should be accessible to people with disabilities. Many sites like BBC have implemented this. Let have a look how we can implement one of the point in Section 508.

Here we will implement in a very small way. The solution I have provided is not complete, but you need to take it forward and modify if you need to use it in blogs or sites. For experiencing a good implementation of Section 508 check out this.

The Requirement:
As a simple statement: Provide keyboard shortcuts to increase and decrease font size in a browser. Usually sites will have button where users can select the size, font and even colour of the page’s text. In this work, we will focus on to provide button to increase and decrease font size and also provide keyboard shortcut.

Why Keyboard shortcut?
Until recently, web application never supported keyboard shortcuts. They have become famous through Gmail and Google Reader and it has been success ever since. Providing shortcuts to you web applications and web pages can improve the productivity of the user. It can also help in quick navigation. But the problem is providing a “standard” set of shortcuts which will work on all browsers. For example, you can increase the font size in Firefox with “Ctrl + Plus”, but this is not applicable in IE.

Our implementation:
We will have a non-standard keyboard shortcut to increase and decrease the font in our implementation. :( (I can’t help it!). To handle keyboard events through javascript you will find many libraries available on web. I will be using the openjs library and the reason? It’s a simple, single file library. To keep your implementation simple and easy to handle we will have the styles, script and HTML in one file.

To start with, we will be using CSS to apply style to all content in your page. Let say we have many styles, but what we need is the list of CSS class which needs to be updated when user request to increase or decrease font size. We will update all these CSS styles through JavaScript when user click on the appropriate button or hit the keyboard shortcut. To handle keyboard, we will initialize listeners in an init method.
shortcut.add("Ctrl+Shift+A",increment);
shortcut.add("Ctrl+Shift+Z",decrement);
This method will be called on onLoad event of the web page. We will track Ctrl+Shift+A and Ctrl+Shift+Z keystrokes and the appropriate methods will be called (increment and decrement).

To modify the font attributes, we need to search through styleSheets object list of a document. I have created my own method to do so.

function getStyleByName(styleName) {
for (i=0; i<document.styleSheets.length; i++) {
if (document.styleSheets[i].cssRules) {
for (j=0;j<document.styleSheets[i].cssRules.length; j++) {
if (document.styleSheets[i].cssRules[j].selectorText == styleName) {
return document.styleSheets[i].cssRules[j].style;
}
}
} else {
for (j=0;j<document.styleSheets[i].rules.length; j++) {
if (document.styleSheets[i].rules[j].selectorText == styleName) {
return document.styleSheets[i].rules[j].style;
}
}
}
}
}
Given a CSS class name, the method traverse through the styleSheets objects and return the style object. In this example we will modify only one style, but if you need to modify multiple CSS styles, you will have to stores these names in an array.

Now have a look at the complete code:
<html>
<head>
<style>
.divStyle {
color: red;
}
.newStyle {
font-weight: bold;
}
</style>
<script type="text/javascript" src="shortcuts.js"></script>
<script type="text/javascript">
//<![CDATA[
function getStyleByName(styleName) {
for (i=0; i<document.styleSheets.length; i++) {
if (document.styleSheets[i].cssRules) {
for (j=0;j<document.styleSheets[i].cssRules.length; j++) {
if (document.styleSheets[i].cssRules[j].selectorText == styleName) {
return document.styleSheets[i].cssRules[j].style;
}
}
} else {
for (j=0;j<document.styleSheets[i].rules.length; j++) {
if (document.styleSheets[i].rules[j].selectorText == styleName) {
return document.styleSheets[i].rules[j].style;
}
}
}
}
}

function testStyleSheet() {
var styleObj = getStyleByName(".divStyle");
if(styleObj) {
alert('style.font-size: ' + styleObj.fontSize);
} else {
alert('style not found.');
}
}

function increment() {
var styleObj = getStyleByName(".divStyle");
if(styleObj) {
styleObj.fontSize = "20px";
} else {
alert('style not found.');
}
}

function decrement() {
var styleObj = getStyleByName(".divStyle");
if(styleObj) {
styleObj.fontSize = "10px";
} else {
alert('style not found.');
}
}

function init() {
shortcut.add("Ctrl+Shift+A",increment);
shortcut.add("Ctrl+Shift+Z",decrement);
}
//]]>
</script>
</head>
<body onLoad="init()">
<input type="submit" onclick="increment()" value="Increment Size"/>
<input type="submit" onclick="decrement()" value="Decrement Size"/>
<input type="submit" onclick="testStyleSheet()" value="Test StyleSheet"/>
<hr/>
<div class="divStyle">A sample text</div>
<div> Without the disStyle class attched to the DIV tag. the fonts will not increment and decrement. The big trouble is the key combination in mozilla.
http://www.openjs.com/scripts/events/keyboard_shortcuts/
</div>
<div class="divStyle newStyle"> This is a test </div>
</body>
</html>
So, there you go! Remember, this is NOT complete and you can take it forward.
Keep programming :)

February 10, 2008

All about Ext.Button!

I have already demonstrated the difference of ExtJS1.x and 2.0 with a simple "Hello World" program. Now let’s get deeper and this time it’s about buttons in ExtJS. In this article we will cover creating, handling and manhandling of Ext buttons.

Setting up your programming environment:

There isn’t much to this. If you do not have ExtJS 2.0, you need to download the latest version. All you have to do is unzip the downloaded file, place them in a proper folder structure. I usually have a folder structure as shown:



The js folder has all the JavaScript of the application. Inside this folder I have separate folders for different libraries and I store my custom JavaScript files in appjs. Again this appjs can have subfolders to separate JavaScript files module-wise. This might not be the best folder structure but for now we will stick to this. If you are new to Ext you can have a look at my "Hello World" program.

Ok! Now we are ready for some action. Let’s start with creating a simple button.

Creating a Button:

Ext has Button class implement in the base package ie, Ext. To create a button all you have to do is create an instance of this class and specify the attributes. The Button class has a parameterized constructor with one parameter, the button’s configuration!
Here is the code to create a simple button:
buttonObject = new Ext.Button({applyTo:'button-div',text:'Simple Button'});
You will see that we have used two configuration parameters. applyTo is used to specify which HTML element is going to become the button. The HTML element can be DIV, P or SPAN tag. Remember that applyTo should be passed for the button to render. The next parameter is the text of the button itself. Now another way to specify the holding element for button can be done my calling the public method applyToMarkup. The method takes a parameter which is the id of HTML element to which the button will be rendered.

Attaching handlers to button:


There are basically three ways to attach event to the button you created. One is to use the constructor to specify a callback when the button is clicked and the other is to use addListner method. This method is more generic because you can specify action for any type of events on a button.

The first method is by using the constructor you specify the call back function that needs to invoke when the button is clicked. Remember: It’s only for handling button clicks. Have a look at the example below:
buttonObject = new Ext.Button({applyTo:'button-div',text:'Testing',handler:buttonHandler});
buttonHandler is a method defined in our application class as private method. Here is the complete application code:
app = function() {

var buttonObject;

var buttonHandler = function(button,event) {
alert('You clicked the button!');
};

return {

init:function() {
buttonObject = new Ext.Button({applyTo:'button-div',         text:'Testing',
handler:buttonHandler});

} 
};
}();
The second method is to use the setHandler method to set the call back method for click event. The method has only one argument and it’s the call back method.

The third method to attach an action is to use the public method addListener. Through this you will be able to define actions for events like clicking, mouse over, mouse out etc. Take a look at this example
buttonNext = new Ext.Button({text:'Touch me'});
buttonNext.applyToMarkup('nxt-button');
buttonNext.addListener('mouseover',mouseHandler);
The addListener method has four parameters out of which last two are optional. Thus in our above example, we have made use of just the feature of assigning action to certain events. The third argument specifies the scope in which the handler method should be executed and the last argument specifies the object containing handler configuration properties. These properties can be scope, delay etc.

Before we close, there is one more way to attach event handler to button. This can be done by calling on method. This method has the same number of parameters as the addListener method.


Firing and removing handlers:


ExtJS provides a good set of APIs to manipulate events and actions for any component. As its possible for developers to create and attach actions for button, its also possible to manually fire, stop and remove these event and action.

Situations arise wherein you need to fire an event or series of events when one components event is fired. To fire an event manually we have fireEvent method.
This method has variable length argument of which the first argument is the event name that needs to be fired and the rest is the parameters passed to the handler if any.Have a look at the example below:
app = function() {

var buttonObject;
var buttonNext;

var buttonHandler = function(button,event) {
alert('You clicked the button!');
buttonNext.fireEvent('mouseover');
};

var mouseHandler = function(button,event) {
alert('Mouse on me!');
};

return {
init:function() {
buttonObject = new Ext.Button({applyTo:'button-div',
text:'Click me',
handler:buttonHandler});

buttonNext = new Ext.Button({text:'Touch me'});
buttonNext.applyToMarkup('nxt-button');
buttonNext.addListener('mouseover',mouseHandler);
} 
};
}();
Here we manually fire the ‘mouseover’ event for buttonNext when user clicks on the first button. Thus inturn, the mouseHandler of buttonNext is called.

Now, let’s remove handlers attached to the buttons. ExtJS provides two methods to remove a specific handler from an event. Developer as either use removeListener or un method (addListener and on for adding). And finally to remove all the handlers attached, you may call purgeListeners method.

Suspending and Resuming Events:

Adding, firing and removing is not all that. At times you may need to suspend the events so that the handlers are not fired. You can use suspendEvents and resumeEvents method to enable and disable the event firing for a component. For example:
buttonNext.suspendEvents();
This would suspend all event fired by buttonNext object.

Other Methods:


I am not explaining each function explicitly. But I am just covering the major once that a developer needs to know. For complete list of methods refer the Ext API Documentation.

Winding Up:

For a Ext beginner, I hope this will greatly helpful. Please let me know of any mistakes in this tutorial. You can download the final source code from here.

Read other articles and tutorials on ExtJS!