JSF, Float, and f:convertNumber February 16, 2010Posted by Phill in Frameworks, Presentation Layer.
Tags: convert, convertNumber, float, jsf
I’ve been having some fun issues with JSF and converting Float issues. Essentially the problem occured when converting a primitive float type to a java.lang.Float type in my value object (I was trying to updating a float value from an inputText field). I kept getting errors like:
java.lang.IllegalArgumentException: argument type mismatch
Anyway, I found an answer which seems to work, but rather than post it directly here I’ll simply link to the original question on StackOverflow (in case someone posts a better answer subsequently!).
These kind of issues are one of the many reasons why JSF has gone down in my estimation… it’s not a bad framework, it just seems to make what should be simple things massively complicated! That said, JSF 2.0 looks good, so maybe it will solve these kind of issues.
Wicket September 17, 2009Posted by Phill in Frameworks, General J2EE, Presentation Layer.
Tags: jsf, wicket
The past few days I’ve been prototyping for a new project we’re starting up at work. Previous web projects we’ve done have mainly been using JSF, however for this project I’ve been looking into Apache Wicket.
My first impressions are, I like it. I like it a lot, in fact. It seems to achieve a much more clean separation between code / components and HTML than other frameworks do. It does take a while to get your head around it though – I’ve only been working with it for a few days so am still finding my way round!
But I expect I will blog up some info when I’ve got my head around it.
Another JSF Gotcha July 9, 2008Posted by Phill in General J2EE.
Tags: arrays, gotcha, jsf, setmanylistbox, value binding
JSF has a number of “gotchas”. Today I managed to stumble across another one. Again.
Suppose you’re designing a user administration panel, and you want to be able to edit a user and select a list of roles for them. You’d think a fairly logical control to use would be a selectManyListbox (assuming, for the moment, it’s a fairly small number of roles).
So, in your backing bean you add in a List containing all the user roles, and you configure your SelectItems and converters. Except you still keep getting that damn error message: “Validation Error: Value is not valid”.
It turns out the problem is that JSF is so advanced, it can’t yet handle the Java Collections Framework: you have to use arrays instead. That’s right, in your backing bean, if you use List<MyClass> as the value binding for the list box, it will not work. You need to use MyClass instead.
I am using an older version of JSF (1.1 as opposed to 1.2) so that might be fixed now – still rather annoying to come across it though.
JSF Issues May 14, 2008Posted by Phill in Frameworks.
Tags: icefaces, jsf, problems
The project I’m currently working on is using JSF and IceFaces. It’s been a while since I used JSF, and I’d forgotten just how annoying it can be at times. The problem is always using frameworks that write the HTML for you: if you don’t have so much control over what is actually output to the browser, if you have a problem (which you inevitably will) fixing it will not be a simple matter.
I think this might be a problem with the way IceFaces loads things up using AJAX, but either way i’m none too impressed. The solution for the time being is to actually use a <redirect/> tag in my faces-config.xml (as suggested on this thread), this isn’t an ideal solution but it seems to work for the moment.
Although JSF does make some development quicker, the amount of time you lose to stupid problems like this probably negates any gains you made originally.
For the next web based project I do, I think I will try something like Spring WebFlow or Wicket, which both look like very interesting frameworks and don’t suffer from the same issues as JSF (although undoubtedly they have their own issues!)
JSF Backing Beans and Spring May 2, 2008Posted by Phill in General J2EE.
Tags: backing beans, jsf, Spring
In the Spring Documentation about JSF integration, the DelegatingVariableResolver (and a few alternatives) are explained. There is one thing it doesn’t mention explicitly, though, which is using Spring managed beans as backing beans.
As it happens, it’s fairly easy: you just need to use beans with request or session scope. There is a little bit of configuration needed for this, but you get the great benefits of having all your bean definitions in one place, as well as all the benefits of Spring managed beans and configuration!
Provided that you have the DelegatingVariableResolver (or one of the equivalents) set up, you can then use
your Spring managed beans in exactly the same way as you would use JSF managed beans.
JSF and IceFaces April 4, 2008Posted by Phill in Frameworks.
Tags: ajax, icefaces, jsf
I mentioned a couple of posts ago that I was trying out Google Web Toolkit. Well, I’ve come to the conclusion that Google Web Toolkit is not the right solution for this particular project.
The problem was mainly one of scope: I think GWT, due to the way it’s designed, is more for small-to-medium size projects at the moment. The project which I am currently working on is small at the moment, but we will need to integrate various other things with it in the future and it will grow.
I did look at Echo2 as well (thanks to Dalibor for pointing it out to me), and that does look good – more like it would be able to handle larger applications, due to the way the page is loaded – but I don’t think it’s exactly what we need at the moment either.
What we have done is use JSF with IceFaces. IceFaces is a “Web 2.0” framework for JSF, i.e. it provides a set of JSF components which are AJAX-enabled. It was a bit of a struggle to get working with Tomcat 6.0, but I got there in the end!
Anyway, I’ve been using it for a couple of days now and I really like it. The AJAX is handled completely transparently to you – you just design your JSF application as you would do normally, and IceFaces will handle the AJAX. As an example, it’s really this simple to add an AJAX based table to your JSF page:
1. Use an IceFaces “dataTable” component
2. Have an IceFaces commandButton call the backing bean to populate the table with data (for example, search results)
3. The data table is updated automatically without needing a page refresh
Ok, I admit it, items 4 and 5 are not part of it. But still, I think it’s pretty good going.
There is a bit of configuration to do before you start, but then that’s the same with pretty much any framework I know!
What I’m trying to do at the moment is set up a “Loading” message, i.e. when you click on a button which will execute a long operation (for example, doing a text comparison on a lot of database fields) a loading message will be shown. By default no message is shown, and I can’t find a way of automatically displaying one for every call (ala DWR).