javax.faces.FacesException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.component.UIComponent

后端 未结 1 717
傲寒
傲寒 2021-01-19 18:19

My Java EE web application is working fine with Glassfish 2.1. Now I want to migrate to Glassfish 3.1.1

I have followed the modifications provided h

相关标签:
1条回答
  • 2021-01-19 18:44

    java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.component.UIComponent at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations

    This particular exception will occur when you have a String value property like

    private String value;
    

    and are binding it to a component using the binding attribute:

    <h:inputText binding="#{bean.value}" />
    

    This is incorrect. The value should be bound using the value attribute:

    <h:inputText value="#{bean.value}" />
    

    The binding is only to be used to bind the whole component (which is an instance of UIComponent) to the backing bean, for example to programmaticlly modify it.

    Verify your login.xhtml code. If necessary cut out as much as possible code as long as you can still reproduce the problem so that you can end up with the smallest possible code snippet which reproduces exactly this problem which should allow you to find the culprit easier.

    See also:

    • How does the 'binding' attribute work in JSF? When and how should it be used?
    0 讨论(0)
提交回复
热议问题