Recent Articles / Archives

Search/Copy/Move file by extension

I recently had a problem to copy my PDF files to a different folder, to do this I could have used windows file search and select all and copy to a different location. But that’s a slow process and my windows explorer says “not responding” many times as there was above 3K PDFs on my computer. So I thought what if I can write a command line program which searches rigorously to the folders provided and finds all PDFs files for me and let me have a copy option to different folder as well. Initially I wrote a program to find files with “.pdf” extension but after successfully searching PDF files, I made it generic for all extensions provided. One interesting thing I found was the count of all the movies with “.avi” extension in some of my shared computer in my office. That was really interesting. And I thought of providing this to everyone, it would be more fun and useful for the needy as well. So let me share my small work which can be an effective tool for you as well. Download FileUtility.exe
The only thing required is JRE C:\Program Files\Java\JRE folder. For non-java users JRE can be downloaded on http://javadl.sun.com/webapps/download/AutoDL?BundleId=45832.
For Java Developers if you want to reuse the FileUtility API. You can download the JAR and browse the Javadoc and if you want to download Javadoc
Enjoy!!!!!!

MVC (Model-View-Controller)

Many of students and starter programmer are unaware of the MVC paradigm. This is my attempt to let them visualize how code can be highly maintainable and reusable by applying MVC pattern.

There are various design patterns already in existence which provide considerable benefits when applied. One such pattern is the MVC (Model-View-Controller) paradigm, which divides your application into three interoperable components:

  • Model: Represents the business data and any business logic that govern access to and modification of the data. The model notifies views when it changes and lets the view query the model about its state. It also lets the controller access application functionality encapsulated by the model.
  • View: The view renders the contents of a model. It gets data from the model and specifies how that data should be presented. It updates data presentation when the model changes. A view also forwards user input to a controller.
  • Controller: The controller defines application behavior. It dispatches user requests and selects views for presentation. It interprets user inputs and maps them into actions to be performed by the model. In a web application, user inputs are HTTP GET and POST requests. A controller selects the next view to display based on the user interactions and the outcome of the model operations.

Adhering to the MVC design pattern provides you with numerous benefits:

  • Separation of design concerns: Because of the decoupling of presentation, control, and data persistence and behavior, the application becomes more flexible; modifications to one component have minimal impact on other components. You can, for example, create new views without needing to rewrite the model.
  • More easily maintainable and extensible: Good structure can reduce code complexity. As such, code duplication is minimized.
  • Promotes division of labor: Developers with different skill sets are able to focus on their core skills and collaborate through clearly defined interfaces.

Happy coding!!!!

JSF 2.0 + Common Tasks

If you are looking for learning JSF and confused which version to learn then go for JSF 2.0 which has lots of features. Initially confusion may arise as there are still lots of resources teaching JSF 1.2 on the net. So for starting JSF 2.0 with some hands on experience of initial java project setup through IDEs, it’s easy and quick to start. There’s a good startup article plus it’s very specific and to the point by Andy Gibson titled as “How to do 10 common tasks in JSF 2.0” on DZone. Topics covered are

1.         Templating.

2.         Writing Code for the Page

3.         Trigger a method execution on the bean

4.         Hiding view elements

5.         Decorating content

6.         Creating re-usable content

7.         Ajaxify a page.

8.         Page Parameters

9.         Validate page

10.       Optional CSS Styling

This doesn’t include the initial configuration for JSF 2.0 project. Just to add on it if you are looking for initial setup for JSF 2.0 project just have an IDE of your choice, preferably Netbeans has a very quick startup on initial project setups. So have latest Netbeans create java web application and have JSF on the selection it will create JSF 2.0 setup and just follow on the link above and follow as per the article on Dzone. Required next is a good design and develop as per the business logic with some understandings on JSF.

« Previous Page  Next Page »