Wednesday, April 21, 2010

Sortedset with Example


When you want to sort the data we have to go with sortedset by default the sorting order is ascending.
You can customize the sorting order by Implementing comparator interface.

You can use treeset for sorting and for this you need to use the constructor which accepts comparator as argument.

Example:

public class Example {


public static void main(String[] args) {


SortedSet ss=new TreeSet();

ss.add("a");
ss.add("e");
ss.add("g");
ss.add("b");
ss.add("c");

Iterator it=ss.iterator();

while(it.hasNext())
{
String value=(String)it.next();
System.out.println("Value :"+value);
}
}
}

What is the difference between Iterator and ListIterator?

Iterator:
Using Iterator we can iterate only in forward direction and you cannot add elements while iterating and Here cursor always points to specific index.

Example:
 public class Example {
 
  public static void main(String[] args) {
 
    ArrayList aList = new ArrayList();
 
    aList.add("1");
    aList.add("2");
    aList.add("3");
    aList.add("4");
    aList.add("5");
   
    Iterator itr = aList.iterator();
 
     while(itr.hasNext())
      System.out.println(itr.next());
 
  }
}
ListIterator:
Allows the programmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator's current position in the list. A ListIterator has no current element; its cursor position always lies between the element that would be returned by a call to previous() and the element that would be returned by a call to next().
Example:
 public class sample {
 
  public static void main(String[] args) {
    //create an object of ArrayList
    ArrayList aList = new ArrayList();
 
    //Add elements to ArrayList object
    aList.add("1");
    aList.add("2");
    aList.add("3");
    aList.add("4");
    aList.add("5");
 
    //Get an object of ListIterator using listIterator() method
    ListIterator listIterator = aList.listIterator();
 
      
    System.out.println(" forward direction using ListIterator");
    while(listIterator.hasNext())
      System.out.println(listIterator.next());
 
   
    System.out.println("reverse direction using ListIterator");
    while(listIterator.hasPrevious())
      System.out.println(listIterator.previous());
   }
}
 
try the above code and get back to me :)

Monday, April 19, 2010

Developing Charts with JFree Charts

Implementing the charts while developing the Web applications as well as Stand alone applications is crucial part. This must act like business intelligence and it should give more information to the user with small graph or in short form of data. These will play major part in the application for analyzing and capturing application whole information.

For example A shopping cart applications sells the things in online and the owner of shopping cart wants to know the sales details in daily basis or weekly basis or Monthly basis and so on... and he has to get this information in short way and user friendly. He may need the more information like in which country the things are selling more, which materials are selling more and the things which are added for the carts and so on... In these situations representing the data in the graphical format will make the user to feel comfortable and feel like friendly.

As I from Java technology I worked more around to choose open source chart implementing tools for some days. I looked into Jasper Reports, Jfree charts, and some other technologies. Jasper reports are more useful while displaying the data in pdf fomat or excel  format and other formats. This has the ui tool called iReport to define the jrxml files and these jrxml files are parsed and finally we will get the data. This data can be displayed on different formats like pdf, excel,html...etc. Using JFree charts we can display the reports data in a graphical format. This chart can be write into pdf or other formats using JFree api. Here i will explain briefly about JFee charts.

By visiting the www.jfree.org site we can see the Jfree charts features as:
" JFreeChart is a free 100% Java chart library that makes it easy for developers to display professional quality charts in their applications.
  • a consistent and well-documented API, supporting a wide range of chart types;
  • a flexible design that is easy to extend, and targets both server-side and client-side applications;
  • support for many output types, including Swing components, image files (including PNG and JPEG), and vector graphics file formats (including PDF, EPS and SVG);
  • JFreeChart is "open source" or, more specifically, free software. It is distributed under the terms of the GNU Lesser General Public Licence (LGPL), which permits use in proprietary applications. "
The demo application can be downloaded from the site and u can start implementing the JFreechart's applications. JfreeChart developer guide helps more to develop the applications.

As per my opinion JFreeChart is more friendly for the developers while developing the applications. Using this you can implement Pi, Bar, StackedBar, Line, Bubble, Step ..etc charts.

Some times you may need to display JFreeChart image in JSP in that case Cewolf tag library helps more. Using Cewolf Tag library you can display all types charts in JSP and its easy to display tool tip, link and labels.

If you works with JSF, you can use Primefaces or Rich faces to integrate the JFree charts and its easy to implement.

Friday, April 9, 2010

Prime faces

Kowing about prime faces is more worth while developing the Web applications wusing JSF framework. Primefaces is just like a plugin for the JSF. It is more related to the UI of the application. Adding this plugin to the JSF based application gives confidence developer in designing ui interface in competence with other best ui technology.

