jsf 2.0 f:ajax render ID not found

2019-06-22 16:16发布

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>

2条回答
一纸荒年 Trace。
2楼-- · 2019-06-22 16:50

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")

查看更多
手持菜刀,她持情操
3楼-- · 2019-06-22 16:52

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.

查看更多
登录 后发表回答