Wednesday Jun 28, 2006

Creator Tip: Making the table component look different

Some time you must be wondering, why should I use the same looking Table Component as others. Why can't I have different look. The ideal solution would have been, Sun Java Creator IDE providing a Theme Editor. However, ideal solution seldom exists in the real world. In such situation, it is better to look at other alternatives.

One of the solution is to override the properties of the implicit CSS classes used by the Table Component. But how to find these CSS class names. There are two ways to get hold of these names.

I wanted my table to have a different look than the default theme. I have overriden the following CSS styles in the resources/stylesheet.css. The result was a different looking tabe.

table.Tbl {
   background-color: #ffcc66;
caption.TblTtlTxt {
   background-color: #990000;
   background-image: none!important;
   color: #ffffb4;
   font-style: oblique;
   font-weight: bolder

.TblHdrTxt {
   background-image: none!important;

table.TblLt .TblHdrTxt {
   background-image: none!important;

table.Tbl .TblHdrTxt {
   background-image: none!important;
   font-weight: lighter

table.Tbl td, table.Tbl th {
   border-color: #ffcc66;

table.Tbl th.TblColHdr {
   background-color: #ffcc66;
   border-color: #f2b741

table.Tbl a.TblHdrLnk:link, table.Tbl a.TblHdrLnk:visited {
   background-color: #ffcc66;
   background-image: none!important;
   color: #663389;
   font-weight: bold;

table.Tbl a.TblHdrImgLnk:link, table.Tbl a.TblHdrImgLnk:visited {
   background-color: #ffcc66;
   background-image: none!important;
   border-color: #f2b741;

Thursday Jun 22, 2006

Sun Java Studio Creator Training at San Francisco

Today I visited (along with my colleagues Chau Nguyen & Jim Inscore) the Sun Java Studio Creator 3-day training site at San Francisco. It was fun to meet the instructors Gail and Paul Anderson and the attendees. There were lots of questions, which we tried to reply as much as possible

Some of the questions I remember are

  • Q: When can we expect Creator pack for Netbeans 5.5
    • A: Fall or early winter 2006
  • Q: Will there be a Desktop Application development project for Creator
    • A: Even though there were plans, now Creator being integrated into Netbeans, Creator user will automatically get access to Desktop GUI builder. This GUI builder lacks features like data binding and application model. However, such features are planned for future release
  • Q: One of the missing feature in Creator is Theme editor. Is there a plan for one?
    • A: Yes, a plan has been proposed. The implementation depends on management and marketing guidelines.
  • Q: While working with tons of pages, it is difficult to modify the look and feel because modifying the base template does not modifies the pages created from it. Is there a plan for tile integration or feature like master pages.
    • A: This feature is also in the future plan list.
  • Q: Will there be a support for floating windows. Creator 1 had this but removed in Creator 2.
    • A: This feature was removed when Creator 2 used Window manager from Netbeans 4.1. Also Creator 1 Window manager had a bug that caused the floated window to disappear or hide behind the main window. Interestingly Netbeans is introducing the floating window.
  • Q: Will there be a database visual design tool for Creator like M$ Access
    • A: Creator audience are expected to be day to day Rapid Application developers in a corporate IT environment. Where as database design tools are meant to be used by enterprise developers. Given that in mind this tool was not implemented in Creator. However, Creator pack on Netbeans 5.5 will inherit several advance database features from Netbeans.
  • Q: When I drag and drop a JDBC table component I want it to create a detail form, with out a need for user to assemble the form, just like it is done in tools like PowerBuilder. Is this possible
    • A: Yes, there is a plan. In fact the proposal is to provide a dialog to the user that would give option to either create a detail view form or normal table component.
  • Q: In tools like Delphi, when I click a select a component and then press F1 key, a dialog pops up to provide details about the component API, whether Creator can provide such feature.
    • A: Interesting feature. We could provide one like that. Currently the possibilities are to use the online help corresponding to component from dynamic help or to use the JavaDoc from the source editor.

One of the attendee asked me about how to provide a TextField in which user can type a SQL query and up on submission should dynamically create a table component based on the query output. This is an interesting exercise. I tried to provide an solution from top of my head. Probably, I'll create a blog on this exercise.

Another customer pointed out a bug in Netbeans 4.1 (up on which Creator was built). As per the bug Ctrl+Alt+F brings up a progress dialog for "Fix import", but fails to fix the imports. Happens intermittently.

Over all the visit was very pleasant. I was surprised to hear that an attendee has come all the way from Phoenix. According to the temperature at Phoenix is around 110 F. Hope he has enjoyed the cool San Francisco weather.

Monday Jun 12, 2006

Is JSP/JSF debugging supported in Sun Java Studio Creator?

Sun Java Studio Creator provides a powerful way to debug your web application project being developed. You can step through the Java code using the debugger support in the IDE. Also you can monitor the data flow inside the web application using HTTP Monitor utility tool

However, Creator does not support stepping through the JSP/JSF code. This is a limitation.  As you know, when the web application is deployed, JSP pages are compiled in to servlets and the intermediate Java code resides inside the Application Server's context. While debugging, the debugger actually step through this intermediate Java code. There was no mapping between this ugly intermediate java code and the corresponding line in the JSP. We expected that Creator user will be confused by these intermediate files suddenly appearing in the IDE's editor. That was the reason why we disabled the stepping through JSP code. If you try to place a break point in the JSP editor, you would hear a beep sound, indicating it is not allowed.

Good news!. This will be no longer a limitation in the future release of Creator. For the next release of Creator pack over Netbeans, stepping through JSP code will be supported. Netbeans currently maps the intermediate Java code line (being debugged) to the corresponding line in the JSP. As a result the line in the JSP is correctly highlighted. The ugly intermediate file no longer surfaces, which is good news for the Creator customers.

Wednesday May 31, 2006

Got the autographed copy of Sun Java Studio Creator Field guide

Today, I received the book, Java Studio Creator Field Guide, Java ONE Edition, autographed by the authors. It was so nice of them to send it directly to my home address. I will treasure this book, especially because of the authors' personalized autograph. I had the privilege of working with these great authors when the book was in the making and also for Hands On Lab during Java ONE.

I would highly recommend this book for all Creator users, especially for beginners who want to learn about Creator (chapter 1-7) and for advanced users as well (chapters 8-13).

You can read more about this book at

Sunday May 21, 2006

Third party JSF components for Sun Java Studio Creator

I happened to visit two of the booths (among others such as TIBCO and Exadel etc, who were also exhibiting AJAX components) exhibited at the Java ONE pavillion hall. Both booths were demoing their respective JSF components. I noticed they also have written Creator design time for these components, so that they could be imported in to Java Studio Creator and available for drag and drop from the Palette window.

The first booth I visited was ICESoft Technologies Inc. I talked to two of the ICESoft engineers Greg McCleary and Pat Corless. According to them, the complib to import these components in to Creator could be downloaded from their web site. A free registration may be required to download the community edition

The second booth I visited was Infragistics. Their JSF components are called NetAdvantage for JSF. As per the Infragistics Senior Architect Stephane Bastian, the complib to import these components in to creator could be downloaded from their web site.

The JSF components from both the companies are AJAX enabled. I haven't tried them myself yet. If I happen to try them, I'll write about my experience in my future blog.

Wednesday May 17, 2006

Sun Java Studio Creator to be open sourced

Yes!, it is official and annouced at the Java ONE key note by Jeff Jackson, Vice President of Java Developer Platforms Group at Sun Microsystems.

Tuesday May 16, 2006

Sun Java Studio Creator Pack for Netbeans

Yesterday in the Netbeans day and today at Java ONE, it has been announced that Sun Java Studio Creator will be available as a pack over Netbeans platform (code named Shortfin) along with Enterprise pack and Mobility pack. This makes Netbeans a complete platform for rich design of

  • Enterprise application
  • Desktop swing Application
  • Web application
  • Mobility application.

In the demo (see picture below) Sandip Chitale, Senior Staff Engineer of Creator team, showed the crowd at Netbeans day, how an end to end web application development could be achieved using the Creator pack installed in Netbeans 5.5. His demo included developing a web service, consuming it in the web application and finally debugging and stepping through the web service code after deploying the web application to the Sun Java Application Server to fix a bug in the web service. Simply awesome!

Thursday May 11, 2006

AJAX Components are available for Creator users

Today, Sun Developer Network announced the availability of AJAX components for Sun Java Studio Creator 2 IDE.

Also in order to see these samples in action, you can run the "Flower Store" demo application directly from

Here is a screen shot

Wednesday May 10, 2006

Creator Tip: CSS based templates for similar page look and feel

One of the powerful features of Sun Java Studio Creator is the ability to save your web pages as template. New pages could be created using the saved page template. This gives a powerful way to make most of the pages in your web site with similar look and feel. I have created a simple website with one page that can be saved as template and then used to create other additional pages with that template for same look and feel. You can down load the project from here.

In order to use the page in this project as template, do the following.

  • Download the project and extract the zip
  • Open the project in Creator 2 Update 1.
  • Right click on the project (SampleTemplate1) and select "Save Project As"
  • In the dialog select the location and project name for the new project. You can also check "Add project to template list" checkbox. Next time when you create a project you will see your project as template under the Category "My Templates". You can create new project using this saved project template. (Note: Unfortunately because of a bug in Creator the package name will be same as the original project)
  • Now, open the new "Saved As" project. You should see all the contents from the original project including WebTemplate1.jsp
  • Right click on the WebTemplate1.jsp and select  "Save as Template".
  • In the popup dialog select the Category Template -> Web Pages and click OK. Your page is saved as template.
  • To create a new web page with the saved template, right click and do Web Pages -> New -> File/Folder
  • Select the WebTemplate1.jsp. (Now onwards you will see  Web Pages -> New ->WebTemplate1.jsp.

Bingo!. You have created a new page with exact look feel as the template page. Now go ahead and modify the new page as per your heart's content. You can create any number of web pages from the template with similar look and feel.

The web page template I created looks like the following image.

Saturday May 06, 2006

Creator Tip: Adding components to dynamically created table

I saw some query in the Sun Java Studio Creator forum about adding components dynamically to a Table component if the table itself is dynamically created. I've already blogged on how to dynamically create a Table component. Read about how to add a Button component to the dynamic table at

Friday Apr 07, 2006

Creator Tip: Understanding the checkbox component to display non boolean value

Some database such as Apache Derby does not support boolean type. According to JDBC documentation (see Table 8.7-JDBC Types Mapped to Database-specific SQL Types), the JDBC type BIT is mapped to the Java type boolean. If you look at the supported data types for derby, BIT (boolean) is not listed. In such case SMALLINT (1 or 0) is used to represent boolean type. However, SMALLINT does not map directly to boolean but to the Java type short. If the user wants to bind this column (SMALLINT) of the database table to a checkbox component, the actual status of the columns will not be reflected in the displayed table component. i.e column row with 1's will not be displayed as selected checkbox. This tip explains how to work around this and also explain about how checkbox component can be used to display any type of column. You can download this tip project from here.

First we need to understand the basic checkbox component. The bundled basic checkbox component is a versatile component. It can handle more than just boolean value. It can behave as

  • A boolean control
  • An object value holder, which can be other than a boolean type  (behaves as a non boolean control)

Checkbox as a boolean control

If the database column is of type boolean, then this is a non brainer. Bind the checkbox to the database column directly and the checkbox would display the status as checked for the value true and unchecked for the value false. However, this is problematic if you are using database that does not support boolean type and you are using a SMALLINT to represent the true (1) and false (0) state. In this case you need to use the following work around.

Assume in the bundled database, the table "DataSources -> Travel -> Person" has a column "FrequestFlyer" which is of type SMALLINT (derby database connection). If the person is a frequent flyer, then the value of the column is 1, else 0. We want to display this column as a checkbox. In order to achieve this follow the below steps.

  • Create a project (call it NonBooleanCheckbox).
  • Add a Table component from the Palette.
  • Assume you have already connected to the derby database, drag and drop the "person" table on to the table component.
  • Right clcik on the table component and bring up the table layout dialog.
  • Selected the FrequentFlyer column and change its component to checkbox
    (Note: if this column is of type boolean, checkbox will be automatically selected for you)
  • Select the source from the project node and add a property of type boolean (call it frequentFlyer). Following code will be generated.
    public boolean isFrequentFlyer() {
        Object value = getValue("#{currentRow.value['PERSON.FREQUENTFLYER']}");
        if(value != null){
            Integer freqFlyer = (Integer) value;
            return freqFlyer.intValue()==1? true : false ;
        return false;
    public void setFrequentFlyer(boolean frequentFlyer) {
           setValue("#{currentRow.value['PERSON.FREQUENTFLYER']}", new Integer(1));
           setValue("#{currentRow.value['PERSON.FREQUENTFLYER']}", new Integer(0));
  • Select the checkbox (table->tableColumn4->checkbox1) and click on the [...] of the selected property to bring up the custom property editor. In the dialog select Page1 -> frequentFlyer and click ok. Now the checkbox is bound to the frequemtFlyer property.
  • Deploy the application. You should see in the frequent flyer column, the rows with value "1" is selected and with "0" are unselected. (See Picture below)

Checkbox as a non boolean control

The checkbox component has two attributes selected and selectedValue. When used as a boolean control the selectedValue attribute is not used. The value of the selected attribute is set either as true or false. When used as a non boolean control both selected and selectedValue are used. When the value of the selected property is equal to the value of the selectedValue property, the checkbox is in a selected state and a checkmark is displayed.

Let us see an example. Assume you want to display a selected checkbox if the job title of the person is VP. Follow the below steps.

  • Add another Table component from the Palette
  • Drag and drop the "person" table on to the table component. Select to use the same CachedRowset when asked.
  • Right clcik on the table component and bring up the table layout dialog.
  • Selected the JobTitle column and change its component to checkbox
  • Select the selectedValue property of the checkbox in the propertysheet and type the value as "VP"
    Note: If the column type is not a string but an integer then you need to set the value in the Java source as
    public void prerender() {
        checkbox2.setSelectedValue(new Integer(20));
  • Deploy the application. You should see in the job title column, the rows with value "VP" is selected and rest are unselected. (See Picture below)

What happens when the user click on the checkbox to select it. In this case the value of the selected property is assigned the value of the selectedValue property. However, if you deselect the checkbox the selected property is set to null and if you update, you might loose your original values in the database. So in this scenario, my recommendation is to use a read only (disabled) checkbox, just to display the state. Use the method I discussed in the section "Checkbox as a boolean control", if you need to update the non boolean columns.

Thursday Mar 30, 2006

Creator tip: How to create a table component dynamically

One of the questions often asked by the Sun Java Studio Creator customers is - How to create a table component dynamically?. This tip gives some hint on how to create a table component programmatically in a web application.

The preferred way to create a table component is by dragging and dropping it from the palette on to the designer and then bind it to a data provider. However, some advance users might want to create the table component programmatically based on some dynamic logic.


Monday Feb 20, 2006

ObjectListData Provider work around - Sample Project

Few Creator users left comments in my previous blog Work around for Object List Data Provider design time problem, stating that they tried the work around but it did not help. So I decided to write a sample test project.

You can download the from here

The simplest way to use ObjectListDataProvider is to add ObjectListDataProvider from the palette and then set your java.util.ArrayList of objects using the property sheet. Unfortunately due to some bugs in Creator this doesn't work. That is why some work around is needed until the bug is fixed in the future release.

To test the downloaded ObjectListDataProvider test project, do the following
  • Open the project in Creator 2.
  • Clean and Build the application.
  • Close the project.
  • Reopen the project.

Note:The above steps are necessary because of some class loading problem in creator design time which will be fixed in future release.

  • Now drop a table component on to the designer
  • Bring up the table layout and select "nameListDataProvider" and close the dialog.

Now the table should display some sample data I added.

This is how I added the object list data provider to the application

  • Added a class called "Name" with two properties "first" and "last" (Constructor takes two arguments)
    (This is the object which holds the data)
  • Added another class called "NameListDataProvider" which extends ObjectListDataProvider.
    (The sample data is added in the constructor)
  • Added a property called "nameListDataProvider" (of type NameListDataProvider) to the Session Bean.

BTW, if you make any changes to the classes "Name" or "NameListDataProvider" you must compile close and reopen project.

Note: As it is pointed in the comment below, to make it work at runtime, add the following statement to the session bean init() method

nameListDataProvider = new NameListDataProvider();

Tuesday Feb 14, 2006

Creator Tip: Work around for Object List Data Provider design time problem

Due to some design time source modeling and class loading problem, looks like Design Time support for Object Array and Object List Data Provider is broken in Creator 2. Here is a work around to solve this problem.

Assume you have a list of Search Data in an object called "SearchData", to display java.util.List of SearchData in a table using Object List Data provider do the following.

First create a Java Class called SearchDataProvider.


public class SearchDataProvider extends ObjectListDataProvider{
   public SearchDataProvider () {
       setList(<your java.util.list of data here>);

In the add a property of type SearchDataProvider (Right click on the and select add -> property in the project windows). This action will add the following code to the

  private SearchDataProvider  searchDataProvider = new SearchDataProvider ();

   public SearchDataProvider getSearchDataProvider() {
       return searchDataProvider;
      public void setSearchDataProvider(SearchProvider searchDataProvider) {
       this.searchDataProvider = searchDataProvider;

Now add table component to the designer and select "Table Layout" from the context menu. In the dialog select "SearchDataProvider" in the drop down menu. You should see all the properties of your "SearchData" class as column in the Table column. The data from your "SearchData" objects will be displayed in the table.

Friday Feb 03, 2006

Creator Tip: Displaying two dimensional array in the table component

This tip explains how to display a two dimensional array of data in the Table Component. Creator comes bundled with dataproviders to display database table in the Table, along with other dataproviders like ObjectArrayDataProvider and ObjectListDataProvider to display data from POJOs (Plain Old Java Objects) using reflection. Unfortunately no dataprovider exists to display just a two dimensional array of data.

Read about how to create a two dimensional array data provider at


« June 2016