Dienstag Jan 06, 2009

A MySQL GlassFish Application

During my time as a teaching assistant, I used to say to the students, "Imagine, you visit your grandmother and she asks you, 'Now boy, what did you do at the university today?' It's hard, but you have to do your exercises in a way, as if you were talking to a six year old." On the other hand, students are often frustrated, if they don't understand a subject down to its bare bones. It's only natural to have such feelings.

Giving a tech talk, you have to find an interesting sample, but it also has to be simple, for you don't want your audience to fall asleep. I was dreaming of a database-web application without tables full of employees, departments and managers or flight schedules. It had to be something, where the design tools and the web stack stand more in the foreground.

I started a project -- www.mimesy.com, using the NetBeans IDE, JSP, the jMaki framework, the MySQL DBMS and the GlassFish application server. It's some kind of a blog site, but the user cannot actually blog, microblog or nanoblog or upload any media files. The only thing you can tell the world is a color. There is also no history of colors, just a color you have at the moment. Login data and the color information can easily be stored in only one database table.


Donnerstag Jul 24, 2008

The Number of Rows

Last month, I held a presentation where I showed how to create a rich client application for a MySQL 5 database using the NetBeans 6.1 IDE. For a single table we can use the Database Application template (New Project → Java → Java Desktop Application → Database Application). Assuming that the table exists and we have created a connection to it, we get a ready to use GUI by just clicking 'Next' and 'Finish'. One of the funny things we can add in the GUI editor is a slider, whose value is bound to a data field (Properties → Binding tab). Then the data in the form gets updated when the slider is moved.

   

             

Suppose we want a label to reflect the number of rows in the table, especially we want the label to change when the number changes. Unfortunately, the bind trick doesn't work in all situations. A bound label doesn't get updated when we add or delete rows. During a demo, you don't want to write to much code and you want the solution to be simple. Without going to much into detail, we get the update functionality by adding an event handler for main frame's propertyChange events.

   private void formPropertyChange(java.beans.PropertyChangeEvent evt) {
       rowCountLabel.setText(Integer.toString(masterTable.getRowCount()));
   }

About

Sun Campus Ambassador,
University of Frankfurt (Germany)

Search

Categories
Archives
« April 2014
MoDiMiDoFrSaSo
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Heute