Wednesday, January 30, 2008

Annoying NetBeans 6.0 Facelets Support Issue on Tomcat

Yesterday i got a call from a good friend of mine who has been dipping his fingers into JSF a bit. He’d decided to jump ship to using JSF on XHTML files, a technology known as Facelets. So he goes to download NetBeans 6.0 Facelets support plugin and installs it.

After developing a simple facelets page, he decides to deploy it to Tomcat 6.0.14 only to get BIG FAT class loader exceptions. What better way to treat a sceptic who is just getting into the game of web development in Java. These are the kind of things that can be so annoying about doing something in Java. Being a Seam advocate and user, I didn’t immediately realise what could have been the problem, since my Seam applications run fine using the jars from Seam.

After doodling around and making some changes to jars that came with the Facelets support, i just decided to ditch the jars from Facelets support and use my own. I picked the jars that come with Seam and VOILA! Problem solved. Makes me wonder if the guys who developed the plugin didn’t try to deploy it themselves AT LEAST to Tomcat before putting it out there. Anyways i just felt like putting up the solution to this simple but very annoying problem here for the sake of those who might try an introduction to Facelets.

Note that i got these jars from the JBoss Seam 2.0.GA’s lib folder. I can’t tell you where u can get them individually but downloading seam altogether will give you a change to start playing around with it if you haven’t started already.

Simply create a new Library in NetBeans by going to Tools->Libraries. I gave mine the name Facelets4Tomcat. Here are the jar files you need.

  • commons-beanutils.jar
  • commons-collections.jar
  • commons-digester.jar
  • commons-logging.jar
  • jboss-el.jar
  • jsf-api.jar
  • jsf-facelets.jar
  • jsf-impl.jar

This goes into your web.xml file.


com.sun.faces.validateXml
true


javax.faces.DEFAULT_SUFFIX
.xhtml


facelets.DEVELOPMENT
false


facelets.SKIP_COMMENTS
true


Faces Servlet
javax.faces.webapp.FacesServlet
1


Faces Servlet
*.jsf



30



forward.jsp

If you want to add the Ajaxified RichFaces components then add the following from the same Seam lib folder.

  • richfaces-api.jar
  • richfaces-ui.jar
  • richfaces-impl.jar

And add these to the top of your web.xml file


RichFaces Filter
richfaces
org.ajax4jsf.Filter


richfaces
*.jsf


org.ajax4jsf.SKIN
classic

You may use a different skin if you want. Check out the documentation for details

You may then add the library you created to your project by right clicking your web project and selecting “Properties”. At Libraries, click “Add Library” and selected the library you just created. Make sure that the check box is enabled or else it will not put the jar files in the right location i.e. WEB-INF/lib.

Oh, and MAKE SURE that the Facelets support libraries are unchecked, or else you’ll be back to square 1.

Five Things Web Developers Should Stop Doing

This may not come as a surprise, but I spend a lot of time on the Internet. Whether it’s browsing around for my own enjoyment or diligently working on a web-based application, I end up seeing both the end result and the inner workings of a lot of other peoples’ development work. And while a large majority of design elements are ultimately a matter of preference, there are certain web development techniques and implementation choices that I find myself shaking my head at, and I’d like to address a few of them here. The following is a list of five things that, in my opinion, web developers should simply stop doing.

1 – Including application code and HTML in the same file

Although many web scripting languages are tailored for alternating between application code and HTML by use of special tags, the failings of this architecture become apparent fairly quickly when developing robust web applications. Not only does this inline scripting method create messy, oftentimes confusing code, but it can discourage effective use of functions and introduce difficulty when delegating the roles of designer and programmer to different people who may not share one another’s skill sets. The answer here is to use a templating system to separate the application code from the HTML presentation. Templating functionality is widely available for any web development language, and is an integral part of pretty much any development framework (e.g. Ruby on Rails, CakePHP, FUSE).

2 – Embedding video with a technology other than Flash Full Motion Video

