问题
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>
回答1:
The :form1:pp1
won't work since you have prependId="false"
on the form. The pp1
won't work since it's then looking for the component in the same scope as <ui:repeat>
which is by itself an UINamingContainer
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 this
<span id="foo:bar:pp1">
You need to use exactly this ID prefixed with :
in the render
attribute.
<f:ajax render=":foo:bar:pp1">
If there's an autogenerated ID part such as j_id0
, then you need to give the parent component in question an fixed ID.
回答2:
If you use prependId=false
your panelGroup's id is pp1
instead of form1:pp1
. (Assume there is a typo in your attribute "prependID" instead of "prependid")
来源:https://stackoverflow.com/questions/5948498/jsf-2-0-fajax-render-id-not-found