Pencils Down

This weblog is about my experiences in software development

Browsing Posts tagged IceFaces

As you may already know icefaces since it’s wrapping faces wrapping jsp wrapping html there is some loss of information, especially when things don’t go well.

In my case I was chasing down why a button click would sometimes work and other times do nothing at all.

After looking at various logging spam you can generate, I started looking into debugging tools in faces.  Desperation sometimes works!  Turns out there is a tag, h:messages, in faces that allows you to dump whatever faces exceptions are currently in the queue.  You just plunk the tag in the same div as the suspected culprit and voila, you get a nice message dump right next to the component.  For example,

<ice:panelGroup styleClass="x">
<ice:commandButton id="okButton" type="submit" value="OK"
actionListener="#{z.popupOkButtonAction}" />
<h:messages layout="table" showDetail="true" />

BTW, in my case I got a list of class cast exception errors.  I had the getter/setter of the selected value of a selectOneItem typed as a SelectItem instead of a String.  Once I saw the errors the fixes were very clear.

I have a screen with a series of vitiman d 3 and of commandButton’s. They all should call various action methods back in the vit d side effects and the controller. Some of function of vitamin d and of the why is vitamin d needed and the command buttons used images – they worked. Others just had values for the vitamin d deficiency symptom and the buttons – they did not work.

Adding onclick showed the too much vitamin d symptoms and the buttons were working, they just were not calling the calcified veins and the actions.

Several misguided google’d references mentioned changing the what is the source of vitamin d and the behavior of what does vitamin d3 do for your body and of the vitamin d3 deficiency symptoms and the ui callback setting in web.xml. I tried that and it made no difference.

Finally I noticed that I was missing the vitamin d studies and the id attribute on the symptoms excess vitamin d and the buttons. Adding different id’s for each of vitamin d deficienct and of the vitamin d toxic levels and the buttons fixed the vitamin d toxicity symptoms in adults and the problem – the low on vitamin d and the buttons now invoke the vitimum d and the methods as expected.

I had thought that icefaces added default id’s where necessary, but there may be a glitch when you have an assortment of symptoms of vitamin d toxicity and of fields of the vitamin d supplementation and the same type.

If you want to have a button to download a file in icefaces you create a button like:

<ice:outputResource id=”printButton”
    attachment=”true” label=”Print…” type=”button”
    fileName=”report.pdf” mimeType=”application/pdf” />

and have the backing bean look like:

public Resource getPrint() {
    //assume we have created the PDF and read into a byte stream oStream
    return new ByteArrayResource(oStream.toByteArray());

The side-effect is that the backing bean is evaluated constantly which means you keep building the PDF file.

The other problem is if you don’t have anything to download, what do you do.  It turns out to be pretty simple: just return a null.  In that case the button will not even be displayed on the screen!

    if (data.size()==0) return null;

This lovely, intuitive message from icefaces means you are doing something interesting on the page in question.  In our case it was a simple redirect to another page based on state.

The solution is to use the push server from icefaces 1.8.  The servlet changes the mechanism used for communicating with the backend and indirectly fixes the above ‘error’.

The column referenced in the jspx file,

<f:facet name="header">
arrow="true" >
<ice:outputLabel value="D-E-F" />

must much the column name in the backing bean,

xtable = new CheckBoxTable();
xtable.setColumnNames(new String[] { "ABC", "DEF"});

You must specify a column width for this to work:

... style="width:20px; text-align:center"...

IceFaces Rocks!

No comments

IceFaces is a Java AJAX framework ().  Open-source.  Through it’s live connectivity to the DOM on the client ALL interactions are performed in sequence to a back-end supporting beans.

IceFaces has all the built-ins you would expect to be able to build a RIA app.  The best part is it works and even better: the tutorials on the site work!  There are so many open source frameworks out there with very little documentation.  More typically the site supporting your open source framework has limited, theoretical documentation – think of Hibernate or Spring – both excellent frameworks, but very sparse documentation on how to do regular, everyday things.  So, you end up poking around on the network and typically find several leads that are just wrong.

Such a pleasure to use a tool that you don’t have to waste time on redeveloping the wheel every day.