Until Flash FMV became widely available, a common method for video playback on websites involved encoding multiple versions of the same video, then asking the user which player he or she preferred to use (e.g. RealPlayer, Windows Media, or Quicktime). This was always a necessary evil, as developers needed to ensure that the site content was available to all visitors. However, presenting potentially confusing video preference questions to the user can often lead to abandonment, not to mention that encoding, uploading, and linking multiple versions of the same video can be a time consuming process.

Thanks to the introduction of full motion video capabilities in Adobe Flash, which has shipped alongside the most popular browsers for several years, developers now have some level of certainty that at least one video player will be available to the majority of users. Additionally, Flash FMV prevents the need to spawn an external application for playback, which is another scenario that can lead to abandonment if the site visitor is unsure of how to answer their browser’s security questions.

Although sites such as YouTube have unfortunately given many people the impression that Flash FMV is only capable of low quality videos with poorly synced audio, this is simply not the case. Adobe has even launched a “Flash HD gallery” (available at http://www.adobe.com/products/hdvideo/hdgallery/ ) that showcases Flash’s HD playback abilities. However, most embedded videos (news clips, etc) are short, small clips that download quickly, so even a medium or low quality encode will suffice. If your specific needs dictate that you must leverage the more advanced features of players like Quicktime or Windows Media, then you will have to use what best suits your end goal, but otherwise, stick with Flash.

3 – Implementing Flash pieces that introduce custom UI elements

Flash is a phenomenal addition to any developer’s toolkit, and well designed Flash pieces can significantly enhance both the aesthetics and functionality of a website or web-based application. However, one thing that many Flash developers fail to steer clear of is overusing Flash where it’s not necessary, to the point of introducing custom user interface elements that can end up hampering usability. As an example, consider something that’s unfortunately fairly common – a Flash-based block of text with a scrollbar that is also implemented within the Flash piece itself. Not only is this an unnecessary use of Flash, since the same effect can be accomplished with fairly simple CSS, but you may be alienating visitors who simply aren’t tech savvy enough to adjust their understanding of the browser’s UI elements on the fly. It may not be apparent to some users that they’re even looking at a scrollbar, especially if the bar is stylized or implemented in such a way that it doesn’t behave like the standard scrollbar. Your visitor is used to the way their browser functions and how they use its features to browse the web, so your best bet is not to alter basic UI elements.

4 – Using long query strings where they’re not necessary

Most web applications rely on the URI’s query string to bring in relevant data that is acted upon by the application code, but poor design choices often cause the query string to grow to unreasonable, unnecessary lengths. Long query strings can severely hamper the ease with which users can link to particular pages on your site, so you could very well be losing visitors because they didn’t quite get the full query string when a friend copy & pasted it over to them.

The first thing to do to clean up your query strings is simply to use small identifiers for both variables and values. Try to use numeric IDs instead of long text strings to identify a specific resource, and keep your variable names short. You should also avoid passing data that could easily be extracted from data you already have. For instance, don’t pass both an item name and item id through the query string – you can just pass the item id and pull the name from the database.

If you want to go a bit further in cleaning up or even eliminating query strings, look into URI rewriting. URI rewriting is a fairly simple process by which the friendly URI the user sees (e.g. /Blog/2008/01) is transparently translated into something more useful on the server side (e.g. blog_list.php?year=2008&month=01). Nearly all Model-View-Controller frameworks (Ruby on Rails, FUSE, CakePHP, etc.) have advanced techniques for rewriting the URI on the fly.


5 – Sizing images by means of the width and height attributes of the img tag

This one should be a no-brainer, but I still see it fairly regularly. While it’s quick and easy to force an image down to certain size by using the tag, you’re doing yourself a disservice in at least two ways by utilizing this technique. The first problem with this method of image sizing is that web browsers aren’t particularly good at shrinking or enlarging images. The browser doesn’t do any kind of resampling, so you often get a pixelated version of your original image, even when shrinking it. The second issue with sizing images by way of the browser is that you may be wasting a lot of bandwidth. An image that’s 1000 pixels by 800 pixels has a much larger filesize than one that’s 200 by 160 pixels, so if you’re forcing it to appear at the smaller size anyway, you’d be transferring a lot of extra data for no reason by resizing it on the client side. To resize images to the size you need, use any of the widely available free tools or websites that allow you to do so.


So there you have it – just a few things I’ve seen during the course of my Web travels that I personally think should be done away with. Especially as development trends continue to shift toward more user-friendly, AJAX-enabled “Web 2.0” applications, it’s important to remember to leave behind techniques that, although familiar, have either been deprecated or were never great ideas in the first place.

Flex and Java – A perfect technological marriage

o you've been a Java developer for most, if not all, of your career. You've been writing business logic in your Java classes and you've been creating application interfaces using JSP pages. More recently you may have used JSF (Java Server Faces) and/or Struts to improve things. But have you really succeeded? You are still writing JavaScript code to bring more life to your interface and to make it dynamic. JavaScript also helps you load XML data from the server without a round trip (otherwise known as AJAX). But don't you get the feeling that it's all the same, that nothing is better for you, the developer, or for the end user? Well, if you are asking yourself these questions, then you are in the same state of mind as I was back in the summer of 2004.

In the summer of 2004 I started work on a mini-CRM application called Phoenix with specific features for my company. I started creating the application interface using JSP pages, but I found I wasn't delivering a better quality application. So I began looking, and trying a whole bunch of technologies—namely the ones I mentioned above—to improve things. But some things still weren't right: It took too much effort to create reusable parts; the browser was always in the way with its JavaScript issues; and the code still looked in some cases like a plate of spaghetti. That's when I got lucky and got my hands on Adobe Flex. Needless to say, several months later, Phoenix was completed using Flex 1.0 as the basis for the interface. Since then, my company has used Flex on six other projects.

So why should any Java developer be interested in integrating Flex into an application? There are several reasons, and I will take a look at them one by one in this article.

Get started using Flex

Flex 2 (Flex Builder, Free Flex SDK, Flex Data Services)

Flex will be familiar to a Java developer

One challenge in introducing a developer to a new technology is the learning curve: No one wants to spend hours or days understanding the basics of a new technology. Learning Flex boils down to two things: MXML and ActionScript. If you know JavaScript, and if you know Java, then you know ActionScript. There are minor differences in the syntax, but you won't get stuck. See for example the following ActionScript code:

package demo
{
public class Person
{
// class fields
private var firstName:String;
private var lastName:String;

/**
* Constructor with parameters
*/
public function Person(fn:String, ln:String) {
firstName = fn;
lastName = ln;
}

/**
* Returns the full name of the person,
* exposed as a property on the class.
* @return the full name
*/
public function get fullName():String {
return firstName + " " + lastName;
}
}
}

With MXML, if you have worked with HTML or any kind of XML document, once again you know MXML. You just have get familiar with the properties of the components; there is great reference documentation for that. I'll let the following example demonstrate the simplicity of MXML:


width="400" height="300">
















From looking at the code, you can see that it's a panel with standard buttons and a form for a typical registration page. Don't forget about CSS! Flex can load and use any CSS file you provide, either at compile-time or runtime.

The languages that Flex uses will be familiar to anyone coming from a Java background. This way, you don't waste everything you have learned over the years, you are only applying it a little differently. It comes down to the old proverb: Everything old is new again.

The Flex development process: It's a lot like the one you use for Java

One of the things that took me a while to realize was that developing in Flex is very similar to developing in Java. In any Java application you create classes: some are classes that encapsulate your business logic, some are utility classes, some are classes that communicate with a database, and much more. This is no different from what you do in Flex. In Flex, you create ActionScript classes that encapsulate your interface logic, utility classes, and classes that communicate with your middleware, which in most cases comprises the Java classes that I just mentioned.

In the last two Flex-based applications that I created, I found myself, more ever before, writing all the MXML code I needed first—thus defining all the various parts of the interface, to ensure that it fit the specification. Then I spent the rest of the time coding in ActionScript classes. Also, you can apply the J2EE patterns you've learned over the years to Flex. Many Flex developers use an MVC (Model-View-Control) framework called Cairngorm that uses many of the J2EE patterns you already know, such as the Value Object Pattern and the Service Locator Pattern. For me, with the architecture similarities, developing in Flex and Java are almost the same.

Another similarity between Flex and Java is application testing. In Java you write unit tests using JUnit and incorporate those tests into your nightly build script to see the results by morning. For Flex, you can unit test your ActionScript classes using FlexUnit. There is virtually no difference between FlexUnit and JUnit. You create test cases in ActionScript, run them using Ant, and then generate test results in HTML in the same fashion as for your JUnit tests. Basically, with every build, you run the Java and Flex unit tests at the same time, thus fully testing your application and making it as robust as possible.

I just mentioned the build process and that's the last thing I am going to bring up about similarities between the two technologies. Just like Java, in Flex code the MXML and ActionScript has to be compiled so that you can execute it within a VM (Virtual Machine), or in this case, Flash Player that resides within your user's browser. The great thing is that the Flex compiler resides within a JAR file, so you can execute it from an Ant build script. You can also run it by executing an EXE file in Windows and a shell script for Unix/Linux. Therefore, you can use your Ant build script to compile both the Java and Flex code.

Flex is simple to use and helps you develop code faster

Lastly, I'll discuss development speed with Flex. Flex comes with the familiar and basic components (Label, Button, TextInput, and so forth.) and more advanced components, such as the DataGrid, Tree, Charts, and more. Flex optimizes development time because the advanced components provide a lot of functionality (such as sorting, highlighting, and so forth) that there is no need for you to develop that advanced functionality over and over again. For these advanced components, you simply pass the component the data you want, set some properties, and it will render the information for you.

Secondly, you know how JSP pages look from a coding perspective: They're HTML mixed in with Java code and then some JavaScript sprinkled in here and there. It can get messy fast. Another challenge is that you have to hold lots of data on the server side to track what is happening on the client side; and you have to do many page refreshes to update the display. Some developers might call this technique "hacking things in order to make them work." With Flex there is no such weaving since everything is deployed and run on the client side. You generate the MXML code and put all the logic in ActionScript classes. With clear separation, it is easy for you to maintain and enhance MXML and ActionScript code. Instead, you can spend more time ensuring the product is easy to use and conveying the right information to the user.

Finally, don't forget what you create when you build a Flex application. It's not a set of pages that are simply connected together, it's an application. In fact it is an application deployed to the web with desktop-like features. It's a responsive, familiar, cross-platform, powerful, and visually pleasing application for your users. Check out Flex sample applications on the Flex Developer Center.

Some differences between Flex and Java

One of the key differences in using Java and Flex in the same project is the changes in the development process. These changes are due to the fact that there now is a distinct and clear separation between the business layer (Java code) and the presentation layer (Flex code).

During a typical project cycle in our team, one set of developers works on the interface while another set of developers works on the business layer independently. After the initial set of requirements for the project, our team either starts writing the business layer first or the interface first, depending on which developers are available and when. Developing each part is completely independent. The business layer developers design, write unit tests, and then write the business code to satisfy the unit tests. Meanwhile, the development on the presentation layer begins, such as reviews with users, and refining the look and feel. The best part is that the interface will actually be functional and it doesn't even do anything yet! Yes, it is possible because you are creating a pure client-side application. Users will see the interface change states and be able to manipulate data—the application will look like it's working.

Once both teams complete development and the application passes all of its unit tests, the last step is to plug the interface into the business layer, do one last round of testing, and, you're all done!

So in the end, what have we learned? First, you know that Flex will be familiar if you're coming from a Java background and that most of your skills and development techniques will carry over. In many cases, parts of the interface will be easier to develop, have more features, will be delivered more quickly, and adjustments will be easier to perform.

When you really think of it, this is the best marriage of two technologies in recent memory—Java for the business layer and Flex for the presentation layer. Basically, you can use the best technologies in each domain and your products will thrive because of it, especially the interface, which is the part of the application that users see and use. Your users will be impressed; meanwhile, you'll have a smile on your face because you didn't even break a sweat.

Design Patterns Quick Reference

Top 10 Firefox Business Extensions

The techies of the world aren't the only people who use Firefox. It can even be adapted to the executives.

How can executives use Firefox? Easy! Download these top business extensions and you'll turn your Firefox into a business dashboard.

  1. Meebo (Review)
    One problem everyone has is the ability to consolidate all of their Instant Messaging accounts into one. If one client is using their favorite IM, you can't talk to them because you use brand x. Meebo is "IM glue" that holds all of your accounts together in one location: your browser. You sign in once and you are logged into all of your IM accounts immediately.
  2. LinkedIn Companion (Review)
    If you're a professional networker, you already know about LinkedIn. But for those who don't know what LinkedIn is, LinkedIn is like the six degrees of Kevin Bacon and mySpace (for businesses) thrown together. The extension provides useful shortcuts to the site and allows you to search for people looking for employment, look for jobs (freelance or otherwise), or...just people to network with.
  3. ReminderFox (Review)
    An exceptional utility that keeps a list of reminders for you. You can create your own categories, search through lists, and set priority to each tasks. Great for those busy executives who forget anniversaries and birthdays. :-)
  4. Peekko (Review)
    Peekko is a unique extension that allows users to congregate on a particular web page and chat. For freelancers, I could definitely see this as a absolute-must utility for showing progress of web sites to clients while working remotely.
  5. FingerAuth Password Manager (Review)
    It seems security is a big thing nowadays and Firefox is doing all it can to help, but there is one extension that is taking it to the next level. The FingerAuth Password Manager extension works with a biometric fingerprint reader for secure web pages. When you arrive at a login page, you can press your finger to the biometric reader, it verifies who you are, and promptly allows you into your secured area.
  6. FireShot (Review)
    It never fails. A programmer completes a new enhancement and then the boss uses it. Guess what? It breaks, but you need a way to capture the screen to show the programmer the error. FireShot will capture the browser screen and let you annotate your questions right on the image. Then you can send the screenshot to the programmer for fixing. It may not be business-related, but it definitely helps the programmer or project manager.
  7. eBay Companion for Firefox (Review)
    You laugh, but more and more businesses are buying hardware through eBay and the merchandise is cheaper than buying new. Just make sure you are buying from a reputable "business." The eBay companion centralizes all of your bids and watched auctions in a sidebar, so you can monitor your business merchandise.
  8. Zotero (Review)
    Zotero is absolutely fantastic for research users and provides a complete streamlined workflow that allows executives to become organized packrats. Use Zotero to gather the research to make proper business decisions based on industry trends. Take that research and provide that data to the project manager and/or programmers to create one heck of a product.
  9. GTDInbox
    Everyone needs organized and business executives and freelancers are no exception to the rule. David Allen's best selling book, Getting Things Done, is applied to this Firefox extension to turn your GMail account into a Getting Things Done Inbox. Very useful and well written.
  10. DataAnalytics (Review)
    Take a web page full of data and have someone try to include that in a spreadsheet (Google docs or Excel). Things may get messy...unless you have DataAnalytics. DataAnalytics extracts the data and allows you perform all types of sorting and filtering on your data to make your executive decisions.

