Friday Jul 11, 2008

Generic Web Page Designer for Netbeans, anyone?

Visual JSF designer in Netbeans provides a way to design a web page visually. Unfortunately, Visual JSF web page designing is limited  to JSP based JSF web pages created by Visual JSF framework. However, Netbeans users might want to design web pages created by various frameworks. Such pages include HTML, PHP, JSP, RHTML (Ruby on  Rails), XML (facelet) etc. So I thought it is worth a time to explore the concept of a generic Web  Page Designer, with out any restrictions of any particular framework. If you are interested, you can read my proposal for a generic Web Page Designer at The proposal includes Web Page Designer Concept Overview and Web Page Designer Design Concepts.

Web Page Designer

I also spent some time to create a prototype of a HTML designer. This designer will be the foundational designer for all other page designers (like PHP, JSP etc). Other page designers would be extended from this designer. This is obvious because HTML is a subset in all page types.

This HTML designer embeds Mozilla Layout Engine (XULRunner) for rendering the web pages. Therefore, unlike Visual JSF designer, user would get hi-fidelity rendering of the web pages. Details on embedding Mozilla in Netbeans is available here.

I've used JAVA-XPCOM API to interact with underlying XULRunner to facilitate page design. Unlike other Mozilla based Web Page authoring tools like NVU, in this designer I'm not exposing the Mozilla Composer, but directly manipulating the Mozilla DOM for visual editing. The advantage is, I can execute JavaScript on demand using XurRunner API. This helps me to render JavaScript based Web 2.0 AJAX widgets (Yahoo, jMaki, Google etc) in the designer. This unique feature I've not seen available in any of the popular WYSIWYG HTML designers, I could lay my hand on, like DreamWeaver or Microsoft expression. Another interesting feature I implemented, is the direct manipulations of CSS style of a HTML element selected in the designer using the Style Builder view docked in the bottom. Any modification of a CSS property in the Style Builder is immediately reflected in the designer.

Oh!, but one bigger question still bothers me - Are Netbeans users really interested in a Web Page Designer or am I just wasting my time?

Saturday Jun 07, 2008

Assemble your Widgets and create a Social Web Application using Zembly

Earlier, using tools like Netbeans and Visual Web, you could easily whip up an Ajax enabled Web Application. Now, Sun Microsystems introduces another interesting Web Development Environment, Zembly, a hosted environment designed to build Social Web Applications from the web itself. Nothing to download, every thing is on the web.


With Zembly, you can quickly and easily develop applications for Facebook, Meebo, OpenSocial, iPhone (to name a few) and other Social Web Applications. It makes it a snap to create embeddable widgets for  google, flickryahoo (again to name a few) gadgets,  that can be distributed to millions of users on the web.

Zembly Editors

Zembly allows you to author Social Web Applications and Widgets using advanced editors running directly in your browser. The editors provides support for code completion , full syntax highlighting for JavaScript, XML, CSS, HTML etc

Zembly Editors

Zembly is released as a private Beta and access is permitted for invitatees only. If you are interested to take it for a test drive, request  an invitation using the following widget.

Sunday May 25, 2008

VW tip: Automatically setting focus to next form element

Assume, you have three text field as shown below and user needs to type three number in each field.

        Phone Number : - -

After typing 3 numbers in the first field, to type in the next field, user first clicks on the second field to get the keyboard focus in that field and then types the numbers. However, it is possible to write a small JavaScript snippet to make the focus automatically jump to next field for the user. Known as form field AutoTab.

Using Netbeans Visual Web, first I created the following fields

  • Dropped the Woodstock Layout -> GridPanel and in the property sheet set the columns to 4.
  • Dropped Woodstock Basic -> Label and selected labelLevel -> Strong(1) in the property sheet.
  • Dropped three Woodstock Basic -> Text Fields and set
    • columns = 5
    • maxLength = 3

Next step is to create the necessary JavaScript. Added the following to the <head> section in the JSP.

   <script type="text/javascript">
