jsf 2.0 f:ajax 渲染 ID 未找到
单击弹出窗口 (pp1) 中的“保存”按钮时,项目列表会更新。 但是,当按下项目列表中的更新按钮时,渲染 ID :form1:pp1 不存在,渲染时会出现错误。如果 render="@all" 它可以工作,但效果不好。 (错误:
包含未知 id ':form1:pp1')
<h:form id="form1" prependid=false>
<h:panelGroup id="projects">
<ui:repeat var="action" value="#{dadadada}" varStatus="status">
<h:commandButton value="Save">
//gives id not found error
<f:ajax event="click" execute="@form" render=":form1:pp1" listener="#{fsfsfsfsfs}" />
</h:commandButton>
</ui:repeat>
</h:panelGroup> // project panel group
//popup
<h:panelGroup id="pp1">
<div id="popup2" class="popup_block">
//save button in the popup
<div class="popupBody_save2">
<h:commandButton image="resources/images/saveBtn.gif" value="Save">
<f:ajax event="click" execute="@form" render="projects" listener="#{dfsfssfs}" />
</h:commandButton>
</div>
</div>
</h:panelGroup>
</h:form>
When the Save button in the popup(pp1) clicked the projects list gets updated.
But when press the update button in the projects list, the render ID :form1:pp1 is not there error comes when its being rendered. If do render="@all" it works, but its not good.
( error : <f:ajax>
contains an unknown id ':form1:pp1')
<h:form id="form1" prependid=false>
<h:panelGroup id="projects">
<ui:repeat var="action" value="#{dadadada}" varStatus="status">
<h:commandButton value="Save">
//gives id not found error
<f:ajax event="click" execute="@form" render=":form1:pp1" listener="#{fsfsfsfsfs}" />
</h:commandButton>
</ui:repeat>
</h:panelGroup> // project panel group
//popup
<h:panelGroup id="pp1">
<div id="popup2" class="popup_block">
//save button in the popup
<div class="popupBody_save2">
<h:commandButton image="resources/images/saveBtn.gif" value="Save">
<f:ajax event="click" execute="@form" render="projects" listener="#{dfsfssfs}" />
</h:commandButton>
</div>
</div>
</h:panelGroup>
</h:form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
:form1:pp1
将不起作用,因为表单上有prependId="false"
。pp1
将无法工作,因为它会在与
相同范围内查找组件,而
本身就是一个UINamingContainer
组件。在网络浏览器中打开 JSF 页面,右键单击并查看源代码以获取生成的 HTML。找到由
生成的 HTML 元素。它应该看起来像这样:您需要在
render
属性中完全使用这个带有:
前缀的 ID。如果有自动生成的 ID 部分,例如
j_id0
,那么您需要为相关父组件提供一个固定 ID。The
:form1:pp1
won't work since you haveprependId="false"
on the form. Thepp1
won't work since it's then looking for the component in the same scope as<ui:repeat>
which is by itself anUINamingContainer
component.Open the JSF page in webbrowser, rightclick and View Source to get the generated HTML. Locate the HTML element which is generated by
<h:panelGroup id="pp1">
. It should look something like thisYou need to use exactly this ID prefixed with
:
in therender
attribute.If there's an autogenerated ID part such as
j_id0
, then you need to give the parent component in question an fixed ID.如果您使用
prependId=false
,您的 panelGroup 的 ID 为pp1
而不是form1:pp1
。 (假设您的属性“prependID”而不是“prependid”中有拼写错误)If you use
prependId=false
your panelGroup's id ispp1
instead ofform1:pp1
. (Assume there is a typo in your attribute "prependID" instead of "prependid")