A comparison between the Google's GWT (Google Web Toolkit) and Adobe's Flex2

This article would compare Google GWT (Google Web Toolkit) and Adobe Flex 2 and would describe the advantages and disadvantages of each of these technologies.
This two technologies are both Rich Internet Application (RIA) frameworks.

GWT Advantages:

  • Doesn't require plug in installation on the client side
  • GWT doesn't require the user to know JavaScript since the code is written in Java
  • GWT doesn't cost money since it is Open Source.
  • Changes in the Client side are immediately shown on the browser by using refresh, no need to restart the server.
  • GWT can be easily debugged in hosted mode.
  • There is compatible between different web browsers.

GWT Disadvantages:

  • The html and JavaScript code which GWT generates is pretty heavy and not necessary fully optimized.
  • GWT doesn't come out of the box with all the possible widgets, there is a need to use extra components

Flex Advantages:

  • The UI looks nicer then plain HTML/JavaScript code, It contains huge amount of animations, widgets etc'
  • Compatible between different web browsers
  • Flex 2 SDK and Flex Builder 2 for Education are both free
  • Google can index SWF files

Flex Disadvantages:

  • It requires plug in installation on the client side , however this may not be disadvantage since Adobe claims that Flash is installed on more then 99% percent of users.
  • Flex Builder 2 costs some money

