How to refresh entire JSF page from the backing bean

六月ゝ 毕业季﹏ 提交于 2019-12-10 11:41:39

问题


We have a rich:comboBox on a JSF page which has a valueChangeListener that calls a backing bean function:

<rich:comboBox id="cbmodel" defaultLabel="${accessUtils.activeRole}" value="${accessUtils.activeRole}" 
 style="float: right;" valueChangeListener="${accessUtils.valueChangeListener}" >
   <c:forEach var="role" items="${accessUtils.currentUserRoles}"> 
    <f:selectItem itemValue="#{role}"/>
    <a4j:support event="onchange" ajaxSingle="false" />

</c:forEach>
</rich:comboBox>

And here's the valueChangeListener backing bean function:

public void valueChangeListener(ValueChangeEvent event){  
System.out.println("EVENT: HAS BEEN CALLED " + event.getNewValue());  
    setActiveRole((String) event.getNewValue());
}

How can we get this function to reload the JSF page which has the rich:comboBox?

Thanks for any help.


回答1:


You could use the oncomplete attribute of the <a4j:support> with JS to force a full page reload, if that's what you want to do, like:

<a4j:support event="onchange" ajaxSingle="false" oncomplete="javascript:location.reload(true)"/>



回答2:


a4j:support contains an optional reRender attribute that can force a JSF component to reload after invoking the JSF listener.

You can try with:

<a4j:support event="onchange" ajaxSingle="false" reRender="myComp" />


来源:https://stackoverflow.com/questions/3628722/how-to-refresh-entire-jsf-page-from-the-backing-bean

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