Permalink
Browse files

Add Faces#refresh() and #refreshWithQueryString().

  • Loading branch information...
1 parent 811a543 commit 572c118a0faa1ef63e1635ef1ba4451d4a3ad81b @BalusC BalusC committed Jul 17, 2015
Showing with 43 additions and 0 deletions.
  1. +27 −0 src/main/java/org/omnifaces/util/Faces.java
  2. +16 −0 src/main/java/org/omnifaces/util/FacesLocal.java
@@ -1172,6 +1172,33 @@ public static void redirectPermanent(String url, String... paramValues) {
}
/**
+ * Refresh the current page by a GET request. This basically sends a temporary (302) redirect to current request
+ * URI, without query string.
+ * @throws IOException Whenever something fails at I/O level. The caller should preferably not catch it, but just
+ * redeclare it in the action method. The servletcontainer will handle it.
+ * @see ExternalContext#redirect(String)
+ * @see HttpServletRequest#getRequestURI()
+ * @since 2.2
+ */
+ public static void refresh() throws IOException {
+ FacesLocal.refresh(getContext());
+ }
+
+ /**
+ * Refresh 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.
+ * @throws IOException Whenever something fails at I/O level. The caller should preferably not catch it, but just
+ * redeclare it in the action method. The servletcontainer will handle it.
+ * @see ExternalContext#redirect(String)
+ * @see HttpServletRequest#getRequestURI()
+ * @see HttpServletRequest#getQueryString()
+ * @since 2.2
+ */
+ public static void refreshWithQueryString() throws IOException {
+ FacesLocal.refreshWithQueryString(getContext());
+ }
+
+ /**
* Sends a HTTP response error with the given status and message. This will end up in either a custom
* <code>&lt;error-page&gt;</code> whose <code>&lt;error-code&gt;</code> matches the given status, or in a servlet
* container specific default error page if there is none. The message will be available in the error page as a
@@ -889,6 +889,22 @@ public static void redirectPermanent(FacesContext context, String url, String...
/**
* {@inheritDoc}
+ * @see Faces#refresh()
+ */
+ public static void refresh(FacesContext context) throws IOException {
+ redirect(context, getRequestURI(context));
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see Faces#refreshWithQueryString()
+ */
+ public static void refreshWithQueryString(FacesContext context) throws IOException {
+ redirect(context, getRequestURIWithQueryString(context));
+ }
+
+ /**
+ * {@inheritDoc}
* @see Faces#responseSendError(int, String)
*/
public static void responseSendError(FacesContext context, int status, String message) throws IOException {

0 comments on commit 572c118

Please sign in to comment.