Care your eyes

This info' is sure to help PC users very much.During a recent visit to an optician, one of my mail friends was told of an exercise for the eyes by a specialist doctor in the US that he termed as 20-20-20." It is apt for all of us, who spend long hours at our desks, looking at the computer screen. I Thought I'd share it with you. 20-20-20

Step I

:-After every 20 minutes of looking into the computer screen, turn your head and try to look at any object placed at least 20 feet away. This changes the focal length of your eyes, a must-do for the tired eyes.

Step II

:- Try and blink your eyes for 20 times in succession, to moisten them.

Step III

:- Time permitting of course, one should walk 20 paces after every 20 minutes of sitting in one particular posture. Helps blood circulation for the entire body.

Circulate among your friends if you care for them and their eyes. They say that your eyes r mirror of your soul, so do take care of them, they are priceless................

Otherwise our eye would be like this.....

WHY EMPLOYEES LEAVE ORGANISATIONS ?

Every company faces the problem of people leaving the company for better
pay or profile.

Early this year, Mark, a senior software designer, got an offer from a
prestigious international firm to work in its India operations
developing specialized software. He was thrilled by the offer.

He had heard a lot about the CEO. The salary was great. The company had
all the right systems in place employee-friendly human resources (HR)
policies, a spanking new office,and the very best technology,even a
canteen that served superb food.

