问题
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 :
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/>
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