java <f:ajax> 无法将 <f:ajax> 附加到非 ClientBehaviorHolder 父级

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3539992/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 02:18:11  来源:igfitidea点击:

<f:ajax> Unable to attach <f:ajax> to non-ClientBehaviorHolder parent

javajsfjsf-2

提问by curiousgeorge

I receive the following error when running my application:

运行我的应用程序时收到以下错误:

<f:ajax> Unable to attach <f:ajax> to non-ClientBehaviorHolder parent

My JSF:

我的JSF:

    <h:commandButton id="submitschool" action="submit" value="Get templates" style="FONT-SIZE: medium;FONT-FAMILY: 'Rockwell';width : 128px; height : 24px;">
    <ui:repeat value="#{person.theImage}" var="item">
    <f:ajax event="change" render="image" />
    <h:graphicImage id="image" value="#{item}"/>
    </ui:repeat>
    </h:commandButton>

I'm trying to return back elements in an array to the view, where "theImage" is an array in person class.

我正在尝试将数组中的元素返回给视图,其中“theImage”是个人类中的数组。

回答by BalusC

The <f:ajax>tag can only be directly nested in an UIComponentwhich implements the ClientBehaviorHolderinterface. The <ui:repeat>isn't one of them.

<f:ajax>标签只能直接嵌套在UIComponent它实现了ClientBehaviorHolder接口。该<ui:repeat>是不是其中之一。

Click the javadoc link, it tells the following:

单击 javadoc 链接,它告诉以下内容:

All Known Implementing Classes:

HtmlBody, HtmlCommandButton, HtmlCommandLink, HtmlDataTable, HtmlForm, HtmlGraphicImage, HtmlInputSecret, HtmlInputText, HtmlInputTextarea, HtmlOutcomeTargetButton, HtmlOutcomeTargetLink, HtmlOutputLabel, HtmlOutputLink, HtmlPanelGrid, HtmlSelectBooleanCheckbox, HtmlSelectManyCheckbox, HtmlSelectManyListbox, HtmlSelectManyMenu, HtmlSelectOneListbox, HtmlSelectOneMenu, HtmlSelectOneRadio

所有已知的实现类:

HtmlBody,HtmlCommandButton,HtmlCommandLink,HtmlDataTable,HtmlForm控件,HtmlGraphicImage,HtmlInputSecret,的HtmlInputText,HtmlInputTextarea,HtmlOutcomeTargetButton,HtmlOutcomeTargetLink,HtmlOutputLabel,HtmlOutputLink,HtmlPanelGrid,HtmlSelectBooleanCheckbox,HtmlSelectManyCheckbox,HtmlSelectManyListbox,HtmlSelectManyMenu,HtmlSelectOneListbox,HtmlSelectOneMenu,HtmlSelectOneRadio

It's not clear from your question what your intent is, so I can't give a more specific answer than recommending to get rid of the <f:ajax>in this context. It doesn't belong there. Maybe you meant to put it directly inside the <h:commandButton>(which is of type HtmlCommandButton), but then you need to change the changeevent since it wouldn't make sense on a <input type="submit">generated by the <h:commandButton>.

从你的问题中不清楚你的意图是什么,所以我不能给出比建议<f:ajax>在这种情况下摆脱 更具体的答案。它不属于那里。也许你的意思是把它直接在里面<h:commandButton>(这是类型HtmlCommandButton),但你需要改变change的事件,因为它不会对任何意义<input type="submit">的生成的<h:commandButton>

I think you would also like to move the <ui:repeat>out of the <h:commandButton>since that does also not make much sense. Put it next to the <h:commandButton>instead of nesting inside it.

我认为您也想将<ui:repeat>移出 ,<h:commandButton>因为这也没有多大意义。把它放在旁边<h:commandButton>而不是嵌套在里面。