Implicit expression language object “component” not working in jsf 2.2.6

可紊 提交于 2019-12-11 22:22:12

问题


I'm migrating a jsf 2.0 application to jsf 2.2.6. There is a extensive use of implicit EL object component as styleClass="#{component.valid?'':'err'}".

In jsf 2.2.6 (jsf-impl-2.2.6-jbossorg-4.jar) valid is not recognized, throwing "ServletException: The class 'javax.faces.component.html.xxx' does not have the property 'valid".

Is this functionality deprecated in jsf 2.x.x?

Can be related to JBoss EL?


回答1:


It seems that you trying the component.valid on element that does not support it at all, for example the h:panelGroup does not have the isValid getter , while h:inputText does.

A workaround could be to abuse the validation status of another element in your page in order to apply the styleClass of another, see example:

<h:panelGroup styleClass="#{myComponent.valid ? '' : 'error'}">
    <h:inputText id="input" value="#{myBean.myValue}" binding="#{myComponent}">
    </h:inputText>
</h:panelGroup >



回答2:


Finally found the reason of the exception. The problem was that I had a comment in the code containing "component.valid". Removing the comment resolves the problem.

<!-- styleClass="#{component.valid ? '': 'err' }" -->

It's tricky. The exception was not clear about the line of code.



来源:https://stackoverflow.com/questions/26476793/implicit-expression-language-object-component-not-working-in-jsf-2-2-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!