I just ran across this when using the Builder pattern in some Pojos -- each setter returns the current instance of the pojo to allow for chaining set-statements:
Pojo pojo = pojo.setName("name").setValue(23);
With setters implemented like so:
public Project setName(final String name)
{
this.name = name;
return this;
}
But JSF complains:
javax.servlet.ServletException: javax.el.PropertyNotFoundException: /faces/page.xhtml @36,20 value="#{pageBean.pojo.name}": Property 'name' not writable on type java.lang.String
It seems to me that this is a slightly harsh restriction. Is there anything we can/should do about this? Does anyone else feel it's worth mentioning?
The obvious answer is to use dumb getter/setter methods, but in some cases that can be restrictive, and I like the idea of being more forgiving.
Thoughts?
--Lincoln