For some reason the option "Work Offline" was removed from the interface. It took some fursther digging to realize that there is a settings.xml file in %user_home%
Friday, November 13, 2009
Using Maven in Netbeans
For some reason the option "Work Offline" was removed from the interface. It took some fursther digging to realize that there is a settings.xml file in %user_home%
CardLayout With Netbeans
Here is a simple tutorial that illustrates the use of CardLayout with the Netbeans GUI-Builder. For this I am using Netbeans 6.7.1.
1. Create a Java Desktop Application.

2. Name your application CardTester (or whatever you want, I am going to name mine CardTester). Make sure you choose an appropriate name for your Application Class including the package name.
Click Finish when you are done. The application is created.3. Ensure that the Inspector window is visible. If not look in the Window > Navigation menu for it.
In the Inspector Window you can see all the components that make up your user interface and how they are associated with each other. The default application is made up of the main application window along with a mainPanel and a menu bar and a statusPanel. We will add a CardLayout to the mainPanel.4. Right click on the mainPanel, select Set Layout from the context menu then select Card Layout.
5. Now lets us drag two cards onto the mainPanel. From the Palette window, click on Panel and drag it onto the mainPanel. You will see the panel under the mainPanel in the Inspector window. Make sure that the new panel is selected and change some properties.name : card1
Card Name: card1

Change any other property that you wish.
6. Repeat step 5 to add another card. Lets call this one card2. The Inspector window should now look like to following illustration.
7. Lets add some content to the cards so that we will be able to see them change. Make sure that card1 is selcted and drag a label onto the card, set any text you wish. Next select card 2 and do the same.

8. Now we can add some functionality that will cause the cards to flip. For this we can use a single button that will flip the cards as it is clicked. Drag a button to the status panel. Right click on the button and choose Set Action... from the menu.
From the Action drop down select New Action... type in a Method Name for the action. You may also add the display text, tooltip and accelerator for the Button.
Click OK when ready. The code view becomes visible. The method that you choose is added to the code.9. Add code.
@Action
public void cardSwitcher() {
CardLayout cl = (CardLayout)(mainPanel.getLayout());
cl.next(mainPanel);
}
10. Run the application. If you are really really lucky, when you click the button the cards will change.
I hope this very simple tutorial makes it a bit easier to use the Netbeans GUI-Builder to create a Card Layout.
For more info on using the Card Layout itself visit this page.
Wednesday, September 23, 2009
Installing JAR file to Maven Repository
mvn install:install-file
-Dfile=path/file.jar
-DgroupId=groupName
-DartifactId=artifactname
-Dversion=file versiomn
-Dpackaging=jar
Tuesday, September 22, 2009
Gravatar
Thursday, August 27, 2009
SQL Server 2005 Training
I find that interesting because I have always given more attention to development rather than administration. Frankly, backing up databases does not light a fire under me. But the range of automation possibilities proves rather exciting as a developer since I can envision how the entire range of administration tasks can be automated with some simple programming.
Tuesday, May 19, 2009
My Stack Overflow Profile
Monday, December 08, 2008
New Development Team
As with all new projects I want to do things the right way from the start. Here are a few of the things I have already put in place even before the team comes on stream.
- Issue Tracking - I am using fogbugz to track the cases for the development. I have experimented with it for the last two months and I am impressed. I have been reading Joel's articles for years so it probably was a given that as soon as I needed issue tracking I would turn to his solution. I am also using this software as a requirements tracker.
- Subversion - I am in the process of setting up an Ubuntu server with websvn. I understand that fogbugz could integrate with this easily. Lets hope.
- Apache Continuum - For continuous integration.
Tuesday, July 01, 2008
First IPG Launch in Trinidad and Tobago
In case you were wondering, the worldwide Baha'i community is involved in creating a new world civilization. The purpose of the Baha'i Faith after all, is to unite all peoples and races into one universal cause and one common Faith. To understand the purpose of the Baha'i community better this article might help: A New Vision for Humanity's Future.
The Universal House of Justice, the supreme ruling body of the Baha'i Faith, directs the spiritual and administrative affairs of the Bahá'í International Community. The Universal House of Justice has been directing the Baha'i world to create a systematic plan for the advancement of human civilization. One aspect of this plan was to create clusters by grouping certain localities all around the world. So here in Trinidad and Tobago, we have five clusters. Tobago is a cluster by itself, then in Trinidad there are North East, North West, Central and South. Each cluster is responsible for implementing the plan within their boundaries in the most appropriate manner to the inhabitants of the cluster.
As the work of the Baha'is become more systematic and the efforts of the Baha'i friends starts to show signs of progress an IPG is launched. Thus, the work of the community of Baha'is in that cluster is considered to be in an advanced stage of systematization.
This is why it is so exciting to see the first IPG launch in our country. All Baha'is in Trinidad and Tobago are very proud of the work that was done in the North East cluster and joined in the celebration. The valuable lessons learned in North East may now be used to assist the other four clusters in this country to advance.
The World Order of Bahá'u'lláh encompasses all units of human society; integrates the spiritual, administrative and social processes of life; and canalizes human expression in its varied forms towards the construction of a new civilization.
(The Universal House of Justice, A Wider Horizon, Selected Letters 1983-1992, p. 66)
Early Phase of Education
During the program, the children had the opportunity to display some of the wonderful things that they learned during the two years that they spent at the preschool. Some sang, recited poetry, sang in Spanish, performed gymnastics and so on. Clearly the children were happy to perform for the admiration of their parents and the parents were happy to see their children perform.
I was asked to give a short talk at this ceremony. And this started me examining the idea of the first phase of the children's education and its impact on the rest of their lives. I have heard that the personality of the child is formed in the first five years of their lives. Basically, you are stuck with whatever you develop in those few years.
I started off by looking at the idea of education from the Baha'i perspective.
Regard man as a mine rich in gems of inestimable value. Education can, alone, cause it to reveal its treasures, and enable mankind to benefit therefrom.
(Baha'u'llah, Gleanings from the Writings of Baha'u'llah, p. 259)
In this excerpt from the writings of Baha'u'llah I found that a person is created with a measure of capacity. Education is then the process of revealing this capacity rather than filling an empty vessel. These capacities, or treasures, become evident as the education of the individual continue. We have started seeing some of these treasures in our children from just a few short years.
The children learned to read and write, do basic mathematics, Spanish and gymnastics. They also learned to interact with their peers, and to be involved in a group. Valuable lessons for their future. Isn't this enough to celebrate?
Another point from the above passage is the fact that mankind will benefit from the education of the individual. This is only true if the education of the child include spiritual education. Without a spiritual education the individual will be a monster in this society and work only for his own benefit. A person with a spiritual education however, will work for the betterment of the world.
As to thy question regarding the education of children: it behoveth thee to nurture them at the breast of the love of God, and urge them onward to the things of the spirit, that they may turn their faces unto God; that their ways may conform to the rules of good conduct and their character be second to none; that they make their own all the graces and praiseworthy qualities of humankind; acquire a sound knowledge of the various branches of learning, so that from the very beginning of life they may become spiritual beings, dwellers in the Kingdom, enamoured of the sweet breaths of holiness, and may receive an education religious, spiritual, and of the Heavenly Realm.
(Abdu'l-Baha, Selections from the Writings of Abdu'l-Baha, p. 142)
With these thoughts I had to reflect on the quality of education, both spiritual and academic, that my son receives. And that is the real benefit of this graduation ceremony. Hopefully, we can remain conscious of this over time and continue to ensure that he does receive the right education.
Tuesday, June 24, 2008
Creating Modular Struts2 Applications with AppFuse and Netbeans – A Tutorial
Introduction
I am not in the habit of writing tutorials but I found that there was a very small niche that I couldn't find adequate documentation for so I decided to write this tutorial. I recently created a new application in which I used the excellent Struts 2 framework. I used Hibernate for persistence and Spring for dependency injection. I used Sitemesh to decorate the user interface and Freemarker to create the forms.
At first the list of technologies was overwhelming and I spent more than a month trying to figure out how to get all these to work well with each other. When I came across Matt Raible's most excellent framework AppFuse it was a Godsend. AppFuse can get you up and running in a few minutes with a large number of configurations.
I found that I was able to create projects without worrying about the configuration and then customize to suit my own needs. The documentation for AppFuse is very good and most of what I write here is covered. Its just that in using Netbeans there are a few points that I had to look in the mailing list for. So its only a very small bit I have to add. You will find appfuse quickstart at http://appfuse.org/display/APF/AppFuse+QuickStart.
Setting Up the Environment
First, lets make sure that we have everything installed and configured. You will need:
Netbeans 6.1 – http://www.netbeans.org
MySQL 5 - http://www.sun.com/software/products/mysql/getit.jsp
Java 6 – http://java.sun.com
Maven 2.0.7 at least - http://maven.apache.org/
On the respective websites there are installation instructions so I will not repeat them here. However there are a few things that I would mention.
Netbeans
After Netbeans has been installed you may install the Maven plugin.
Start by opening the Plugins window. Click Tools > Plugins. In the plugins window you can update existing plugins or install new plugins. Click on the Available Plugins tab. You will see the list of plugins that are available for download. See Figure 1.
Figure 1: Available Plugins in Netbeans
Search for the Maven pluigin and select it then click Install.
After the installation Netbeans is now Maven Aware.
Maven Local Repository
Create a local repository for Maven so that the project could be built even without an Internet connection. Select a location on the hard drive and set the following in the M2_HOME/conf/settings.xml file:
<localrepository>path/to/your /local/repository</localrepository>
Creating the Application
Now its time to create a new application, and this is where the magic of AppFuse happens. As the title implies this project is using Struts2 Modular architecture. AppFuse allows many different configurations so you should visit the website and see for yourself.
1. Open a command window and run the following command.
mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-modular-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.2 -DgroupId=com.mycompany.app -DartifactId=myproject
Make sure you change com.mycompany.app to your own package structure and myproject to the name of your project. Maven creates a directory with your project name.
2. CD into the newly created project directory
In here you will find a file called pom.xml. This file is the main configuration file for Maven. Open it and edit the Database Settings. You will find these near the bottom of the file. Add the user name and password necessary for your database.
3. Run mvn
This downloads all the files and dependencies from the internet for you. It may take a long time to run. The database will be created in MySQL at this point.
4. Run mvn war:inplace
This will copy the source code from the appfuse wars into your src directory and give you a chance to make changes to them.
5. Run mvn appfuse:full-source -DrenamePackages=false
This is necessary for Netbeans to find the dependent classes. It basically installs all the source code into your application. The rename packages option is necessary if you want to keep the appfuse packages separate from your packages.
6. Now lets test your project and make sure its working. CD to the web directory of your project. Run mvn jetty:run-war.
This builds your website and starts the Jetty server. You can now open your browser and visit http://localhost:8080 to see your application. The default user name and password is admin/admin.
7. Now you can open Netbeans and click File > Open Project. Browse to the location of your new project and click on it. Make sure that you select the Open Required Projects checkbox. Click Open Project button.
Now edit your project to your hearts content.
Friday, March 14, 2008
How we learn
Long term memory contains the things that we actually learn. For example, your address, how to tie your shoes, how to drive and so on. Most of us cannot remember what we ate for breakfast on the third of April 1987. That is because, that fact was not important enough to make it into our long term memory.
The trick is getting the things we need to know into our long term memory. Apparently, our brains are selective about what gets into the long term memory. So I may want to learn how to use the JPA and Hibernate and Spring and Struts 2 and a myriad other frameworks, API's and tools but my brain may decide that its not important enough to remember. Instead, I could quote word for word every line from the Lord of The Rings. Why?
Recently I started attempting to use Appfuse to create a new project that I am about to build. Since I am already experienced with Hibernate, Struts 1.x and some of the other technologies involved I thought that I would breeze through the learning phase. That was not that case. After examining why it was so difficult for me to learn this framework I realized that I never gave myself the chance to learn. I approached the task of learning with arrogance. Believing that I already knew enough.
Arrogance closed the door to learning. So I tried a series of ten minute approaches and none worked and my frustration grew and I blamed Appfuse for being too complex.
Then one day I spent several hours working on Struts 2 alone. I found it quite easy to pick up and learn. I stopped, rested did no more learning that day.
The next day I spent several hours on sitemesh. Again, quite easy to learn and use. I then spent some hours each on Freemarker, Maven and Spring. At the end I tried Appfuse again and found it quite easy to use. In fact I wonder how I ever got anything done before.
The lessons I learned is that first, don't be arrogant about your knowledge. There is always more to learn. And second, give yourself a chance to learn. That is, make time to spend on the topic, make sure you don't crowd too many different new things into the same day. Your brain needs time to convert the things you experience into long term memory.
Sunday, October 21, 2007
Case Sensitivity in MySQL
I made some changes to my database schema and attempted to upload the application. While running the tests on the Linux environment I started getting some strange data related errors.
After fiddling around for several hours I realized that MySQL is case sensitive in the Linux environment but not in the Windows environment. Generally, I use all lower case names in the database schema so I never noticed before.
I carelessly (but probably luckily) used an uppercase name in the change that i made to the schema. Then using mysqldump to export the database on the Windows machine and re-import the database on the Linux server caused a unforeseen effect. Mysqldump lowercased all the identifiers in my schema. So Foo became foo.
I have no idea how the import did not complain...but Hibernate used my uppercase identifiers when generating the SQL statements and blam...all hell breaks loose.
I went through all my configurations for Hibernate to ensure that I did not make the mistake anywhere else, then re-created the database schema and re-deployed. Now everything works. I wonder what other surprises are in store for me for being so bold (read:stupid) as to work in a mixed environment.
Friday, October 05, 2007
Hibernate InstantiationException
I have an inheritance hierarchy with an abstract class called Case and two concrete sub classes named MedstarCase and RoadsideCase. I am using the table per subclass strategy for persisting these objects. This worked fine until suddenly this morning, code that worked all along blew up.
I got org.hibernate.InstantiationException Cannot instantiate abstract class or interface:! I immediately revisited my mappings and painstakingly ran tests to determine the cause. But I found nothing to give me any clues. So I paused to think. What did I do this morning to my code.
I added a new collection to the Case. But the Case already had several collections and none of them caused problems before...and I checked that the mappings were similar.
I had re-imported some data into the database. Aha! I turned to the database to check my data. I had cleared the entire database and re-imported data to run some tests on the data migration code that I would need this coming weekend. I counted the number of rows in the Case table and the number of rows in the medstarcase and roadsidecase tables and found1367 Cases but only 600 medstar cases.
All along I was trying to instantiate Cases that did not correspond to any concrete class. Needless to say this was carelessness on my part for not verifying my data. I keep learning these valuable lessons the hard way though.
After clearing the data, fixing the data import program and re-importing the data, everything worked fine.
Thursday, October 04, 2007
Development Environments
For the last year and a half I have been using Netbeans as my IDE of choice. It took some time but I was finally converted from eclipse. Now don't get me wrong, eclipse is a very good development environment and probably enjoys wider support than Netbeans. So nothing is wrong with it. There is one place where Netbeans has the advantage though...installation and configuration.
With Netbeans, the installation is easy and the add ons are just as easy. Finding the updates and installing them are a very simple process. Setting up eclipse and configuring all the tools that you need to work with has been a headache. After the set up everything goes smoothly and the tools do a great job. In my case I found that I have to set up several different machines and after a while I started appreciating the simplicity of the Netbeans installation.
I see that with Netbeans 6.0 all the common tools are included in the installation so its now even easier than before. I would usually download Netbeans and the Visual Web Pack and several others. I am looking forward to using 6.0 for this reason.
Monday, July 31, 2006
What this blog is about.
I have two jobs at the moment. First, I am a lecturer at the School of Business and Computer Science (SBCS) where I lecture a number of courses that fall in the field of computer science. Second, I am a software developer that use these technologies and more in my development work. In addition to my work I also have some thoughts on the Baha'i Faith that would like to share.
As far as lecturing is concerned, I hope that students would find some of these posts useful. I would try to post answers to questions that students frequently ask as well as pointers and tips on the various courses that I teach. The courses are:
- Object Oriented Software Development - Level 3 - BSc. Degree in Computing - University of Greenwich.
- Introduction to Computing and The Internet(CIS110) - Level 1 - BSc. Computing Information Systems - University of London
- Advanced Programming Concepts(CIS212) - Level 2 - BSc. Computing Information Systems - University of London
- Software Engineering(CIS210) - Level 2 - BSc. Computing Information Systems - University of London
As a developer I develop software for corporations as a consultant. In some cases I use the Java Platform and in some cases I use the .NET platform. I use Java whenever I have some degree of flexibility to choose the development platform and I use .NET when the company dictates the environment based on their own internal criteria. Maybe they have a team of inhouse developers that are already trained in the .NET environment.
Recently I put together a number of technologies into a single framework that will serve as the starting point for my future development work. I used Struts, Hibernate, Tiles, JSF and others. Later I discovered the AppFuse project. I haven't had a chance to evaluate that framework but it is doing exactly what I was trying to do. It most likely is superior so if you are looking for such a framework I suggest that you try it. In the mean time I learned a few things and wanted to share them with others who may be attempting to get these technologies to work together.
Finally, (but most importantly) I am a Baha'i and I wish to share some of the ideas that I have come across while reading and investigating the Faith. It is not my intention to repeat a number of facts about the faith here. You can get that at the Baha'i International Site . However, I would discuss some concepts and experiences I have had as a Baha'i.
As time goes by I will re-evaluate my content to see if I could focus the discussion better. But thats the best I could do for now.
Some Notes on Plagiarism
I thought that I could start with this same theme since most of the students that I deal with would be faced with this issue. Plagiarism comes in many forms and it is important that students are aware of both the forms of plagiarism as well as the implications of plagiarism.
From dictionary.com I found this definition:
"Plagiarism
n 1: a piece of writing that has been copied from someone else and is presented as being your own work 2: the act of plagiarizing; taking someone's words or ideas as if they were your own"- http://dictionary.reference.com/browse/Plagiarism
A question that is frequently asked is "how much could be copied before it is considered plagiarism?" The answer should be NONE AT ALL. Even a sentence or part of a sentence from a web site or a book will be considered plagiarized IF it is nor referenced. That is the main distinction. Any work taken from another source must not be presented as your own.
If you find a definition on line, and wish to use it then you should make a reference to the source. If you leave out the reference then you are saying that you developed the definition and you are guilty of plagiarism. It is also useful to mark the copied sentence so that it is clear that it is not part of your work. For example, you may wish to format the sentence in italics and use double quotes. The reference should then be placed immediately after the quoted text.
Having said that it is also important to note that a student cannot copy an extensive piece of work, reference the entire thing and hand it in as an assignment. You should keep the quoted sentences to a minimum. Remember that you are being marked on you own contribution (or work). If you copy every line in your report then you did not do any work that is worthy of marks.
As for the implications of plagiarism. The first and most obvious implication is that you are going to be penalised if you plagiarise. That is, you could be marked as fail for the assignment that you did, or marked as fail for the entire course. There is also some implications for the honours that you get for the degree.
Another less obvious implication is in your future career. Plagiarism is not only a concern at the university but is a serious concern in the cororate environment. A mark of plagiarism against you has some serious consequences later in your career. Another point to note is that your lecturers play an important role in your career development. They provide recommendations to your potential employers for instance. If a lecturer suspects plagiarism, you will not get a good recommendation.
So to conclude, do not copy any words or code from any source unless you clearly mark it and reference it. There is more than a good chance that your lecturer will discover it and the consequences would be dire.
