free web page hit counter
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 http://www.jroller.com/heffel/entry/user_friendly_error_messages_for


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 = messageClientIds.next();
if (clientId != null) {
UIComponent uic = uivr == null ? null : uivr.findComponent(clientId);
Iterator messages = facesContext.getMessages(clientId);
while (messages.hasNext()) {
FacesMessage facesMessage = messages.next();
// 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
facesMessage.setDetail(detalle);
facesMessage.setSummary(resumen);
}
}
}
}

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

Netbeans.org 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/private.properties 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 private.properties 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/private.properties.
  • Remove all lines in nbproject/build-impl.xml that contain the following instances:
    ${libs.woodstock-components.classpath.libfile.6} 
    ${libs.woodstock-components.classpath.libfile.7}
  • Start the IDE and open the project, apply 'Run'

For more details go to the Netbeans issue #129499

Tuesday Feb 19, 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

  • 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

http://winstonprakash.com/articles/netbeans/flickr_enabled_webapp.html

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 


Monday Dec 03, 2007

Netbeans 6.0 has been released. Download it now!

Today, it is a major milestone for Netbeans.  It announced the release of much anticipated 6.0 Version of the IDE and it is available for download now.

In this release several of  the addons  packs are consolidated in to a single IDE such as Visual Web Pack, Ruby and Rails, Enterprise Pack, C++ pack etc.

Highlights

Easy-To-Use Java GUI Builder

Create professional-looking Java GUIs by placing and aligning components on a canvas.

 

Visual Web and Java EE Development

Build standards-based web applications visually using Ajax, CSS, and JSF. Full set of tools for EJB development.

Visual Mobile Development

Create, test and debug GUI applications that run on mobile phones, set-top boxes, and PDAs.

Visual UML Modeling

Separate software design from implementation with UML Modeling.

Ruby and Rails Support

Powerful Ruby editor (with code completion), debugger, and full support for Rails. Includes the JRuby runtime.

C and C++ Development

Full-featured C/C++ editor, debugger, project templates, and support for multiple project configurations

Saturday Dec 01, 2007

Acrylic on Canvas - Old Barn View

Another one of my Acrylic paintings.

Old Barn View

Wednesday Nov 21, 2007

Netbeans 6.0 Release Candidate 2 available now

Netbeans.org announces the availability of Netbeans 6.0 Release candidate 2. It can be downloaded from

http://download.netbeans.org/netbeans/6.0/rc2/

Don't forget to read the Release Notes

Thursday Nov 08, 2007

How to Create a CSS based Page Layout - Part 1

Earlier, I posted a module that allows you create a Page Layout for your Visual Web pages from few pre-defined Page Layouts. However, you may be interested in developing your own Page Layouts.

There are two ways to create Page Layouts

  • Using nested tables to arrange children.
  • CSS based positioning.

I have put together an article that explains how to create a CSS based fixed width page layout.

Creating a CSS based Fixed Page Layout - Part1

Related articles

How to create Netbeans Visual Web Page Layout Plugin

NB 6.0 plugin for Predefined Visual Web Page Layouts