Amazon deals

Sunday, December 21, 2008

AJAX - A misconception?

My encounters with HR's of various companies have left me wondering on how people with very little/narrow technical knowledge end up being major recturing factors of some well known technical companies. Naming the person here and the company would actually soil the reputation of one of a few damn good companies, so i'll refrain from mentioning that and give more of the background and clear off a few misconceptions about a piece of technical jagron termed AJAX.

Here's the incident: It was kinda of deep into a tech interview round when i mentioned AJAX as one of the technologies i've been working on in the recent times. As expected the HR asked me what was AJAX and i gave the classical definition that even you can look up here. He then went on to ask how to make a score ticker using AJAX. I'll mention the steps here minus the technical jagron

1. Write javascript with an automated function call that calls itself every min or so as the time difference needed for the score update.

2. Create the xmlhttprequest object connection to the data source (an ASP/JSP page here)

3. Write the DataSource provider script to access the database and return the XML data.

4. Put the XML data on the page.

And to this he told: Wrong. Where are you using AJAX? You are using just javascript. I tried my best to convince him that AJAX technology is a confluence of javascript and XML. Ironical but his belief was that i had to drag and drop one of the widgets either from dojo/yui or any of the widget libraries that provide AJAX. Uph!! When will people ever learn that code libraries are also collection of javascripts that do the same job as we write; and the technology doesn't change whether you use an API/library or you yourself write the code within the technology constraints.

LESSON: Never go indepth onto the side of technology your interviewer has little knowledge off. The company doesn't deserve a bright individual as you.

Wednesday, October 22, 2008

javax.xml.transform TransformerException: java.lang.NullPointerException : How to Solve?

Just after solving my previous problem I stumbled on NullPointerException in Transformer.transform (Source, Result) method, my application was working fine until yesterday, there was no update, no change in configuration of anything…

What I was doing therewas a simple attempt to use the transformer from the xml api to write an xml file:

Source source = new DOMSource (doc);
Result result = new StreamResult (new File (file));
Transformer transformer = TransformerFactory.newInstance ().newTransformer ();
transformer.transform (source, result);


Personally this is the worlds's most stupid error. Guess what the console gave as the eroor description : ERROR: '' "

Very helpful, isn’t it? What next? Well we'll proceed to the stack trace next:

Down somewhere in the jungle of exceptions you get Caused by: java.lang.NullPointerException

at com.sun.org.apache.xml.internal.serializer. ToUnknownStream.characters(ToUnknownStream.java:312)

the code there looks like this:

public void characters(String chars) throws SAXException
{
final int length = chars.length();


Now we finally see the part that threw the error. Well the char.kength() was zero because there was a null text node insertion beging tried. So now's the solution to this problem

1. Go through your source code

2. Find the text node that is null

3. Give it a String value

4. Recompile and run

OWLS ARE NOT ALWAYS WHAT THEY SEEM

Xforms submission giving null parameters to request.getparameter() - Solution

Simplicity side of X-forms and xml apart, when one goes building any major web app from the very little, itsy bitsy knowledge we have, looms large problems that shake the very fundamentals of what you began coding with. If you ever tried the previous Xform in a debug mode on the Websphere server you would have found out now the hard way that the form does pass values, but jsp page cannot recognise in whatsoever.  Its an irksome problem i had last night and spent around 6 hours of my valuble time figuring out, going through over 1000 links on google and reading over 10 pdfs, to know there isn'at a solution posted anywhere. Ok fine leave apart my difficulties, here's what you came for, the solution to the problem

 

Goto your submission element

<xf:submission action=”process.jsp”
method=”get” id=”sub”/>


add an extra parameter

<xf:submission action=”process.jsp”
method=”get”
seperator="&amp;" id=”sub”/>

voila, you have your parameters now.

Now, the exact reason why the problem occured:

An html form uses the seperator by default and a jsp seperates out and creates a parameter map from this. Xforms by default, doesn't specify the standard seperator, so the addition tag required in the submission element in your model.

Saturday, September 27, 2008

Writing your First Xform

Xforms isn't as complicated as people claim it to be. It is a simple, and with tons of benefits than traditional forms. Here's a step by step procedure involved inwriting an Xform that takes a persons name as an input and sends it to an jsp page process.jsp for processing.

1)

Open notepad and put in the following xhtml header

<html
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


this header tell the browser the type of XHTML page and the different standards used as per W3C. the first line is the xforms standards, the second of schema for display and the third for the instance model. Without these your browser will not be able to intepret the page properly.

