Archive for December, 2006
How to create a New Custom JSF Component that randomly displays select items in SelectOne… and SelectMany components
Dec 30th
Selection components, such as Radio Buttons. Dropdown-lists, Lists, Shuttles and Check Boxes, are key elements of many a web page. Java Server Faces has a pretty wide range of such selection widgets available, from selectOneRadio to selectManyCheckbox in the RI and a wide range of additional components in distributions such as ADF Faces and MyFaces. The options to choose from are specified through SelectItem and SelectItems elements. For example:
<h:selectOneRadio id="colorchooser" layout="pageDirection"> <f:selectItem itemLabel="Brown" itemValue="Brown"/> <f:selectItem itemLabel="Red" itemValue="Red"/> <f:selectItem itemLabel="Blue" itemValue="Blue"/> <f:selectItem itemLabel="Yellow" itemValue="Yellow"/> <f:selectItem itemLabel="Green" itemValue="Green"/> </h:selectOneRadio>
The options are presented to the user in the order in which they are defined in the SelectItem and SelectItems elements. In most situations that is perfectly alright or even very desirable. However, there are situations where we might prefer to apply a random ordering to the options in the selection component. For example in Polls we would either not want to influence the poll result through presenting options in a specific order to every interviewee. And in Exams/tests we might want to minimize the risk of candidates informing each other on the correct answers by presenting the answers in an ever changing sequence.
The challenge I will face in this article is the implementation of a new JSF Component that will reshuffle the order of the select items. All we need to do in order to make a Select Component display its options in a random sequence is apply this new component.
Read the rest of this entry »
ADF BC – Fun with Bind Parameters Part Four – Choosing between various Pre-Canned Queries by leveraging the View Link bind-parameter
Dec 29th
In this article on bind parameter usage in ADF Business Components, we will discuss a feature that I recently found out about and that I think offers a lot of potential. Unfortunately I do not think I quite grasp all the possibilities yet. However, since my understanding is enough to write a nice article, that is exactly what I will do.
The core of the realization I had is that the Bind Parameter(s) defined through a View Link can also be used in the where clause of the Target (details) View Object, as long as that View Object is always queried in the context of the Source (Master). Or, to put it more precisely, the values of bind parameters in a ViewObject can be provided in several ways, one of which is through a ViewLink.
In this article I will show a simple example of how is form of bind parameter value injection can be (ab)used. I am looking for more serious applications.
Read the rest of this entry »
Deploying Custom JSF Components – and using them in new JSF Applications
Dec 29th
In several previous posts – and some articles yet to be published – I discuss the development of new JSF Components. Of course the true potential of such components can only be realized if they can be packaged and distributed and integrated in an IDE and new JSF application in a very simple way. This articles demonstrates how two simple custom JSF components – a Validator and a UIComponent – can be packaged in a JAR file with supporting configuration files and subsequently be distributed to be used in other applications.
The jar-file is available for download at the end of this article. You can download it and create wonderful new applications with the two custom JSF components: helloworld and greaterThanValidator:
Implementing Client Side Validation for Custom Validators in ADF Faces
Dec 28th
The SUN Reference Implementation of Java Server Faces has a limited number of Validators. The framework has plenty support for creation and integration of custom validators. It does not however come with out of the box support for client side validation. Validation only occurs on the middle tier after a form has been submitted – either in full or partially through an AJAX style operation – from the client to the server.
ADF Faces has extended this approach by providing JavaScript based Client Side validation that occurs inside the browser when the Form is submitted, and therefore before the request is sent to the server. When validation fails, no request is sent at all and the user is notified of this failure to submit as a result of validation errors. Again, the set of out of the box validators in ADF Faces is fairly liimited, but we are free to extend that set with our own validators. It turns out to be quite easy to implement client side validation in our own custom validators as well, utilizing the infrastructure in ADF Faces.
In this article, I will demonstrate how my custom GreaterThan validator is client-side-enabled within the context of ADF Faces.
Read the rest of this entry »
How to create a custom JSF Validator – The Greater Than Validator to enforce one component’s value being larger than some other’s
Dec 28th
One of the major benefits of Java Server Faces (JSF) in comparison to other View frameworks is its easy extensibility. UI Components can be incorporated, custom converters and page-life-cycles can be defined and of course Validators can be developed an integrated into JSF applications. Although there is a number of tutorials and articles available on line on creating new custom Validators, they do not seem to discuss the creation of a validator that deals with more than one component(’s value). For example I would like to have a Validator that enforces that one component can only have a value that is larger than the value of some other specified component.
Basically I want to be able to specify something like:
<af:inputText label="Old Salary" id="oldSalary" value="#{SalaryBean.oldSalary}"/> <af:inputText label="New Salary" value="#{SalaryBean.newSalary}" id="newSalary"> <AMISJSF:greaterThan greaterThanId="mainform:oldSalary"/> </af:inputText>
And have the validator raise an exception if the value in New Salary is lower than the value in Old Salary:
Funny ESB?
Dec 27th
Hi all,
I’ve used my ESB system – installed on SuSE9, connected to a 10.2 E.E. on the same machine – for a few
months now, so I thought it would be interesting to take a look at what’s
going on in my database schema created by my esb system (oraesb). This
led to some questions and raising eyebrows, I hope some of you esb-experts out there might have an answer for or a comment for that matter .
Read the rest of this entry »
Using jQuery, the jQuery Form plugin and Stripes to create pretty Javascript and Java
Dec 26th
I recently discovered jQuery, it a blazingly
fast Javascript-framework and has a very compact notation. Now some
guy made a plugin to submit plain html forms with Ajax and jQuery.
Just add some Javascript that says you want to submit the form via
Ajax and you don’t have to touch the html of the form. What’s wrong
with touching the html of the form I hear you think. In most web
applications the forms are generated with tag libraries (Struts,
Spring, Stripes) or a templating library (like Velocity) and it can
get a bit difficult to add Javascript properties to your form. Today
I also discovered that you can return Java objects as Javascript with
Stripes.
Most of you probably never heard of
Stripes so I will give you a short introduction and then you’ll learn
to Ajajas (Asynchronous Javascript And Java And Stripes
)
The code examples can be downloaded here
Fun with ADF BC Bind Parameters – Part Three: Support for generic bind-parameters in ADF Business Components
Dec 26th
It can easily be the case that in your ADF BC application many ViewObjects make use of the same bind-parameters, for example a bind parameter referring to the current user. One simple way of providing the correct value for such bind-parameters could be implementing a little piece of pre-query-trigger-like logic: by extending the ViewObjectImpl class with our own implementation and overriding the executeQueryForCollection() method, we can intercept default query processing and set the value of any generic bind-parameters just prior to query execution, if they have not already been set.
Typical examples of generic bind-parameters are :currentUser and :locale, but you can think up any parameters you like, ranging from user preferences to security considerations. We could even go so far as to have our executeForQueryCollection method inspect all bind parameters, and try to get values for any parameter still without value from a central method on the ApplicationModuleImpl.
The implementation of this mechanism is fairly simple:
Read the rest of this entry »
ADF BC and Faces: Fun with Bind Parameters Part Two – Locale specific database querying from the ViewObjects
Dec 24th
In this article I would like to demonstrate another unexpected usage of ADF BC bind-parameters. In a previous entry I argued that bind parameters are typically seen as good only for the where-clause of an SQL query underlying a ViewObject. In that entry I showed using a bind parameter to select between very distinct order by clauses. Now we will take a look at using a bind parameter to select the meaning associated with domain values in the proper language, as defined through the UI locale. The article as an aside demonstrates how we can change the locale on the fly, by selecting the desired value from a set of radiobuttons. Note: that part of the discussion is based on one of the undocumented samples from Steve Muench.

ADF BC: Fun with Bind Parameters – Part One – Complex Order By clauses
Dec 23rd
Bind parameters (:paramName) are typically used in the Where clause of SQL queries underlying ADF BC ViewObjects. However, there is no rule that they can only occur in the where-clause. Any part of a query can be made a little dynamic through the use of bind-parameters. In this article an example of how we use a bind-parameters in an order by clause inside a ViewObject, and how we can leverage this bind-parameter from our (JHeadstart generated) ADF Faces user interface to choose from various wildy varying order by clauses.
In this article, I will demonstrate how we can order a list of employees (yes, table EMP again) by various Order By clauses, by selecting the appropriate option from the Dropdown list.


