droidy
droidy

Reputation: 461

How to refresh entire JSF page from the backing bean

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.

Upvotes: 1

Views: 25675

Answers (2)

Jose Diaz
Jose Diaz

Reputation: 5398

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

Upvotes: 4

Vivien Barousse
Vivien Barousse

Reputation: 20875

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

Upvotes: 1

Related Questions