Wednesday 23 October 2013

DataTable Row Selection Radio Checkbox Primefaces 4.0


DATATABLE ROW SELECTION RADIO CHECKBOX
Implementing a table that allows row selection either having a column of radio buttons or checkboxes
After good hours of struggle and deep search, I found out that, to use the feature as shown in this url, You must have Primefaces-4.0 or above. I was using primefaces 3.5 I couldn't get it working.

Helpful Threads I visited:
I visited many threads, but finally the 2 below helped me to come to a conclusion that the feature was still a major problem in the lower versions(3.5 and below).

Things that must be done to have this datatable working.
-Make sure your Bean implements selectableDataModel or include the rowKey property in the datatable definition.
-selection - (Getters and setters in the Bean. If selection mode is multiple, set and get and array. If the selection mode is single, set and get the object)
-selectionMode - (multiple/single)
-Include this line as one of your columns <p:column selectionMode="single/multiple but not both" style="width: 4%"/>. This is selection mode for radio or checkbox
-Don't include selectionMode in the Datatable definition (<p:datatable selectionMode=""/>) since this is selection mode for row selection. Reason: Row selection and radio/checkbox selection are not compatible and cannot be both enabled.

Do it like here http://www.primefaces.org/showcase/ui/datatableRowSelectionRadioCheckbox.jsf but make sure to add rowkey in <p:datatable ../>


Only me can access the code. Its in my Dropbox and it's protected.

Saturday 5 October 2013

NetBeans 7.3 Nice Features I discovered

NetBeans is my most treasured Java Environment. Recently, I intergrated Visual Paradigm for UML 10.0 Standard Edition into my NetBeans 7.3 and it was very successfull.You can see how i did it here. A day after, I found out that there are other features that are provided through plugins that I have not used yet they are interesting.

Open NetBeans->Tools->Plugins->Available plugins.

On the list, you will find very many plugins with these inclusive;
  •  NetBeans Status line Memory Usage : Shows u NetBeans memory usage










  • Graphical Class Viewer: Shows you graphical view of the Java class



















  • Visual Mobile Designer. Installed but not tested it yet.
  • Log Management. Installed but not tested it yet
Check and install. Its that easy. I installed all the 4 above, but I have tested the First two. I will check out for more features and update this post. I
If you have used some NetBeans features that have interested you, let us know. 

Friday 4 October 2013

UML Integration in NetBeans 7.3 using Visual Paradigm for UML 10.0 Standard Edition and NetBeans UML Plugin

Question: How can I draw UML diagrams in NetBeans 7.3

Response: I asked my self this same question after my own code had grown huge and had started confusing me. I mean my own written code. It was hard to follow up and to remember the flow and logic I had in mind at the time of writing the code. May be you are in the same prison.
Here is what I did. I already had a UML tool (Visual Paradigm Standard Edition 10) installed on my Computer. I used this tool and I reverse engineered my code into a Class diagram, and Sequence diagram as well. This tool is an award winning and one of the best UML tools you can find. It is actually the best if I may be prompted to say. You can do any UML modeling with this tool. So, with this tool, I could easily  visualize how my code was structured from the generated class diagram, and the flow from the sequence diagram. Well, this worked well but I felt I would be more comfortable if I did all this modeling in my environment (NetBeans 7.3) .

I did some search and this is what I found.
I found that Visual Paradigm being a great tool, It has Integration capabilities with a number of IDEs including NetBeans,Eclipse, VisualStudio and others. The Integration capabilities they provide allow you to do all the UML modeling in your Environment. You can draw Class Diagrams, ERD, Sequence Diagrams, Activitity diagrams, Code Reverse and Foward Engineering and many other things.

For NetBeans,
1. On the NetBeans website, I found NetBeans IDE UML Features. They highly recommend the SDE for NetBeans from Visual Paradigm. 
2. On the Visual paradigm website, I found 4 Quick steps to start UML Modeling in NetBeans
3. There is a NetBeans UML plugin that you can just install in NetBeans.See the NetBeans UML plugin project. See also what NetBeans' say about UML

After perusing  all the three options above, I did some more research and, 
This is how I integrated UML into NetBeans 7.3 and got It working!!
Step 1. I already had NetBeans 7.3 and Visual Paradigm for UML 10.0 Standard Edition already installed on my computer. I went to Tools->IDE Integration->NetBeans Integration (CheckBox)->Next->Next. This  installed UML into my NetBeans 7.3 install location automatically.
After doing this, I opened NetBeans and Created a new Java application and right clicked the application as described here. I did not see Visual paradigm options on the Right menu as expected. So I went to step 2.



