You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Nikita Belov <NB...@abisoft.spb.ru> on 2006/03/01 11:46:38 UTC

FW: Value binding problems

Can anybody suggest where I have made mistake?

 

My application uses own PropertyResolver. It gets values for JSF components
from XML documents by XPath expressions, thus it can't predict actual data
type (String, Integer, Boolean) of the returned value and always return some
object with implemented toString() method. This mechanism worked perfectly
with Sun RI, but, when I switch to MyFaces, it has failed. For some reason,
MyFaces JSF components need values of the certain data type (for example,
Boolean for h:selectBooleanCheckbox). Why it doesn't try to convert value to
expected type as suggested in JSP 2.0 spec? Where I have mistaken?

 

______

 

With Best Regards,
Nikita Belov

 

  _____  

From: Nikita Belov [mailto:NBelov@abisoft.spb.ru] 
Sent: Monday, February 27, 2006 11:01 PM
To: 'users@myfaces.apache.org'
Subject: Value binding problems

 

Hello,

 

I have two problems with MyFaces 1.1.1.

 

1). I have created page:

. . . .

<h:selectBooleanCheckbox id="checkbox" value="#{Bean.prop}"/>

. . . .

It is uses managed bean:

public class Bean {

    public String getProp() {

        return "true";

    }

}

 

During page rendering, MyJSF throws exception:
"java.lang.IllegalArgumentException: Expected submitted value of type
Boolean". However, by specification (JSF 1.1 spec: Section 5.1.3 and JSP 2.0
spec: Section 2.8.5), string "true" must be converted to Boolean by
Boolean.valueOf() method.

 

2). Page:

. . . .

<h:selectOneMenu id="menu" value="#{Bean.prop}">

      <f:selectItem itemValue="1" itemLabel="1"/>

      <f:selectItem itemValue="2" itemLabel="2"/>

      <f:selectItem itemValue="3" itemLabel="3"/>

</h:selectOneMenu>

. . . .

This time following beans used:

public class Bean {

      public Prop getProp() {

            return new Prop();

      }

}

 

public class Prop {

      public String toString() {

            return "2";

      }

}

 

Page rendering fails with exception: "java.lang.IllegalArgumentException:
Value is no String and component form_id:menu does not have a Converter". By
specification (JSF 1.1 spec: Section 5.1.3 and JSP 2.0 spec: Section 2.8.2),
Prop object must be converted to String by Prop.toString() method.

 

With Sun JSF RI both these examples works properly. Is this MyJSF bugs or I
have made something wrong?

 

______

 

With Best Regards,
Nikita Belov