Its providing more features like AccordianPannel, AutoComplete, Captua, Calender, Charts, Color picker,CommandButton, CommandLink, Confim Dialog, Data Exporter, Data Table, File Upload, File Download, Graphic Image, Image Compare, Layout, Menu, Menu Bar, Panel, PickList, Stack, Stack Menu,Tab, Tab Slider, Tree, Tool Tip ... etc.

Its providing more features related to JavaScript and extention to the JSF tags.

Integrating the Prime faces with JSF applications is too easy, its just adding the jar file into the application and setting up normal requirements in the web.xml file.


Wednesday, March 31, 2010

JSF is Cool..........

After spending with few days on jsf its looking like cool and making me share my happiness with you.

The features given in JSF is very impressive. The development with JSF is giving more happiness.The tag libraries (Core as well as UI tag libraries) given in JSF are more friendly and easy to understand.
The concept of managed-bean, Backing-bean and connecting the beans from the jsf elements (tags) is makes the developer to concentrate on the Business logic more instead of playing with requests and responses. There are more cool features in JSF for the developer as well as user and more plugins to to improvise the JSF functionalities.

I spent more than 2 months with JSF its gave me confidence on my developing skills and its made me think more on business logic.

At present I am enjoying while learning the JSF. I hope, I will come with more explanation on JSF and Integration of JSF with hibernate, spring, struts.

I am sure I will come with architecture of jsf and small examples and complexities discussions with you..............


Sunday, March 7, 2010

JSF Vs Struts Post Your Responces as comments.


I worked on Struts 1.x i felt it was easy. Now I am working on JSF with JBoss Portlets its looks little bit complicated while development. Why its looking like that? Is really JSF is complex when compared to Struts?
 In struts I used to have request and response in My hand so that i felt every thing was in my hand to control the application.
 But Jsf with Portlets is not like that. We need to work around to get the request and response objects.But handling these request and response objects is not as easy as in struts.
I feel working with Jsf and portlets is little bit difficult when I compare  struts frame work.
Is Jsf complex or Jsf with portlets combination is complex ?

Can you please let me know when to go for JSF with portlets otherwise with struts.

Sunday, February 28, 2010

WI FI Beacame old then whats new?

Wi Fi stands for Wireless Fidelity and is used to define any of the wireless technology.

Recently in Jan 2010 Intel introduced a laptap which contains the technology called Wi Di.

Wi Di stands for wireless Display.

With Wi Di you can watch the movie in your TV while dowloading in your laptop.

Why to to wait lets enjoy the movie on the big screen.

I hope this will be a big hit for the intel.

Wish the intel to bring more such advanced technologies in to the world.

Wednesday, February 24, 2010

How to Import Oracle Database wih Data


Step 1:  Move to dmp file directory using command prompt

Step 2:  Connect to dba user in oracle
            sqlplus sys/manager as sysdba

Step 3:  Select the user language from the dual
            select userenv('language') from dual

Step 4:  Create the user in database with username empuser and password userpassword
              (use your own user/password)
             create user empuser identified by userpassword
             grant connect,resource privileges to empuser

Step 5: Come out from the sqlplus
             exit;

Step 6: set the language of the user which you got in the Step 3 in the command prompt.
             set NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252

Step 7: import the database
            imp file=empuser.dmp fromuser=scott touser=empuser log=temp.log commit=y


These are the basic steps which i fallow while importing. These are not enough some times while importing and you can use several other methods to import the database.  


The popular oracle Books from Amazon:


Oracle Database 10g: The Complete Reference (Osborne ORACLE Press Series) 
Guide to Oracle 10g 
Oracle Database 10g Performance Tuning Tips & Techniques (Osborne ORACLE Press 
Oracle Database 10g PL/SQL ProgrammingSeries)

Wednesday, February 17, 2010

How to export Oracle Database with data

There are more ways exporting the database but i feel the procedure i fallow is good for me. You can do this as simple steps.

Step 1 : Connect to the user sys as sysdba 
              d:\>sqlplus sys/syspassword as sysdba

Step 2: Select the user language from dual
              sql> select userenv('language') from dual;

Step 3:  Come out of the sqlplus and set the LNS_LANG from the command prompt
             set NLS_LANG=  paste above display language

Step 4: Import the user using the fallowing command
           exp file=dumpfilename.dmp owner=scott log=expample.log


Popular Oracle  Books From Amazon:

Expert Oracle Database 11g Administration (Expert's Voice in Oracle)Oracle Essentials: Oracle Database 11gBeginning Oracle Database 11g Administration: From Novice to Professional (Beginning from Novice to Professional)Oracle Database 11g The Complete Reference (Osborne ORACLE Press Series)

Friday, February 12, 2010

My Experience with JSF

I am working with JSF from few days its cool and good.

So, I am planning to post several posts on JSF in near.

So be ready to fallow with me ..

I allow any suggestions and request from all

Thank you....