我正在开发liferay中的primefaces portlet。我收到了以下错误:
<f:ajax> contains an unknown id 'firstNameField' - cannot locate it in the context of the component firstName
代码段是:
<aui:field id="firstNameField" label="#{i18n['first-name']}">
<p:inputText id="firstName" label="#{i18n['first-name']}" required="true"
value="#{applicantModelBean.firstName}">
<f:ajax render="firstNameField"/>
<p:message id="firstNameMessage" for="firstName"/>
</p:inputText>
</aui:field>
**Stack trace is**
javax.faces.FacesException: <f:ajax> contains an unknown id 'firstNameField' - cannot locate it in the context of the component firstName
at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.getResolvedId(AjaxBehaviorRenderer.java:285)
at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.appendIds(AjaxBehaviorRenderer.java:272)
at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.buildAjaxCommand(AjaxBehaviorRenderer.java:214)
at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.getScript(AjaxBehaviorRenderer.java:86)
at javax.faces.component.behavior.ClientBehaviorBase.getScript(ClientBehaviorBase.java:103)
at com.sun.faces.renderkit.RenderKitUtils.getSingleBehaviorHandler(RenderKitUtils.java:1607)
at com.sun.faces.renderkit.RenderKitUtils.renderHandler(RenderKitUtils.java:1700)
at com.sun.faces.renderkit.RenderKitUtils.renderOnchange(RenderKitUtils.java:388)
at com.sun.faces.renderkit.html_basic.TextRenderer.getEndTextToRender(TextRenderer.java:134)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:170)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
答案 0 :(得分:0)
不确定<aui:field
来自哪个库
但是,似乎该组件未将其id
传递给生成的 HTML ,或者它可能会添加一些前缀......
执行:查看生成的HTML上的来源... <aui:field
的ID是多少?尝试在f:ajax