javax.faces.application.NavigationCase Java Examples
The following examples show how to use
javax.faces.application.NavigationCase.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 6 votes |
@Override public Set<NavigationCase> put(String key, Set<NavigationCase> value) { if (value == null) { return null; } Set<NavigationCase> result = new HashSet<NavigationCase>(); //filter entries created by createViewConfigBasedNavigationCases for (NavigationCase navigationCase : value) { if (!(navigationCase.getFromOutcome() == null && navigationCase.getFromAction() == null)) { result.add(navigationCase); } } //delegate to the wrapped instance -> the innermost handler needs to receive it //(because mojarra uses ConfigurableNavigationHandler#getNavigationCases // to add cases for std. nav.rules from the outside) return this.wrapped.getNavigationCases().put(key, result); }
Example #2
Source File: DeltaSpikeNavigationHandler.java From deltaspike with Apache License 2.0 | 6 votes |
@Override public Map<String, Set<NavigationCase>> getNavigationCases() { Map<String, Set<NavigationCase>> result = null; if (this.wrapped instanceof ConfigurableNavigationHandler) { result = ((ConfigurableNavigationHandler) this.wrapped).getNavigationCases(); } if (result == null) { result = new HashMap<String, Set<NavigationCase>>(); } if (!this.activated) { return result; } return new NavigationCaseMapWrapper(result, this.wrapped); }
Example #3
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
@Override public boolean add(NavigationCase navigationCase) { Set<NavigationCase> navigationCases = this.wrapped.getNavigationCases().get(this.navigationCaseKey); if (navigationCases == null) { navigationCases = new HashSet<NavigationCase>(); this.wrapped.getNavigationCases().put(this.navigationCaseKey, navigationCases); } return navigationCases.add(navigationCase); }
Example #4
Source File: RedirectNavigationHandler.java From development with Apache License 2.0 | 5 votes |
/** * Handles redirection. After POST action is done on the page and redirect * to the same page is found, informs navigation handler to do GET in order * to avoid f.e. Form Resubmission. * * @param context * - FacesContext * @param from * - navigate from * @param outcome * - navigate to */ @Override public void handleNavigation(FacesContext context, String from, String outcome) { NavigationCase navCase = getNavigationCase(context, from, outcome); if (notNull(context, navCase, from, outcome) && isRedirectNeeded(context, outcome) && isSamePageRedirect(navCase, context)) { outcome = navCase.getToViewId(context) + FACES_REDIRECT; } parent.handleNavigation(context, from, outcome); }
Example #5
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
private DelegatingSet(Collection<? extends NavigationCase> c, ConfigurableNavigationHandler wrapped, String navigationCaseKey) { super(c); this.wrapped = wrapped; this.navigationCaseKey = navigationCaseKey; }
Example #6
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
@Override public Set<NavigationCase> get(Object key) { Set<NavigationCase> navigationCases = super.get(key); if (navigationCases == null) { navigationCases = new HashSet<NavigationCase>(); put((String)key, navigationCases); } return new DelegatingSet(navigationCases, this.wrapped, (String)key); }
Example #7
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
/** * @return a combination of navigation-cases configured via XML and * {@link org.apache.deltaspike.core.api.config.view.ViewConfig}s */ @Override public Set<Entry<String, Set<NavigationCase>>> entrySet() { Set<Entry<String, Set<NavigationCase>>> result = new HashSet<Entry<String, Set<NavigationCase>>>(); result.addAll(this.wrappedNavigationCaseMap.entrySet()); result.addAll(createViewConfigBasedNavigationCases(true).entrySet()); return result; }
Example #8
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
/** * @return a combination of navigation-cases configured via XML and * {@link org.apache.deltaspike.core.api.config.view.ViewConfig}s */ @Override public Collection<Set<NavigationCase>> values() { Collection<Set<NavigationCase>> result = new HashSet<Set<NavigationCase>>(); result.addAll(this.wrappedNavigationCaseMap.values()); result.addAll(createViewConfigBasedNavigationCases(true).values()); return result; }
Example #9
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
/** * XML configuration overrules {@link org.apache.deltaspike.core.api.config.view.ViewConfig}s */ @Override public Set<NavigationCase> get(Object key) { Set<NavigationCase> result = this.wrappedNavigationCaseMap.get(key); if (result == null) { return createViewConfigBasedNavigationCases(true).get(key); } return result; }
Example #10
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 5 votes |
/** * Constructor for wrapping the given navigation-cases * * @param navigationCases current navigation-cases * @param wrapped wrapped navigation-handler */ public NavigationCaseMapWrapper(Map<String, Set<NavigationCase>> navigationCases, NavigationHandler wrapped) { this.wrappedNavigationCaseMap = navigationCases; this.wrapped = wrapped; this.viewConfigBasedNavigationCaseCache = createViewConfigBasedNavigationCases(false); }
Example #11
Source File: ButtonRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Find all parameters to include by looking at nested uiparams and params * of navigation case */ protected static Map<String, List<String>> getParams(NavigationCase navCase, Button button) { Map<String, List<String>> params = new LinkedHashMap<String, List<String>>(); // UIParams for (UIComponent child : button.getChildren()) { if (child.isRendered() && (child instanceof UIParameter)) { UIParameter uiParam = (UIParameter) child; if (!uiParam.isDisable()) { List<String> paramValues = params.get(uiParam.getName()); if (paramValues == null) { paramValues = new ArrayList<String>(); params.put(uiParam.getName(), paramValues); } paramValues.add(String.valueOf(uiParam.getValue())); } } } // NavCase Params Map<String, List<String>> navCaseParams = navCase.getParameters(); if (navCaseParams != null && !navCaseParams.isEmpty()) { for (Map.Entry<String, List<String>> entry : navCaseParams.entrySet()) { String key = entry.getKey(); // UIParams take precedence if (!params.containsKey(key)) { params.put(key, entry.getValue()); } } } return params; }
Example #12
Source File: ButtonRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Translate the outcome attribute value to the target URL. * * @param context * the current FacesContext * @param outcome * the value of the outcome attribute * @return the target URL of the navigation rule (or the outcome if there's * not navigation rule) */ private String determineTargetURL(FacesContext context, Button button, String outcome) { ConfigurableNavigationHandler cnh = (ConfigurableNavigationHandler) context.getApplication() .getNavigationHandler(); NavigationCase navCase = cnh.getNavigationCase(context, null, outcome); /* * Param Name: javax.faces.PROJECT_STAGE Default Value: The default * value is ProjectStage#Production but IDE can set it differently in * web.xml Expected Values: Development, Production, SystemTest, * UnitTest Since: 2.0 * * If we cannot get an outcome we use an Alert to give a feedback to the * Developer if this build is in the Development Stage */ if (navCase == null) { if (FacesContext.getCurrentInstance().getApplication().getProjectStage().equals(ProjectStage.Development)) { return "alert('WARNING! " + C.W_NONAVCASE_BUTTON + "');"; } else { return ""; } } // throw new FacesException("The outcome '"+outcome+"' cannot be // resolved."); } String vId = navCase.getToViewId(context); Map<String, List<String>> params = getParams(navCase, button); String url; url = context.getApplication().getViewHandler().getBookmarkableURL(context, vId, params, button.isIncludeViewParams() || navCase.isIncludeViewParams()); return url; }
Example #13
Source File: NavLinkRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * Find all parameters to include by looking at nested uiparams and params of * navigation case */ protected Map<String, List<String>> getParams(NavigationCase navCase, AbstractNavLink button) { Map<String, List<String>> params = new LinkedHashMap<String, List<String>>(); // UIParams for (UIComponent child : ((UIComponent) button).getChildren()) { if (child.isRendered() && (child instanceof UIParameter)) { UIParameter uiParam = (UIParameter) child; if (!uiParam.isDisable()) { List<String> paramValues = params.get(uiParam.getName()); if (paramValues == null) { paramValues = new ArrayList<String>(); params.put(uiParam.getName(), paramValues); } paramValues.add(String.valueOf(uiParam.getValue())); } } } // NavCase Params Map<String, List<String>> navCaseParams = navCase.getParameters(); if (navCaseParams != null && !navCaseParams.isEmpty()) { for (Map.Entry<String, List<String>> entry : navCaseParams.entrySet()) { String key = entry.getKey(); // UIParams take precedence if (!params.containsKey(key)) { params.put(key, entry.getValue()); } } } return params; }
Example #14
Source File: NavLinkRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
private String encodeHref(FacesContext context, AbstractNavLink navlink) { String href = navlink.getHref(); String url; if (href != null) { url = getResourceURL(context, href); return url; } else { String outcome = navlink.getOutcome(); if (outcome == null) { return null; } ConfigurableNavigationHandler cnh = (ConfigurableNavigationHandler) context.getApplication() .getNavigationHandler(); NavigationCase navCase = cnh.getNavigationCase(context, null, outcome); if (navCase == null) { return null; } String vId = navCase.getToViewId(context); Map<String, List<String>> params = getParams(navCase, navlink); url = context.getApplication().getViewHandler().getBookmarkableURL(context, vId, params, navlink.isIncludeViewParams() || navCase.isIncludeViewParams()); if (url != null) { String frag = navlink.getFragment(); if (frag != null) { url += "#" + frag; } return url; } else { return "#"; } } }
Example #15
Source File: BeyondViewScopeNavigationHandler.java From JSF-on-Spring-Boot with GNU General Public License v3.0 | 5 votes |
/** Calls the default implementation */ @Override public Map<String, Set<NavigationCase>> getNavigationCases() { if (wrappedNavigationHandler instanceof ConfigurableNavigationHandler) { return ((ConfigurableNavigationHandler) wrappedNavigationHandler) .getNavigationCases(); } else { return null; } }
Example #16
Source File: BeyondViewScopeNavigationHandler.java From JSF-on-Spring-Boot with GNU General Public License v3.0 | 5 votes |
/** Calls the default implementation */ @Override public NavigationCase getNavigationCase(FacesContext context, String fromAction, String outcome) { if (wrappedNavigationHandler instanceof ConfigurableNavigationHandler) { return ((ConfigurableNavigationHandler) wrappedNavigationHandler) .getNavigationCase(context, fromAction, outcome); } else { return null; } }
Example #17
Source File: RedirectNavigationHandler.java From development with Apache License 2.0 | 5 votes |
/** * @return */ @Override public Map<String, Set<NavigationCase>> getNavigationCases() { if (parent instanceof ConfigurableNavigationHandler) { return ((ConfigurableNavigationHandler) parent) .getNavigationCases(); } else { return null; } }
Example #18
Source File: RedirectNavigationHandler.java From development with Apache License 2.0 | 5 votes |
/** * @param context * @param fromAction * @param outcome * @return */ @Override public NavigationCase getNavigationCase(FacesContext context, String fromAction, String outcome) { if (parent instanceof ConfigurableNavigationHandler) { return ((ConfigurableNavigationHandler) parent).getNavigationCase( context, fromAction, outcome); } else { return null; } }
Example #19
Source File: DeltaSpikeNavigationHandlerWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public Map<String, Set<NavigationCase>> getNavigationCases() { return this.deltaSpikeNavigationHandler.getNavigationCases(); }
Example #20
Source File: DeltaSpikeNavigationHandlerWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public NavigationCase getNavigationCase(FacesContext context, String fromAction, String outcome) { return this.deltaSpikeNavigationHandler.getNavigationCase(context, fromAction, outcome); }
Example #21
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
private Map<String, Set<NavigationCase>> createViewConfigBasedNavigationCases(boolean allowParameters) { Map<String, Set<NavigationCase>> result; if (this.wrapped instanceof ConfigurableNavigationHandler) { result = new DelegatingMap((ConfigurableNavigationHandler)this.wrapped); } else { LOG.warning("the wrapped navigation-handler doesn't extend " + ConfigurableNavigationHandler.class.getName() + ". therefore std. navigation-rules might not work correctly with mojarra"); result = new HashMap<String, Set<NavigationCase>>(); } Collection<ViewConfigDescriptor> viewConfigDescriptors = BeanProvider.getContextualReference(ViewConfigResolver.class).getViewConfigDescriptors(); if (!viewConfigDescriptors.isEmpty()) { Set<NavigationCase> navigationCase = new HashSet<NavigationCase>(); Map<String, List<String>> parameters = null; if (allowParameters) { parameters = resolveParameters(); } boolean includeParameters; for (ViewConfigDescriptor entry : viewConfigDescriptors) { View viewMetaData = entry.getMetaData(View.class).iterator().next(); includeParameters = View.ViewParameterMode.INCLUDE .equals(viewMetaData.viewParams()); navigationCase.add(new NavigationCase("*", null, null, null, entry.getViewId(), includeParameters ? parameters : null, View.NavigationMode.REDIRECT.equals(viewMetaData.navigation()), includeParameters)); result.put(entry.getViewId(), navigationCase); } } return result; }
Example #22
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public Set<NavigationCase> put(String key, Set<NavigationCase> value) { return this.wrappedNavigationCaseMap.put(key, value); }
Example #23
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public Set<NavigationCase> remove(Object key) { return this.wrappedNavigationCaseMap.remove(key); }
Example #24
Source File: NavigationCaseMapWrapper.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public void putAll(Map<? extends String, ? extends Set<NavigationCase>> m) { this.wrappedNavigationCaseMap.putAll(m); }
Example #25
Source File: RedirectNavigationHandler.java From development with Apache License 2.0 | 3 votes |
/** * @param navCase * - NavigationCase * @param context * - FacesContext * @return - true if redirect is done to the same page it is currently on * and page is registered in PRG_REGISTRY, false otherwise */ private boolean isSamePageRedirect(NavigationCase navCase, FacesContext context) { return notNull(navCase.getFromViewId()) && navCase.getFromViewId().equals(navCase.getToViewId(context)); }