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
Posted at 09:39AM Apr 26, 2008 | Permanent link to this entry | Comments [4]
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;
}
Posted at 08:07AM Apr 19, 2008 | Permanent link to this entry | Comments [2]
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.
Posted at 07:55PM Apr 13, 2008 | Permanent link to this entry | Comments [2]
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
The main highlights for VisualWeb are
Posted at 12:19PM Apr 11, 2008 | Permanent link to this entry | Comments [0]
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.
Posted at 05:00PM Apr 04, 2008 | Permanent link to this entry | Comments [20]
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.
${libs.woodstock-components.classpath.libfile.6}
${libs.woodstock-components.classpath.libfile.7}
For more details go to the Netbeans issue #129499
Posted at 09:35AM Mar 08, 2008 | Permanent link to this entry | Comments [12]
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
Posted at 06:47AM Feb 19, 2008 | Permanent link to this entry | Comments [4]
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
Posted at 02:03PM Jan 27, 2008 | Permanent link to this entry | Comments [9]
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.
Here are some test results after the implementation
Posted at 09:50PM Jan 14, 2008 | Permanent link to this entry | Comments [11]
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
Posted at 08:03PM Jan 06, 2008 | Permanent link to this entry | Comments [4]
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.
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


Other useful components are
Posted at 11:25AM Dec 20, 2007 | Permanent link to this entry | Comments [19]
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.
|
Create professional-looking Java GUIs by placing and aligning components on a canvas.
|
Build standards-based web applications visually using Ajax, CSS, and JSF. Full set of tools for EJB development. |
|
Create, test and debug GUI applications that run on mobile phones, set-top boxes, and PDAs. |
Separate software design from implementation with UML Modeling. |
|
Powerful Ruby editor (with code completion), debugger, and full support for Rails. Includes the JRuby runtime. |
Full-featured C/C++ editor, debugger, project templates, and support for multiple project configurations |
Posted at 09:14AM Dec 03, 2007 | Permanent link to this entry | Comments [24]
Acrylic on Canvas - Old Barn View
Another one of my Acrylic paintings.

Posted at 05:43PM Dec 01, 2007 | Permanent link to this entry | Comments [4]
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.
Posted at 10:45AM Nov 21, 2007 | Permanent link to this entry | Comments [9]
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
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
Posted at 08:09PM Nov 08, 2007 | Permanent link to this entry | Comments [9]