Tuesday, August 26, 2008

Some ICEFaces tags

First at all, why i've chosen an ICEFaces? There are some reasons and here they are:
1. It supports Ajax
2. It looks very cool
3. It works well
4. Integrated with Eclipse
5. It is possible to combine another frameworks like Spring, Struts and even more.

The first control i would rather speak about is ice:selectonelistbox
The control looks like this:

The corresponding listbox tag looks like this:
ice:selectOneListbox id="SlctFileListBoxID" title="files" size="5"
value="#{buttonclick.fileSelected}" partialSubmit="true"
style="width:100%;overflow: auto;"
f:selectItems id="SlctFilesItms"
value="#{buttonclick.filesListItems}" />
I missed "<" sign because it's not correctly showing on the blog page How does it render on the html page?
<select class="iceSelOneLb" 
="iceSubmitPartial(form, this, event);"
="width:100%;overflow: auto;"
<option value="allclasses-frame.html">allclasses-frame.htmloption>

What we need in backing bean...
String fileSelected = "";
protected SelectItem[] FILES_ITEMS;

public SelectItem[] getFilesListItems() {
try {
FILES_ITEMS = new SelectItem[getFiles().length];
for (int i = 0; i < getFiles().length; i++) {
FILES_ITEMS[i] = new SelectItem(getFiles()[i]);
} catch (Exception e) {

public void fileChanged(ValueChangeEvent event) {
if(event.getNewValue()!= null){
fileSelected = (String) event.getNewValue();
System.out.println("Clicked value: " + event.getNewValue());
public String getFileSelected() {
return fileSelected;

public void setFileSelected(String fileSelected) {
this.fileSelected = fileSelected;

That's it indeed.
But isn't actually. Something is incomplete...
And now time for theory.
The values—allclasses-frame.html ,Driver.html and so on.—are transmitted as request parameter values when a selection is made from the menu and the menu’s form is subsequently
submitted. Those values are also used as labels for the menu items. Sometimes you want to specify different values for request parameter values and item labels, so f:selectItems also has an itemLabel attribute:
f:selectItems itemValue="2008" itemLabel="Have a good day"/>

A single f:selectItems tag is usually better than multiple f:selectItem tags. If the number of items changes, you ought to adapt only Java code whether you use f:selectItems, whereas f:selectItem may entail to change both Java code and JSF pages.

That's all.

No comments: