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 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)

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


« February 2017