× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I haven't found the JSF keyword (if one exists) that will tell a field to
use an alternate style if the field is in error.

Here is an example of applying a custom class to a JSF field in error:

JSF view code:
<h:inputText id="name" size="45" value="#{CompanyCtl.curCompany.name}"
required="true" styleClass="input"/>
<h:message for="name" styleClass="error"/>
<h:commandButton value="SAVE" action="#{CompanyCtl.addCompany}"
styleClass="button"/>



JSF controller logic code:
public String addCompany() {
boolean errors = false;
if (Company.exists(new Integer(0), curCompany.getName())) {
UIHelper.addMessage("name", "The name specified has already been
used.");
errors = true;
}

if (errors)
return null;

try {
DBConn.sess().saveOrUpdate(curCompany);
} catch (HibernateException e) {
e.printStackTrace();
return null;
}
return "success";
}

As you can see I have a little bit of leaky abstraction with Hibernate
concerning my ORM layer not being ORM agnostic - oops :-)

The issue I had is that JSF will do the built in validations first and if
any of them fail it will exit the JSF lifecycle and send a response back to
the screenbefore it gets to your business logic edits. This was enough to
make me not use "the validation framework" unless the validations were
incredibly simple. These are the types of "bummers" that bite you in the
butt 3 months after you have made the decision to go with a framework and
are the same types of "bummers" I am watching out for in EGL. Not that I
won't choose EGL for some project eventually, it would just be great to not
learn the hard way.

Aaron Bartell
http://mowyourlawn.com

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.