Tim Holloway wrote:The decorator class is usually something you write, since the point of it is to add features that you need that the underlying object doesn't have. In the case of datatables, you can do things like create a list of decorators and fill it by enumerating the underlying object collection, constructing a decorator object for each underlying object, and inserting the decorator into the decorator list, which is then wrapped by a ListDataModel.
Which is a lot less fun than simply wrapping the underlying collection, since you can do that in a single line of code. But sometimes the extra work is worth the price.
Tim Holloway wrote:
Don't feel bad about the design patterns. Actually codifying and naming these critters was a relatively recent event, although some of these techniques I've been using for years. The iterator pattern got to be blatantly obvious when I moved to C++. Seemed like almost everything I did for a while had an iterator in it.
Tim Holloway wrote:"Uncatholic" is a perfectly good word, but probably not the best one to use here, since "catholic" is more in the lines of "universal". "un-kosher", if you will.
A Decorator is one of the Gang of Four (GoF) Design Patterns, and it's basically a proxy or wrapper for an object that "decorates" that object with additional properties. In this particular case, adding the "isDriver()" read-only property method to the setter/getter methods that it repeats from the object being decorated. From the sound of it, however, you have enough control over the base object that in your case you can just add isDriver to the original class and not need a separate decorator.
However, if you want to talk "un-kosher", if not dowright haram (going muslim just to complete the roster), Using FacesContext.getSession.getBean is not the way to go. If you need to access one JSF managed bean from another managed bean, use property injection (Inversion of Control).
As a general rule, the less JSF-specific code that's in a bean, the better.
Tim Holloway wrote:
Urk. I'll stack my technical expertise against anyone's. But don't ever depend on me to have a proper sense of time.![]()
Tim Holloway wrote:
I think you're making the common, but incorrect assumption that a datatable has to be bound to the domain data. A JSF datatable is a Model object, and its primary purpose isn't domain data, it's to server as the Model part of MVC. And, just like the Model objects in, say, Swing, the JSF model objects are go-betweens with personalities of their own, not just placeholders.
Tim Holloway wrote:
BTW, you don't "call" a routeBean.isDriver on your JSF view. You reference the routeBean's driver property. That's an important distinction to make since A), "routeBean.isDriver" won't work as a value attribute, and B), value objects are lvalues. Meaning that not only is "isDriver invoked, but setDriver, as well. All the calling (or invoking, in OO terminology) is done by the framework. The JSF tags are specifications, not code.
Tim Holloway wrote:
Yup. Not everyone who's "Over the Hill" is "Behind the Times" :)
Tim Holloway wrote:
What you are doing wrong is mixing JSTL with JSF. I won't say you should never do that, but I haven't found a good reason to use JSTL on a JSF page ever and I've been working with JSF since about 1985.
Tim Holloway wrote:
There's nothing a <c:out> can do that an <h:outputText> can't do.
To display an element conditionally, use the JSF tag's "rendered" attribute. You don't need to wrap the tag with conditional logic. You can select between 2 alternatives images using a "bean.x" property by using the 'rendered="#{bean.x}"' attribute on the first image and 'rendered="#{! bean.x}"' on the second. If you have more than 2 alternatives, I'll leave that as an exercise for you.
driverEmail1: testEmail
Login: testEmail, Driver:
<image passenger.png>
Ulf Dittmer wrote:Which JRE version and which JSF version are you using? JSF 1.2 requires at least Java 5 (since it's part of JEE 5), while JSF 2.0 requires Java 6 (since it's part of JEE 6).
Is there a class file version number given in the error message? Should be a number around 50.
benjamin muktesh wrote:Go to tomcat/bin and modify the JAVA_HOME parmater in catalina.sh (for linux/unix) or catalina.bat (for windows)