Twice Mark was sent abroad for training. "My learning curve is the
sharpest it's ever been," he said soon after he joined.

Last week, less than eight months after he joined, Mark walked out of
the job.

Why did this talented employee leave ?

Arun quit for the same reason that drives many good people away.

The answer lies in one of the largest studies undertaken by the Gallup
Organization. The study surveyed over a million employees and 80,000
managers and was published in a book called "First Break All The Rules".
It came up with this surprising finding:

If you're losing good people, look to their immediate boss .Immediate
boss is the reason people stay and thrive in an organization. And he 's
the reason why people leave. When people leave they take
knowledge,experience and contacts with them, straight to the
competition.

"People leave managers not companies," write the authors Marcus
Buckingham and Curt Coffman.

Mostly manager drives people away?

HR experts say that of all the abuses, employees find humiliation the
most intolerable. The first time, an employee may not leave,but a
thought has been planted. The second time, that thought gets
strengthened. The third time, he looks for another job.

When people cannot retort openly in anger, they do so by passive
aggression. By digging their heels in and slowing down. By doing only
what they are told to do and no more. By omitting to give the boss
crucial information. Dev says: "If you work for a jerk, you basically
want to get him into trouble. You don 't have your heart and soul in the
job."

Different managers can stress out employees in different ways - by being
too controlling, too suspicious,too pushy, too critical, but they forget
that workers are not fixed assets, they are free agents. When this goes
on too long, an employee will quit - often over a trivial issue.

Talented men leave. Dead wood doesn't.

"Jack Welch of GE once said. A company's value lies "between the ears of
its employees".