Friday, June 22, 2007

What's (on) your menu ?

Imagine a restaurant which serves great food, preferably your own favorite restaurant. Now imagine that this same restaurant, has your own personalized menu. Wouldn't that be great. You could just go there and eat whatever you feel like at that moment.

The same goes for the application you build. If you use ADF-Faces and a panelpage with menu facets to show the menu in your application, the framework tells you how your menu works, and almost what it looks like.

So this is what my menu looked like.

The ADF-faces menu has a couple of annoying features. First of all the size of the Menubar. If you have about 10 menu items (or less but with very long labels) the end users have to scroll to the right to see all items. You would easily miss the menu items on the far right. End users just love the pulldown menu's that they are used to. They use it in OracleForms, they use it in TwoLetterWord Office, and so on.

Secondly, the faces-config, in which the menu is configured will load only once.
Immagine what could happen if your menu is being constructed from a database table with roles and permissions per user: "An admistator revokes permission from a given users, and tells him to log off the system to activate this new privilige". Say what ?!. I'll explain this in a later post, and I will describe how to implement database driven menu security.

Here is how the pulldown menu can be implemented.

Copy lib's to be able to use myfaces menu.

Create the namespace, xmlns:t=""
Create an extension filter in the web.xml

And this is my new menu.

So what about the "own personalized menu" that I mentioned in the beginning of this post ? I even found a way to fix that. Not rocketscience though; just use a switcher in the menu facets and add a "Customizer" to your application. Your menu and your look and feel wil change "on the fly". The customizer contains SelectOneChoice listboxes to set the values of skin and menutype:

<af:selectOneChoice label="Select Menu type"

And in the page you use the switcher to display either of the menutypes.

<f:facet name="menu2">
<af:switcher facetName="#{sessionScope.menuType}"
<f:facet name="ADF-Faces">
<af:region id="menu2"
<f:facet name="My-Faces">
<af:region id="menu7"

After that it works just great. Below you see the 'deault' ADF look and feel.

And when you set your "own" customizations, here's what you get:

I really had fun creating this, and after showing this to some of my coworkers, even they liked it ;-)

Monday, June 11, 2007

Sliding into view

A couple of days ago some one asked me if it was possible to bind inline style properties to a backing bean using Expression Language. I knew this was possible so I explained him how to do that. This also was a nice opportunity to try out how an af:inputNumberSlider works. I wanted to use the value of the slider to set the fontsize in the rest of my example application.

It worked ! Here's how I did it.
First you have to drop the af:inputNumberSlider on your page. You also have to drop an af:outputText on your page. This textfield will contain the displayed text. If you want the page to use the value of the slider immediately, you have to set the autosubmit property of the slider to true. After that, give the slider an id and use this id in the partial triggers property of the inputtext.

Finally you have to bind the slider and the outputtext to a backingbean. In this bean you will read the slidervalue and use it to set the size of the text in the outputtext.

The source of the bean looks like this

public class UseSliderValues
private Integer sliderValue = 100;
private Integer sliderStartValue =100;

String text = "initial text";
String fontsize = "font-size:0%;";

public UseSliderValues() { }

public void setSliderStartValue(Integer sliderStartValue) {
this.sliderStartValue = sliderStartValue; }

public Integer getSliderStartValue() { return sliderStartValue; }

public Integer getSliderValue() { return sliderValue; }

public void valueChanged(ValueChangeEvent valueChangeEvent) {
this.sliderValue = (Integer)valueChangeEvent.getNewValue(); }

public String getFontsize() {
return fontsize; }

public String getText() {
if (sliderValue!=0) {
text="Your eyesight is "+sliderValue+ "%; you're able to read this"; }
else {
text="Are you sure ? With "+ sliderValue+"% eyesight you shouldn't be able to read anything except braille !!"; }
return text; }}

The source of the page will look something like this:

af:inputNumberSlider id="slider"
label="How good is your eyesight (0-100%) ?"
minimum="0" maximum="100"

af:outputText value="#{RichComponents_backingbean.text}"

Run the application and try some slider values (0% eyesight...........)

So now you have two solutions in one post: How to use a inputnumberslider and how to set the inlinestyle property through EL. I had fun doing this.

Monday, June 04, 2007

Whats new ?

Recently this blog was mentioned on '' and on Steve Muench's weblog . Thanks Steve ! I guess my weblog is getting more popular by the week ("I Love Google Analytics").

So I want to put some really new stuff here. I also want to post at least once every week..... Here's my challenge !

I want to write on templating, LOV's and other new features, but that takes time. And I'm not just doing stuff for my blog. I'm also working ;-)

But I'll see what I can do. First I'll try to isolate some solutions we had to implement in the prvious project. And if there's more time ......