| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package javax.faces.internal.scope; |
| 17 | |
|
| 18 | |
import java.util.Map; |
| 19 | |
|
| 20 | |
import javax.faces.FacesException; |
| 21 | |
import javax.faces.context.FacesContext; |
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
public abstract class RedirectScope { |
| 28 | |
|
| 29 | 2 | private static final String REDIRECTING_KEY = RedirectScope.class.getName(); |
| 30 | |
|
| 31 | 1 | private static final String REDIRECTED_KEY = RedirectScope.class.getName() + |
| 32 | |
".REDIRECTED"; |
| 33 | |
|
| 34 | 1 | private static final VariableScope scope = new VariableScope( |
| 35 | |
REDIRECTING_KEY); |
| 36 | |
|
| 37 | 0 | protected RedirectScope() { |
| 38 | 0 | } |
| 39 | |
|
| 40 | |
public static Map getContext(FacesContext context) throws FacesException { |
| 41 | 0 | return scope.getContext(context); |
| 42 | |
} |
| 43 | |
|
| 44 | |
public static Map getOrCreateContext(FacesContext context) |
| 45 | |
throws FacesException { |
| 46 | 4 | return scope.getOrCreateContext(context); |
| 47 | |
} |
| 48 | |
|
| 49 | |
public static void removeContext(FacesContext context) |
| 50 | |
throws FacesException { |
| 51 | 0 | scope.removeContext(context); |
| 52 | 0 | } |
| 53 | |
|
| 54 | |
public static void clearContext(FacesContext context) throws FacesException { |
| 55 | 2 | scope.clearContext(context); |
| 56 | 2 | } |
| 57 | |
|
| 58 | |
public static boolean isRedirecting(FacesContext context) |
| 59 | |
throws FacesException { |
| 60 | 2 | Map ctx = scope.getContext(context); |
| 61 | 2 | if (ctx == null) { |
| 62 | 2 | return false; |
| 63 | |
} |
| 64 | 0 | return ctx.containsKey(REDIRECTING_KEY); |
| 65 | |
} |
| 66 | |
|
| 67 | |
public static void setRedirectingPath(FacesContext context, String path) |
| 68 | |
throws FacesException { |
| 69 | 1 | Map ctx = getOrCreateContext(context); |
| 70 | 1 | ctx.put(REDIRECTING_KEY, path); |
| 71 | 1 | } |
| 72 | |
|
| 73 | |
public static String getRedirectingPath(FacesContext context) |
| 74 | |
throws FacesException { |
| 75 | 0 | Map ctx = scope.getContext(context); |
| 76 | 0 | if (ctx == null) { |
| 77 | 0 | return null; |
| 78 | |
} |
| 79 | 0 | return (String) ctx.get(REDIRECTING_KEY); |
| 80 | |
} |
| 81 | |
|
| 82 | |
public static void setRedirectedPath(FacesContext context, String path) |
| 83 | |
throws FacesException { |
| 84 | 0 | Map ctx = getOrCreateContext(context); |
| 85 | 0 | ctx.put(REDIRECTED_KEY, path); |
| 86 | 0 | } |
| 87 | |
|
| 88 | |
public static String getRedirectedPath(FacesContext context) |
| 89 | |
throws FacesException { |
| 90 | 0 | Map ctx = scope.getContext(context); |
| 91 | 0 | if (ctx == null) { |
| 92 | 0 | return null; |
| 93 | |
} |
| 94 | 0 | return (String) ctx.get(REDIRECTED_KEY); |
| 95 | |
} |
| 96 | |
} |