If you have an abstract class with generic types and try to set that attribute with f:viewParam, always get String type if running with Java 11. If you run the same code with Java 8, it works as expected. Ex:
/** CrudBean.java */
...
public abstract class CrudBean<K, E extends DomainEntity<K>> {
private K id;
private E e;
...
public K getId() {
return id;
}
public void setId(K id) {
this.id = id;
}
...
/** ZoneBean.java */
...
@Named
@ViewScoped
public class ZoneBean extends CrudBean<Integer, Zone> implements Serializable {
...
When you run this code in Java 8, the id attribute set the value as Integer. In Java 10&11, the id attribute set the value as String and JSF throws the following error:
javax.servlet.ServletException: Provided id of the wrong type for class Zone. Expected: class java.lang.Integer, got class java.lang.String
@maxcav7 Commented
The workaround for this problem is to set the converter in the f:viewParam. Ex:
<f:viewParam name="id" value="#{zoneBean.id}" converter="javax.faces.Integer"/>
If you have an abstract class with generic types and try to set that attribute with f:viewParam, always get String type if running with Java 11. If you run the same code with Java 8, it works as expected. Ex:
zone.xhtml
When you run this code in Java 8, the
id
attribute set the value as Integer. In Java 10&11, theid
attribute set the value as String and JSF throws the following error:javax.servlet.ServletException: Provided id of the wrong type for class Zone. Expected: class java.lang.Integer, got class java.lang.String
Technologies used: