Re: JSF technology
gk wrote:
On Sep 18, 2:33 am, "Arved Sandstrom" <dces...@hotmail.com> wrote:
gk wrote:
On Sep 17, 4:54 pm, Lew <no...@lewscanon.com> wrote:
gk wrote:
Thanks. I did a look up on that and found the conversion . see the
example below. I think this is a data conversion.
It was "String age" in Backing bean but in Page view we are using
converter="javax.faces.Integer" to convert this data. So, This is
a data conversion I think.
<!-- PAGE VIEW -->
<h:message showSummary="true" for="age"/>
<h:inputText id="age"
value="#{user.age}"
converter="javax.faces.Integer" />
<!-- BACKING BEAN -->
public String getAge() {return this.age;}
public void setAge(String age){this.age = age;}
private String age;
Shouldn't the backing-bean methods be
public Integer getAge();
public void setAge( Integer age );
?
I checkd it . but the source has private String age;
I think probabily thats why we have converter="javax.faces.Integer"
in the JSF tag to convert String to Integer ....is not it ? what
say ?
That source is not doing you any favours. The backing (managed) bean
field/getter/setter data types should be what you want *after*
conversion, not before it. Otherwise the process would be somewhat
absurd, as everything would be a String and in what other publicly
accessible spot would you find the converted values?
I got confused now. Did you mean the example I posted is NOT a JSF
data conversion example ? OR you are trying to say its a CORRECT
example but NOT a GOOD one ?
By anyway , could you please post me an correct example for data
conversion ? Alternatively, Could you please post me a relevant link
which explains this stuff . so that I can look up the details what you
are referring at.
I have checked the sources and have come up with that example. But
from your comments , it seems to me I landed to a wrong place. Could
you please correct me what should be correct example ?
Regards.
There are lots of good resources. Simply going through some Google results
pages I could suggest the following:
http://facestutorials.icefaces.org/tutorial/converter-tutorial.html
http://www.ibm.com/developerworks/library/j-jsf3/ (somewhat dated but still
a good read)
and http://johnderinger.wordpress.com/2007/10/11/validators-and-converters/
looks OK.
Also read up on the lifecycle:
http://download.oracle.com/javaee/5/tutorial/doc/bnaqq.html
http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html
http://www.ibm.com/developerworks/library/j-jsf2/
I'd have to see the complete source that you've been using to judge it. As
it is, it's pointless to use an integer converter in your page yet the
corresponding managed bean property is a String. If it's an online source
I'd be interested in the link.
AHS
--
Before a man speaks it is always safe to assume that he is a fool.
After he speaks, it is seldom necessary to assume it. -- H.L. Mencken