In a bit of situation and I am sure some (most) of you will sympathise. A senior developer at work decided to leave weeks before a release and I have been handed an almost complete interface written in JSF using Primefaces. I am relatively new to Java, around 6 months experience and even newer to JSF, around 4 weeks exposure. I come from a C++ background so I know programming, but with a deadline fast approaching I am having issues doing some very simple things. If anyone can give some advice or point me in the right direction it would be greatly appreciated.
Basically the tool I have is an Administrator interface that talks to a JAR that I wrote which in turn connects to SQL Server to perform administration on the database. Most of the development is done there is just a few usability issues I need to implement. What I mainly need to know is the following:
If I can get this error reporting working I will fix 90% of the problems I have as everything just fails silently at the moment.
Thanks in advance for any help
Joined: Jul 17, 2004
I can't guarantee to tell you best practices, because I haven't used JSF 2.0 in a real project yet.
About web development in general:
The most user friendly way to present errors in forms is an error message next to the field where the error occurs.
JSF is particularly well suited to make form validation simple. Actually, that's the one big gain when using JSF, while it makes other things much harder than they were with plain Servlets/JSP.
It's a trivial matter in JSF to ensure that a form isn't submitted with blank items in it. Just put the 'required="true"' attribute on the controls where mandatory input is required. You can use the 'h:messsages for=' element to display the message, and either use the generic built-in message, or supply a field-specific message.
"required=" works on most controls. SelectionOneMenuItem checks to make sure that the value of the selection isn't null/empty string. Boolean true/false checkboxes don't support it because there's an implied entry of a value (if you don't check it, it's false). Radio buttons can't be missing a required value as long as one of the buttons in the group was selected before the view was displayed. In generally, it does what most people would like it do do.
A bigger issue that most people have is when an item is only required when certain other elements on the form are populated. That's one of our more popular questions.
JSF is designed to avoid passing incomplete or corrupt data to the action processor (and from there to the backend), so it provides quite a bit of support for "up-front" validation and reporting validation failures.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: May 12, 2009
The best way of validating form input is to enclose the inputText statements in a panelGrid.
Allow one paneGrid per component to allow for components that render in more than one
column like a selectBooleanCheckbox.
Allow columns=3, for example outputLabel = 1 + inputText = 1 + h:message = 1
== 3. The h:message component would need to use for=id to connect to the component
in question. For messages that are not connected to a single component the h:messages
(note the plural) will display potentially multiple messages, but you need to manage the
space on the page.
Sorry if I've missed your moment in need, good luck,