Step 2.  I restarted NetBeans. I went to Tools->Plugins->Settings->Add-> type Name(UML), URL( http://dlc.sun.com.edgesuite.net/netbeans/updates/6.9/uc/m1/dev/catalog.xml )->Click Ok. Wait for this update process to finish. This finds the NetBeans UML Plugin. When this is done, go to Tools->Plugins->Available Plugins. You should see "UML" on the list. Check it and click install. When installation is done. Thats all.

 Step 3. To be sure that everything was successful, restart NetBeans -> NewProject. You will see UML on the list. Also, when you create a new Java project and you right click, now the Visual Paradigm menu is there as shown here. Enjoy!!

 I will be glad to hear from you. If you have never tried, try this. If you have tried and have gotten it working, share with us.

Wednesday 2 October 2013

Getting started with primefaces 3.4 in NetBeans 7.3.

Question: How do I get started with PrimeFaces in NetBeans?

Response: First of all, PrimeFaces is a JSF(Java Server Faces) Framework. JSF is a UI framework created to ease User Interface creation in Java Web Application development. There are a number of JSF frameworks e.g PrimeFaces, ICE Faces, Rich Faces, Oracle ADF e.t.c.
We shall Use NetBeans 7.3 to get a hello world application with PrimeFaces 3.4. Note that PrimeFaces 3.4 is already part of NetBeans 7.3. You might only need to download PrimeFaces if you want a different version from that already provided in NetBeans. If you have a higher version of NetBeans, then you might have a higher or similar version of PrimeFaces which is fine.

Requirements: You only need to have NetBeans 7.3  up and running on your computer. 

Step 1: Choose Project. Open netbeans and Go to File->New Project. A New Project window will pop up. Choose Java Web-> WebApplication . If you are running NetBeans for the first time after Installation, you might see some extra step as NetBeans tries to activate the Java  web environment, so don't worry. Click Next.

Step 2: Name and Location. In the ProjectName put PrimeFacesHelloWorld. Click Next. ProjectName is the name of your project, so it can be anything. Location is where it will be stored on your computer, so you can change the location by clicking browse if you want.

Step 3: Server and Settings. On the Server, Choose GlassFish Server 3.1.2., Java EE version is Java EE 6 Web, Optionally tick "Enable Contexts and Dependency Injection". Click Next.  If you are using another version of NetBeans, you  might have a different version of GlassFish. Its fine. You are free to use another Java EE server if you know how to, but since GlassFish  is the default for NetBeans, we use that for this tutorial. For a hello word application like this, Contexts and Dependency Injection (CDI) might not count but later if you are to do a bigger application, you might need it. So, Its no problem if you don't tick it for now. 

Step 4: Frameworks.On Frameworks,  tick Java Server Faces. Below, on Java Server Faces Configuration, select PrimeFaces. If you want to see the version of PrimeFaces you have, Click more. This also helps if you have more than one versions of PrimeFaces installed. NetBeans 7.3 has PrimeFaces 3.4 already installed. So, all you have to do is just tick it and your application will automatically be configured to use PrimeFaces. After all this, click Next

Step 5: Run. Right Click PrimeFacesHelloWord(with a blue round Icon) and Click Run. At this point, your application is already created. The application already has 2 Webpages. i.e index.xhtml and welcomePrimefaces.xhtml. If you notice under libraries, you can see primeFaces 3.4.jar. You can also right click index.xhtml and Run.

Step 6: You have arunning application in the browser. The Index page has a link(PrimeFaces  welcome Page ). Click this link and you will see a PrimeFaces page.

This note is optional. You don't have to read it to get the application to run but the information might be helpful.

If you want to use another version of PrimeFaces say PrimeFaces 3.5, just download the jar and after creating the Java web Project with JSF activated, right click libraries and add the Jar. 
Or Go to Tools-> Ant Libraries->New Library ->Library Name(The name for the library you are adding-your own naming)->Add JAR/Folder->Browse for the Jar you downloaded and add it(The jar will be added under the library name you just created). When you add a library here, It will be globally available so whenever you wish to add it in the project, you will always find it on the list of jars(after creating the project right click libraries ->Add library->you will see a list of global libraries and the library you added in ant libraries will be on the list), and also for PrimeFaces You will find it on the List when you are creating a PrimePaces application under more in the NetBeans Wizard.

Note: Images are coming soon. But if you follow well, you can have your helloworld program running. Let me know if you have any issues or any questions or even suppliments. Thanx.