function autotab(tabFrom, tabToId){
var length = tabFrom.value.length;
var maxLength = tabFrom.getAttribute("maxlength");
if (length == maxLength){
var tabTo = document.getElementById(tabToId);

The script takes two parameters.

  • tabFrom - The field from which the focus should jump from
  • tabTo - The "id" of the field to which the focus should jump to

Next step is to call this JavaScript from a suitable event in the TextField. To do this, selected the TextField in the designer and from the property sheet scrolled down to JavaScript event list and entered the following code to the "onKeyUp" event.

 autotab(this, 'form1:textField2_field')

In the above snippet, "this" refers to the field from which the focus should jump and "form1:textField2_field" is the id of the field to which the focus should jump to.

Note: The id of a JSF component specified in the JSP is not same as the id of the HTML dynamically generated in the browser. So it is important to use tools like firebug to find the correct id.

Deployed the application and typed three numbers. When I typed the third number, the focus automatically automatically jumped to the next field.

Saturday May 17, 2008

Visual Web FAQ revised for NB 6.1

The contents of the Netbeans Visual Web FAQ has been revised for the Netbeans 6.1 release.

This FAQ is not created by development team or doc team, but a collection from articles contributed by various developers and users from blogs, forum etc. Any interested contributer can add to this FAQ. Details at

The main topics covered in this FAQ are

  •  Visual Web Application general concepts
  •  Components
    •  General
    •  Input Components
    •  Output Components
    •  Action Components
    •  Layout Components
    •  AJAX Sample Components
    •  Table Components
    •  Selection Components
    •  Standard Components
    •  Converters and Validators
    •  Data Providers and Binding
    •  Processing and Lifecycle
    •  Portlets and Portal Servers
  •  Migrating From Previous Versions
  •  Database Access
  •  Working with Deployment Servers
  •  Troubleshooting
  •  Working with Java Source Code

Saturday Apr 26, 2008

VW user tip2: User Friendly Error Messages For Woodstock AutoValidation

One of the powerful features of  Woodstock TextField components bundled with Netbeans Visual Web is, client side auto validation. However, it is kind of tricky, if you want to change the default messages it displays. David Heffelfinger sent me this neat tip on how to achieve this.

For other user tips, visit Netbeans Visualweb user tips and code snippets

A while back I was experimenting with Woodstock. One of the things I liked about it was the "ajaxified" auto validation of text fields and text areas. Unfortunately when I tried it out I was disappointed that neither <h:message> nor <webuijsf:message> would "catch" validation errors when auto validation "kicked in". Reading about it I noticed that we can use an alert component to display validation errors, via the "notify" attribute.

Unfortunately by default both the "Header" and the "body" of the alert display the same message, not exactly user friendly.

After some research I found a solution, we need to override the "detail" and "summary" error messages via a resource bundle.

I blogged about this at

Saturday Apr 19, 2008

VW user tip1: A workaround for validation messages translation issues

This useful tip was sent to me by Jorge Campins. In this tip Jorge gives a solution to fix the problem related to intermixing of translated messages (Spanish, applies to other languages also) and English, which he jokingly calls as "Spanglish". Especially, this is a case with standard components and its Converters and Validators.

For other user tips, visit  Netbeans Visualweb user tips and code snippets

We wouldn’t know about other languages, but if you are developing with NetBeans 6 there are some translation issues you should solve before releasing your applications to Spanish speaking end-users. Here we specifically address those issues at JSF core components such as Converters and Validators. These issues include not translated, partially translated and wrongfully translated messages; also visual component ids appearing as part of the message, which is very helpful for the programmer but very confusing for the end-user. Fortunately, we were able to deal with all these in an easy way, based on the approach suggested by Dr. Winston Prakash. All we had to do was to build a translation routine and execute it at the prerender event. It was particularly easy for us because we already had all our pages calling some helper methods at prerender, so we didn’t had to modify every page to call the new translator routine. The following is an example of a translation routine based on the one we built:

public static void fixFacesMessages() {
FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot uivr = facesContext.getViewRoot();
Iterator messageClientIds = facesContext.getClientIdsWithMessages();
while (messageClientIds.hasNext()) {
String clientId =;
if (clientId != null) {
UIComponent uic = uivr == null ? null : uivr.findComponent(clientId);
Iterator messages = facesContext.getMessages(clientId);
while (messages.hasNext()) {
FacesMessage facesMessage =;
// Get the messages
String detail = facesMessage.getDetail();
String summary = facesMessage.getSummary();
// translate
String detalle = getMensaje(uic, detail);
String resumen = getMensaje(uic, summary);
// Set your own message

private static String getMensaje(UIComponent uic, String message) {
FacesContext facesContext = FacesContext.getCurrentInstance();
String mensaje = StringUtils.trimToEmpty(message);
if (uic != null) {
mensaje = trimPrefix(mensaje, uic.getClientId(facesContext));
mensaje = trimPrefix(mensaje, uic.getId());
mensaje = trimPrefix(mensaje, ": ");
mensaje = trimPrefix(mensaje, "Validation Error: ");
mensaje = trimPrefix(mensaje, "Error de Validación: ");
mensaje = trimSuffix(mensaje, "Example:");
mensaje = trimSuffix(mensaje, "Ejemplo:");
mensaje = mensaje.replace(
"is not a number",
"debe ser un número");
mensaje = mensaje.replace(
"must be a number consisting of one or more digits",
"debe ser un número");
mensaje = mensaje.replace(
"must be a number between",
"debe ser un número entre");
mensaje = mensaje.replace(
"Specified attribute is not between the expected values of",
"El valor debe estar comprendido entre");
mensaje = mensaje.replace(
" and ",
" y ");
\* We always use the maxLength property of the TextField component to avoid
\* length errors on string fields, so only TextArea components need a Length
\* validator. Therefore, only if the component is a TextArea we need to
\* change the subject of the sentence.
String sujeto = uic instanceof TextArea
? "La longitud del valor"
: "El valor";
mensaje = mensaje.replace(
"Valor es más grande de valor de máximo permitido:",
sujeto + " debe ser menor o igual que");
mensaje = mensaje.replace(
"Valor is menos de valor de mínimo permitido:",
sujeto + " debe ser mayor o igual que");
return mensaje;

public static String trimPrefix(String message, String prefix) {
String mensaje = StringUtils.trimToEmpty(message);
int i = mensaje.indexOf(prefix);
if (i >= 0) {
mensaje = mensaje.substring(i + prefix.length());
return mensaje;

public static String trimSuffix(String message, String suffix) {
String mensaje = StringUtils.trimToEmpty(message);
int i = mensaje.indexOf(suffix);
if (i > 0) {
mensaje = mensaje.substring(0, i);
return mensaje;

Sunday Apr 13, 2008

Netbeans Visualweb user tips and code snippets

I'm planning to post useful programming tidbits provided by Netbeans Visual Web users in my blog.  If you have any interesting tips, code snippets or ideas for enhancements and want to share them with others and get their comments, send me an e-mail at wjprakashATnetbeansDOTorg. I''l post them in my blog.

Friday Apr 11, 2008

Netbeans 6.1 release candidate 1 available for download announces the availability of Netbeans 6.1 release candidate 1, which can be downloaded from here.

Some of the highlights of this release, as listed here, are

  • JavaScript Support (Javscript debugger is not yet part of the product, but will available soon as auto-update module)
  • Performance Enhancements (Up to 40% faster startup and less memory consumption)
  • Support for Popular Web APIs
  • RESTful Web Service Support
  • Spring Framework Support
  • New MySQL Support in Database Explorer
  • Ruby/JRuby Support Enhancements
  • Java Beans Support (back by popular demand)
  • JSF CRUD Generator (back by popular demand)
  • Javadoc Code Completion
  • Sharing Projects (AKA Sharable Libraries)
  • New Update Center Modules for ClearCase, AXIS, Hibernate, and SOAP UI

The main highlights for VisualWeb are

  • Performance improvement (mainly memory consumption)
  • No more mandatory binding attribute
  • Latest Woodstock components (release 4.2 with performance improvement)

Friday Apr 04, 2008

Updated plugin - Visual Web Woodstock Component Theme Builder

I have updated Visual Web Woodstock Component Theme Builder to work with Netbeans  releases. The updated  plugins available are for

For details on how to install and use the  plugin read my previous blog

Creating Netbeans 6.0 Visual Web Components Custom Theme Using Theme Builder

As I mentioned in that blog, you can directly add the jar created using Theme Builder project to any Visual Web Application. Interestingly, if you change CSS or messages in the Theme Builder project, just build the project to create the jar and refresh the page in the Web application that uses that jar. The changes should be  reflected  immediately in that page.  

Note: I noticed that the project build might fail if there are spaces in the project path. Try to create the project with out spaces in the path.

Saturday Mar 08, 2008

How to fix the Netbeans 6.1 beta errors while opening Visual Web project

There are couple of complaints stating that Netbeans 6.0 Visual project could not be successfully imported in to Netbeans 6.1 beta release. It turned out that Netbeans 6.1 includes new release of Project Woodstock components and its Theme. While opening the Netbeans 6.0 project, it somehow remembers the settings from the old IDE and while deploying the project, following runtime error occurs.
WEBUITHEME001: No theme name or version specified and no default theme resource available

When Netbeans 6.0.1 project, is created, <project-dir>/nbproject/private/ contains the absolute path information about the Woodstock Components and its theme jars which points to the Netbeans 6.0.1 installation location.

When the project is opened using Netbeans 6.1 beta, the absolute path information in the should be adjusted to the new Netbeans 6.0.1 installation location. Some how this does not happens. An issue (#129316) has been filed against this bug.

One of the solution is to delete the <project-dir>/nbproject/private directory and allow it to be recreated when it the project is opened using Netbeans 6.1 beta. However, this does not seem to solve the problem. Building the project throws the following error.

$projdir\\nbproject\\build-impl.xml:501: Warning: Could not find file 
$projdir\\${libs.woodstock-components.classpath.libfile.7} to copy.

One of Visual Web engineers, Po-ting Wu, went through the scenario and found out the following work around.

  • Open the project, apply 'Clean' and close the IDE
  • Remove nbproject/private/
  • Remove all lines in nbproject/build-impl.xml that contain the following instances:
  • Start the IDE and open the project, apply 'Run'

For more details go to the Netbeans issue #129499

Monday Feb 18, 2008

Understanding Netbeans Visual JSF Web Application

Advanced users might have already figured out how Visual JSF Web Application works under the hood. I have written this article mainly for users new to Visual Web. It is important understand how Visual JSF applications works both at designtime and runtime to write well behaving and scalable application. Read more at

Understanding Netbeans Visual JSF Web Application

Sunday Jan 27, 2008

Creating your own Visual Web Page Layout Plugin

In two of my earlier blogs, I explained

Now I've written another article that provides step by step tutorial on how to create your own Page Layout plugin to make your own Page Layout appear in the New Visual Web Page Wizard. Read the complete article at


How to create your own Visual Web Page Layout Plugin


Monday Jan 14, 2008

No more mandatory component binding in Visual Web

Netbeans Visual Web Designer (NB 6.0 and before) mandates that each JSF component tag in the JSP must have a binding attribute which is bound to a property in the backing page bean via Expression Language binding. This ends up generation of getter and setters for each of the component in the page bean. Even though, this is convenient to set properties directly to the JSF component used in the page, this is very annoying because 95% of the components declared in the page Java source are not used and unnecessarily bloats the backing page bean.

For Netbeans 6.1 release this is going to change. Following changes have been implemented already and available in the Netbeans 6.1 nightly builds.

  • Newly created pages and page fragments will not have any binding attribute.
  • The generated Java source will not contain tons of getter and setters for corresponding properties.
  • The binding attribute in the JSP and corresponding property in the Java source will not be generated when a component is dropped on to the designer.
  • Users will have the option to add component binding using "Add binding attribute" context menu item of the component in the outline or designer.
  • Users will also have the option to remove component the binding using "Remove binding attribute" context menu item.

Here are some test results after the implementation

  • Create a project
  • In the page drop a table and copy and duplicate it to 20 tables
  • Copy the page and duplicate it to 128 pages.


  • Results With binding attribute for each component
    • Extremely slow to copy and create all the pages (more than 20 minutes)
    • Memory in the memory meter reached 512 MB and OME after copying about 95 pages
    • Copy all 128 pages after restarting IDE.
    • Final project size 10.2 MB
    • Restart IDE and Open project and 10 pages (switch to Java) - Memory 120/190 MB
  • Result With out binding  for each component
    • Reasonably faster to copy and create all the 128 pages (about 5-7 minutes)
    • Final Memory in the memory meter (after GC) 165/340 MB
    • Final project size 1.9 MB
    • Restart IDE and Open project and 10 pages (switch to Java) - Memory 75/140 MB

Sunday Jan 06, 2008

Creating a Flickr enabled Visual Web Application

As mentioned in it's web site, Flickr - almost certainly the best online photo management and sharing application in the world. It is becoming popular to mash up your own photos or other's public pictures from Flickr in to your own web application. Flickr exposes rich sets of open API via Web Services, which allows you to write your own program to fetch Flickr data such as photos, tags, groups and profiles.

I've written an article that explains how to fetch data from Flickr using a proxy client library and displaying the data in a Visual Web Application page. You can read about it at

Thursday Dec 20, 2007

Using the additional Woodstock Components not included in Netbeans 6.0

There are several useful Woodstock Components that are not bundled with Netbeans 6.0. These components were still under construction and not fully QA certified during the release of Netbeans 6.0, so they do not appear in the bundled components palette. However, they can be separately downloaded and added to the Palette as explained in this article - Updating Woodstock Component Library in NetBeans 6.

Once the additional components are installed , they appear in the palette as shown below and can be drag and dropped on to a visual web application.

Woodstock Additional Comps

You can preview the components via a Sample Application and view its source code to find out how to use these components in your application.

The most interesting components are

Accordian Comp

 Bubble Help

Popup Comp 

Other useful components are 


« July 2016