Pesia,
Last month Daniel had a problem using generic type also. Andrew had some
thoughts on why this occurs, which you can read here [1] in the message
thread. Or use TinyURL[2] if [1] doesn't work.
[1]
http://www.nabble.com/Generics-in-%3Cfunction-signature%3E-for-custom-EL-function-tf2605810.html#a7279158
[2] http://tinyurl.com/ycf9or
Regards,
Jeff Bischoff
Kenneth L Kurz & Associates, Inc.
Pesia wrote:
Hi!
Have anyone tried to use JSF with generic type?
Here is the example:
class SessionBean{
private ValueWrapper<Integer> testIntegerWrapper = new
DBValueWrapper<Integer>();
private Integer testInteger2 = new Integer(7);
public SessionBean(){
this.testInteger.setValue(newInteger(6));
}
public ValueWrapper<Integer> getVal(){
return testIntegerWrapper;
}
public Integer getVal2()
{
return this.testInteger2;
}
public void setVal2(Integer iii)
{
this.testInteger2 = iii;
}
}
class ValueWrapper<T>{
private T value;
public void setValue(T value){
this.value = value;
}
public T getValue() {
return this.value;
}
}
in the jsp file (form):
<h:inputText value="#{sb.val.value}"/>
<h:inputText value="#{sb.val2}"/>
After submiting the form testInteger2 is converted correctly to Integer
but Integer inside value wrapper is set as String (no convertion done)
There is also no any error/exception, it looks like
ValueWrapper<Integer> has been replaced by ValueWrapper<String> !!!
I set a breakpoint in ValueWrapper.setValue on the line this.value = value;
and before execution of this line I have value type of Integer but after
value is type of String (I got "6" instead of 6)!
(actually I have array of ValueWrappers
created with different T types - but all of them are replaced with String
values
in Update Model phase).
Can anybody tell me what am I doing wrong here? Do ou have any ideas?
Or mayby my conception is totally wrong?