2)

Write the head section as you do in HTML, i'll elaborate the otter fields in comments delimited by //

<head>
<title>Xforms Example</title>


//The model specifies the Xforms data model. Instance contains all the fields you'll have in the model. Here we have only one field in the instance namely name.

<xf:model>
<xf:instance>
<name/>
</xf:instance>

//in submission action link to your serverside code
<xf:submission action="process.jsp"
method="get" id="sub"/>
</xf:model>
</head>


3) Now to the body part of the page.

<body>
<xf:input ref="name">


// the ref field is used to referance particular elements from the instance model. The label is what the label you want to show on the page

<xf:label>Name:</xf:label>
</xf:input>
<br />


//br is normal HTML break. The submission="sub" specifies the id as given in the instance model in head.

<xf:submit submission="sub"><xf:label>Submit</xf:label></xf:submit>
</body>
</html>


4) There you have your first Xforms ready. Save the file with a .xhtml extension and view in any Xforms compitable browser(click here to know more about xforms viewers) and there you go.

Tuesday, September 23, 2008

A Girl Called Deepa

I thought Deepa would be the ideal person to be referred to in this new blog of mine especially since no other girl could be introspected here, the case being a void in my personal space. The other day when the topic of writing a testimonial in orkut came up, it struck to me that not much can be said about this worthy being in a span of 1024 characters. So it struck to me to dedicate a blog to this girl who is typically intrusive, analytic and introspective and currently assumed a loving role of a foster sister to me.

Dee as i affectionately call her, though with her typical girlish charm has aura of silence surrounding her. This is a shell that one has to break into and go through the process of knowing and understanding to get this otherwise extremely talkative, fun loving female to open her mouth. Putting aside all the pinkish tags, the major reason dee serves as an admiration as well as an inspiration is the grit and valour embedded in her as a modern day female to face. dwell and survive in hard situations still bearing a smile on the face. She is one stop destination for advices from mobile phones to relationships ;) People who know me do know the fact that i turn a deaf  ear to most advices but this is one person i listen to and that must be enough for you to know how powerful advisory she is.

She's got an AWESOME handwriting and is one major brains!! She is but a typical girl who likes being admired, praised and gifted. Please don't think i am bluffing or trying to impress when i tell you she's one heck of a cook. My stomach vouches for the pleasantness and my tongue for the taste of the food she brought the other day to college. I secretly hope though that writing this blog would reduce the price tag of the rakhi gift i'm delaying in giving her :P She's got a sweet voice, and a patient ear to listen to. She is everything a girl should be and more.

