-
1. Re: Newbie, how declaring read only variables?
nbelaevski Dec 13, 2009 7:52 PM (in response to jonnyrico)Hi Jonny,
You don't have to configure this. Don't implement setter for read-only fields and that's all
-
2. Re: Newbie, how declaring read only variables?
jonnyrico Dec 14, 2009 11:06 AM (in response to nbelaevski)Hi,
thank for reply. That was my first intention but if I don't declare a method setPro(), I'll get an error-message(NullPointer-Exception) when I open the page.
Do you mean I have to declare a method setPro() without any content? Just
public void setPro(Integer pro) {}
Thanks a lot.
Jonny
-
3. Re: Newbie, how declaring read only variables?
ebross Dec 14, 2009 12:07 PM (in response to jonnyrico)Alternatively, you could use 'private' instead of 'public':
private void
setPro(Integer pro)
{
this.pro = pro;
}
This will prevents a write outside the 'Bean', and with a “public String getPro()” method, you will have your 'read only'.
But one more important thing: Is your component a ui input? For example, is it “h:inputText”? If so, since you only want 'read only', replace it with “h:outputText”. If you use a ui input, jsf will assume that you have a setter method, hence the NPE.
-
4. Re: Newbie, how declaring read only variables?
jonnyrico Dec 14, 2009 12:10 PM (in response to ebross)Hi,
the component I want to use is a progressbar and I would like to set the value-attribute through the Bean-property.
-
5. Re: Newbie, how declaring read only variables?
ebross Dec 14, 2009 12:49 PM (in response to jonnyrico)Then you want:
<rich:progressBar value="#{yourBean.pro}" ...
HtmlProgressBar is a ui command like HtmlCommandButton and HtmlAjaxCommandButton, so you don't need a setter method for it, Your getPro() signature will do. And to set “rich:progressBar” value, do some processing and then return a value in getPro to set the rich:progressBar value.
Here is a 'must see':
http://community.jboss.org/wiki/SimplePingApplicationwithrichprogressBar
-
6. Re: Newbie, how declaring read only variables?
jonnyrico Dec 14, 2009 12:52 PM (in response to jonnyrico)okay thank you. I'll try.
Thanks a lot.
Jonny