h:graphicImage无法重新渲染 [英] h:graphicImage not reRender
问题描述
我有一个jsf文件,其中有selectOneMenu和ah:graphicImage.现在的问题是当我通过selectOneMenu发送onchange请求并想重新渲染h:graphicImage并想在动作bean中显示和隐藏布尔值时.适当地.首先我非常仔细地研究它,当我通过selectOneMenu发送动作时,在Bean中正确设置了布尔值,但没有正确设置reRender值.如果刷新页面,那么它将正常工作.如果我想刷新页面,任何可以解决它的人在selectOneMenu actionlistener上,然后刷新页面.有关详细信息,请参见我的代码
i have a jsf file where i have selectOneMenu and a h:graphicImage.Now the problem is when i send onchange request through selectOneMenu and want to reRender the h:graphicImage and want to show and hide boolean in action bean.But not work properly. Actully first i investigate it very carefully that when i send action through selectOneMenu the boolean value set correctly in bean but not set the reRender value properly.If i refresh page then it work properly.Anyone who i can solve it if i want to refresh page on selectOneMenu actionlistener then how i refresh page.My code is here for more detail
<h:selectOneMenu id="stageListID" value="#{mnpBean.stageList.defaultValue}" >
<f:selectItems value="#{mnpBean.stageList.values}"/>
<a4j:support event="onchange" actionListener="#{mnpAction.onStageListChangeAction}" reRender="addBtn1" oncomplete="resetViewConfigs();"/>
</h:selectOneMenu>
图形图像代码
<h:graphicImage id="addBtn1" url="" rendered="#{mnpBean.showAddButton}" style="cursor:pointer">
<a4j:support id="addRowBtn1" event="onclick" actionListener="#{mnpAction.addMultiNoRingFence}"/>
</h:graphicImage>
此处有Bean代码
public void onStageListChangeAction(ActionEvent ae) {
mnpBean = getMNPBean();
if ("10".equals(mnpBean.getStatusList().getDefaultValue()) && "010".equals(mnpBean.getStageList().getDefaultValue())) {
mnpBean.setShowAddButton(false);
}else{
mnpBean.setShowAddButton(true);
}
}
对此表示感谢的任何帮助
Any helping regarding this appreciate
推荐答案
您应该做什么:
-
将
<h:graphicImage/>
包裹在类似<h:panelGrid/>
<a4j:outputPanel ajaxRendered="true" layout="none" id="imageContainer">
<h:graphicImage id="addBtn1" url="" rendered="#{mnpBean.showAddButton}" style="cursor:pointer">
<a4j:support id="addRowBtn1" event="onclick" actionListener="#{mnpAction.addMultiNoRingFence}"/>
</h:graphicImage>
<a4j:outputPanel/>
使用容器的ID作为reRender
<a4j:support event="onchange" actionListener="#{mnpAction.onStageListChangeAction}" reRender="imageContainer" oncomplete="resetViewConfigs();"/>
首先考虑问题的原因,请参见此处
For the reason why the issue is happening the first place, see explanation here
这篇关于h:graphicImage无法重新渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!