I must say that she has a great future in whatever she takes up in her life be it being a great chef or a good housewife(pardon me she's doing a engineering course right now ;)) She's a female who easily assumes the role of being the spurtive oasis you see in you myriad dreams in wayward travels through this desert called life. I wouldn't end this blog with just this one entry, every word i type here henceforth, every character(whitespace or non-white space) is a dedication to this wonderful human being called Deepa. No matter how many twinkling eyes and smiling faces sneak upon me from the oblivion i shall never forget one of my best friends in UVCE, a true sister, A Girl Called Deepa. 567 words, 1502478 procesor ticks, are nothing but a token of admiration, a rose flower at thy graceful feet.

"We romanticize, criticize, fantasize and theorize about the eyes. So, why should beauty be any different. It's all in the eyes. But if you don't see the beauty of character, you will but realise that what you miss in life is a ray of hope, a silver lining in the dark black cloud called life, where humanity is by far a virtue and beauty a vice"

Monday, September 22, 2008

Xforms - An insight

Xpath, Xquery, Xlink, XSLT, Xforms uph... the never ending list of techologies that begin with an X and literaly give people headaches being one of the most complicated yet powerful SGML. This is a honest effort to render off itsy bitsy details about one such XML based technology - Xforms.

Well Xforms to begin with is a W3C recommendation that is a replacement for standard HTML forms. XForms provides a richer, more secure, and device independent way of handling web input. Pretty easy to learn actuall if u go through some tutorials like http://www.w3schools.com/xforms/xforms_intro.asp but they don't spell out the looming truth. You can very well write an xform page but to get it to display in your ordinary browser... well its close to defining hell. So here's what you got to do.

XForms browser Plugins


For Mozilla: Well for all those who switched to mozilla 3.0 there's no plugin available for Xforms, there goes W3c statements of supporting Xforms in all future browsers. The new kid on the block Chrome also doesn't support it natively nor has it plugins. For those still on Mozilla 2.0 check http://www.mozilla.org/projects/xforms/download.html

For IE: for once IE is good. Well atleast there are plugin developers who have developed plugins for Xforms for non native support. These include formsplayer and Novell

XForms standalone browsers


The most popular standalone XForms browser is surely X-Smiles, developed by the the University of Helsinky. X-Smiles is a Java-based browser, with full support for XForms and for Smil. X-Smiles works as well on PCs, as on PDAs as on (modern) mobile phones

XForms application servers


This is the third category which is quite useful if you don't want your clients to install software at their end to run your web application. That doesn't make it the recommended option though as its damn slow as the server process your xml based form and renders an equivalent html+js. However you can try it out in case you can sacrifice the speed for delivering your end users a hassle free usage of your application. The most popular of these application servers is probably Chiba 2.0, from ChibaCon. It is open source, very stable, and very easy to install on the server: just deploy the .war file on your favorite application server (Tomcat, JBoss, Orion, Resin, Oracle, WebLogic, WebSphere ...), and you are ready.

Friday, September 19, 2008

Lessons learnt

I've learned that it's taking me a long time to become the person I want to be.

I've learned that we are responsible for what we do, no matter how we feel.

I've learned that either you control your attitude or it controls you.

I've learned that learning to forgive takes practice.

I've learned that there are people who love you dearly, but just don't know how to show it.

I've learned that just because someone doesn't love you the way you want them to doesn't mean they don't love you with all they have.

I've learned that it isn't always enough to be forgiven by others. Sometimes you have to learn to forgive yourself.

Last but not the least I've learned that no matter how bad your heart is broken the world doesn't stop for your grief.

Wednesday, September 10, 2008

Don't move a database that has it's tables linked in db2

Hey guys, don't make the mistake I did by trying to move a database that has its tables linked. You'll get an sql error numbered 3304.

LOAD is a very fast and direct way to get data from a file residing in the file system into a table in your database. LOAD does not use SQL INSERT statements, as does IMPORT. Instead, it writes the data directly to the data pages in the tablespace. Additionally, less logging occurs to further improve performance of the load process.

So, we need to keep the behavior of LOAD itself in mind. If there are any dependent tables (tables that have a foreign key referencing the table into which data is to be loaded, for example), they might be placed in the CHECK PENDING state. Additionally, further constraints could also result in the table not being available right after the LOAD operation, requiring you to run the SET INTEGRITY SQL statement first.

So, you could either set INTEGRITY SQL or you could do the mapping in your buisness logic using entity beans.

Monday, August 25, 2008

Hibernate...

This video is a part of our continuous approach towards learning by sharing knowledge together. We deal with hibernate plugin onto the reverse engineering process we discussed earlier.

[googlevideo=http://video.google.com/videoplay?docid=7169964626981764870]

Sunday, August 24, 2008

AJAX

AJAX is simple.... It ought to be as you can even find books titled "Teach yourself AJAX in 10 minutes". I mean even the silliest of technology learning book titles have a minimum time span of 24 hours but by jove 10 minutes?? By the way the simplicity of ajax using jmaki plugin is demostrated in the following screencast(PS:don't feel bad, its a little screechy and 14 mins long but anyway gives an overview of jmaki and dojo). Now to the reality part, what exactly is AJAX? AJAX (asynchronous JavaScript and XML) isn'ta technology. It's really several technologies, each flourishing in its own right, coming together in powerful new ways. AJAX incorporates:

  • Standards based presentation using XHTML and CSS

  • Dynamic display and interaction using the document object model

  • Data interchange and manipulation using XML and XSLT

  • Asynchronous data retrieval using  XmlHttpRequest

  • and JavaScript binding everything together.


What is important to note is that it is easy to use ajax code from ajax libraries available  such as those from Yahoo, Google and DOJO to name a few, but to write your own code in AJAX its humongus. The only way to be good at AJAX is "Practice, practice and more practice".

Saturday, August 9, 2008

Reverse Engineering : An insight into the process of reverse engineering databases

Lets first look into the definition of reverse engineering. Reverse engineering (RE) is the process of discovering the technological principles of a device, object or system through analysis of its structure, function and operation. Reverse Engineering is a very powerful technique for discovering the structures of databases. There are many tools available like Apache Cayenee,Oracle Designer etc. What I want to talk thorough here is the concept of reverse engineering and its relevance into enterprise application development. You must be knowing that in the 3 tier system of Enterprise Applications other than the business code in the middle tier a lot of coding goes into both data access and modification in the innermost layer. So an enterprise app could be seen as a concentric sperical shell of three layers with the ineermost core dedicated to database(say db2),its connections and data access. Once we have this core, i.e. we know exactly what data is to be delt with we could use a tool to map the database directly to code(POJO and DAO combination in case of EJB's) and then build the rest of the application on top of this. This is reverse of the actual front end to back end conceptuation we tend to do and is termed reverse engineering. Its a relatively fast and effective method wherein the focus is exactly on the application data, enabling us to build on both existing databases and our own data logic on any given scenario.

Monday, July 28, 2008

Moving a db2 database

You must have encountered this problem sometime while working on db2. It doesn't have a proper GUI for direct moving of a database from one system to another. Here are the detailed steps.

Step1:
Export using following command sequence

/>db2move databasename export

Commet: this generates files Export.out - ASCI info about export db2move.lst - has table info tabn.ixf - info exchange format, holds data .msg -message files tabna.nnn - large object data

/>db2look -d databasename -e -a -o outputfilename.sql

Comment: generates the sql file holding DDL data

Step2:
move all files to the target system

Step3:
Import using following command sequence

/>db2 create databasename
comment: creates the database
/>db2 -tvf sqlfile.sql
comment: structure the generated database with the sql file from the export
/>db2move databasename load

/*HURRAY DATABASE MOVED */

Design Phase - 3

Continuing further, we see the drawing of sequence diagram. Check the tutorial here. This diagram shows the various actors we have from our use case diagrams interact with the various classes in our class diagram. This UML specified the object to object message passing via various operations.

Sunday, July 27, 2008

Eclipse - Problems and solutions

People encounter a lot of nerve wrecking problems, not while installing or using eclipse but while configuring it for particular project requirements. Here are a few common problems are their solutions.

¿   Cannot find Data source explorer view

√  You are using the wrong type/version of eclipse. You need to download the eclipse package for Java EE      developers

¿  Cannot install WAS CE 2.0 in Eclipse ganymade. Gives dependency problems error message.

√ There is no WAS CE plugin available for Eclipse ganymade(3.4). You need to use the older Eclipse Europa(3.3) to solve this dependency issues.

¿ Cannot install WAS CE plugin directly even in Eclipse Europa

√ You need to install the database plugin before installing WAS CE plugins.

¿ the instruction at "0x7c93426d" referenced memory at "0x00000000"

√ Your installation is faulty/ is corrupted. Reinstalling eclipse will solve this problems

Thursday, July 24, 2008

Design phase - 2

Continuing further from use cases, we reach the part of designing classes for the users and for different uses they do the system. Again on rational ROSE we've developed the following class diagram. (see this to learn how to draw class diagrams in UML). The next time I write about class diagrams, it would be expanded to its fullest possible extend. Catch a glipse of this to get a sneak peak on UML,

[caption id="attachment_18" align="aligncenter" width="497" caption="Class_diag_ver_1"]Class_diag_ver_1[/caption]

Friday, July 18, 2008

Design phase - 1

After figuring out the host of technologies we reqire to our enterprise project and after our really long chat out at coffee day on 15th july Rahul and me immersed ourselves with design duties. He'll come around with the databases(DB2) soon with all the research work coming up from jan. Now into the tech stuff.

We used a trial version of IBM's ROSE to develop the following use case UML diagram. (see this to learn how to draw use case diagrams). After a few hours of pondering i've come up with the following use case view


[caption id="attachment_11" align="aligncenter" width="497" caption="UML_USE_CASE"]UML_USE_CASE[/caption]

Thursday, March 27, 2008

Saturday, January 12, 2008

ATTITUDE

The longer I live, the more I realize the impact of attitude on life. Attitude, to me, is more important than facts. It is more important than the past, than education, than money, than circumstances, than failures, then successes, than what other people think or say or do. It is more important than appearance, giftedness or skill. It will make or break a company...a church...a home. The remarkable thing is we have a choice every day regarding the attitude we will embrace for that day. We cannot change our past...we cannot change the fact that people will act in a certain way. We cannot change the inevitable. The only thing we can do is play on the one string we have, and that is our attitude...I am convinced that life is 1% what happens to me and 99% how I react to it. And so it is with you...