h:graphicImage not reRender

故事扮演 提交于 2019-12-11 23:17:55

问题


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>

code for grphic image

<h:graphicImage id="addBtn1"  url=""  rendered="#{mnpBean.showAddButton}" style="cursor:pointer">
<a4j:support id="addRowBtn1" event="onclick"  actionListener="#{mnpAction.addMultiNoRingFence}"/>
</h:graphicImage> 

bean code here

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


回答1:


What you should do :

  1. Wrap your <h:graphicImage/> in a container like <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/>
    
  2. Use the id of the container as the target of the 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



来源:https://stackoverflow.com/questions/14397771/hgraphicimage-not-rerender

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!