sâmbătă, 18 iulie 2015

[OmniFaces utilities 2.2] Refresh the current page by a GET request, maintaining the query string


[OmniFaces utilities] The refreshWithQueryString() method refreshes the current page by a GET request, maintaining the query string. This basically sends a temporary (302) redirect to current request URI, with the current query string. Whenever something fails at I/O level, the caller should preferably not catch it, but just redeclare it in the action method. The servlet container will handle it.

Method:
Usage:

Let's have a simple example of Faces#refreshWithQueryString(). Notice that we are using <o:form> not the standard <h:form> because we want to preserve the query string over postback:

<o:form includeRequestParams="true">
 <h:commandButton value="Refresh" action="#{bean.refreshPage()}" />
</o:form>

public void refreshPage() throws IOException {       
 Faces.refreshWithQueryString();
}

Niciun comentariu:

Trimiteți un comentariu