[Java] Unable to attach to non-ClientBehaviorHolder Correspondence method when it becomes parent

less than 1 minute read

-Environment -CentOS Linux release 7.8.2003 (Core) -Eclipse IDE for Enterprise Java Developers.Version: 2020-03 (4.15.0) -openjdk version “11.0.7” 2020-04-14 LTS -JSF 2.3.9

Phenomenon: When I try to display a page by adding ajax processing, I get HTTPS status 500

Eclipse Console error


javax.faces.view.facelets.TagException: /base.xhtml @18,103 <f:ajax> Unable to attach <f:ajax> to non-ClientBehaviorHolder parent
    at com.sun.faces.facelets.tag.jsf.core.AjaxHandler.applyNested(AjaxHandler.java:276)
    at com.sun.faces.facelets.tag.jsf.core.AjaxHandler.apply(AjaxHandler.java:148)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
    at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:179)
...abridgement...

base.xhtml


...abridgement...
<h:inputHidden id="file">
  <f:ajax event="change" execute="@form" render="@form" listener="#{uploadBean.uploadFile}" />
</h:inputHidden>
...abridgement...

Cause: f:ajax cannot be used unless it is in a tag that implements the ClientBehaviorHolder interface

Register an AjaxBehavior instance on one or more UIComponents implementing the ClientBehaviorHolder interface. ajax(JSF 2.2 View Declaration Language: Facelets Variant)

Register an AjaxBehavior instance with one or more UIComponents that implement the ClientBehaviorHolder interface. In this case, the problem is whether h:inputHidden implements the ClientBehaviorHolder interface, but it was out of scope when I looked at the JavaDoc of ClientBehaviorHolder

All Known Implementing Classes: HtmlBody, HtmlCommandButton, HtmlCommandLink, HtmlDataTable, HtmlForm, HtmlGraphicImage, HtmlInputFile, HtmlInputSecret, HtmlInputText, HtmlInputTextarea, HtmlOutcomeTargetButton, HtmlOutcomeTargetLink, HtmlOutputLabel, HtmlOutputLink, HtmlPanelGrid, HtmlPanelGroup, HtmlSelectBooleanCheckbox, HtmlSelectManyCheckbox, HtmlSelectManyListbox, HtmlSelectManyMenu, HtmlSelectOneListbox, HtmlSelectOneMenu, HtmlSelectOneRadio ClientBehaviorHolder (JavaServer Faces API (2.2))

Supported: Change the tag to h:inputText

...abridgement...
<h:inputText id="file" style="display:none;">
  <f:ajax event="change" execute="@form" render="@form" listener="#{uploadBean.uploadFile}" />
</h:inputText>
...abridgement...

Tags: ,

Updated: