use of javax.faces.application.NavigationHandler in project acs-community-packaging by Alfresco.
the class DoneEditingDialog method handle.
/**
* Method for handling done-editing action(e.g. "done_editing_doc")
* @param event Action Event
*/
public void handle(ActionEvent event) {
setupContentAction(event);
FacesContext fc = FacesContext.getCurrentInstance();
NavigationHandler nh = fc.getApplication().getNavigationHandler();
// if content is versionable then check-in else move to dialog for filling version info
if (isVersionable()) {
nh.handleNavigation(fc, null, DIALOG_NAME);
} else {
checkinFileOK(fc, null);
nh.handleNavigation(fc, null, AlfrescoNavigationHandler.DIALOG_PREFIX + "browse");
}
}
use of javax.faces.application.NavigationHandler in project acs-community-packaging by Alfresco.
the class ExternalAccessServlet method service.
/**
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
String uri = req.getRequestURI();
if (logger.isDebugEnabled())
logger.debug("Processing URL: " + uri + (req.getQueryString() != null ? ("?" + req.getQueryString()) : ""));
AuthenticationStatus status = servletAuthenticate(req, res);
if (status == AuthenticationStatus.Failure) {
return;
}
setNoCacheHeaders(res);
uri = uri.substring(req.getContextPath().length());
StringTokenizer t = new StringTokenizer(uri, "/");
int tokenCount = t.countTokens();
if (tokenCount < 2) {
throw new IllegalArgumentException("Externally addressable URL did not contain all required args: " + uri);
}
// skip servlet name
t.nextToken();
String outcome = t.nextToken();
// get rest of the tokens arguments
String[] args = new String[tokenCount - 2];
for (int i = 0; i < tokenCount - 2; i++) {
args[i] = t.nextToken();
}
if (logger.isDebugEnabled())
logger.debug("External outcome found: " + outcome);
// we almost always need this bean reference
FacesContext fc = FacesHelper.getFacesContext(req, res, getServletContext());
BrowseBean browseBean = (BrowseBean) FacesHelper.getManagedBean(fc, "BrowseBean");
// get services we need
ServiceRegistry serviceRegistry = getServiceRegistry(getServletContext());
PermissionService permissionService = serviceRegistry.getPermissionService();
// as we are potentially coming in from an external app reset the view stack
Stack viewStack = (Stack) fc.getExternalContext().getSessionMap().get("_alfViewStack");
if (viewStack != null) {
viewStack.clear();
if (logger.isDebugEnabled())
logger.debug("Cleared view stack");
}
// setup is required for certain outcome requests
if (OUTCOME_DOCDETAILS.equals(outcome)) {
NodeRef nodeRef = null;
if (args[0].equals(WebDAVServlet.WEBDAV_PREFIX)) {
nodeRef = resolveWebDAVPath(fc, args);
} else if (args.length == 3) {
StoreRef storeRef = new StoreRef(args[0], args[1]);
nodeRef = new NodeRef(storeRef, args[2]);
}
if (nodeRef != null) {
// check that the user has at least READ access - else redirect to an error or login page
if (!checkAccess(req, res, nodeRef, PermissionService.READ_CONTENT, true)) {
return;
}
// setup the Document on the browse bean
browseBean.setupContentAction(nodeRef.getId(), true);
}
// perform the appropriate JSF navigation outcome
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, "dialog:" + OUTCOME_DOCDETAILS);
} else if (OUTCOME_SPACEDETAILS.equals(outcome)) {
NodeRef nodeRef = null;
if (args[0].equals(WebDAVServlet.WEBDAV_PREFIX)) {
nodeRef = resolveWebDAVPath(fc, args);
} else if (args.length == 3) {
StoreRef storeRef = new StoreRef(args[0], args[1]);
nodeRef = new NodeRef(storeRef, args[2]);
}
if (nodeRef != null) {
// check that the user has at least READ access - else redirect to an error or login page
if (!checkAccess(req, res, nodeRef, PermissionService.READ_CONTENT, true)) {
return;
}
// setup the Space on the browse bean
browseBean.setupSpaceAction(nodeRef.getId(), true);
}
// perform the appropriate JSF navigation outcome
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, "dialog:" + OUTCOME_SPACEDETAILS);
} else if (OUTCOME_BROWSE.equals(outcome)) {
NodeRef nodeRef = null;
if (args.length != 0 && args[0].equals(WebDAVServlet.WEBDAV_PREFIX)) {
nodeRef = resolveWebDAVPath(fc, args);
} else if (args.length >= 3) {
int offset = 0;
offset = args.length - 3;
StoreRef storeRef = new StoreRef(args[0 + offset], args[1 + offset]);
nodeRef = new NodeRef(storeRef, args[2 + offset]);
}
if (nodeRef != null) {
// check that the user has at least READ access - else redirect to an error or login page
if (!checkAccess(req, res, nodeRef, PermissionService.READ_CONTENT, true)) {
return;
}
// this call sets up the current node Id, and updates or initialises the
// breadcrumb component with the selected node as appropriate.
browseBean.updateUILocation(nodeRef);
// force a "late" refresh of the BrowseBean to handle external servlet access URL
browseBean.externalAccessRefresh();
// check for view mode first argument
if (args[0].equals(ARG_TEMPLATE)) {
browseBean.setDashboardView(true);
}
// the above calls into BrowseBean setup the NavigationHandler automatically
} else {
// perform the appropriate JSF navigation outcome
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, outcome);
}
} else if (OUTCOME_MYALFRESCO.equals(outcome)) {
// setup the Dashboard Manager ready for the page we want to display
if (req.getParameter(ARG_PAGE) != null) {
DashboardManager manager = (DashboardManager) FacesHelper.getManagedBean(fc, DashboardManager.BEAN_NAME);
manager.getPageConfig().setCurrentPage(req.getParameter(ARG_PAGE));
}
// perform the appropriate JSF navigation outcome
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, outcome);
} else if (OUTCOME_DIALOG.equals(outcome) || OUTCOME_WIZARD.equals(outcome)) {
if (args.length != 0) {
if (args.length > 1) {
String currentNodeId = null;
if (args[1].equals(WebDAVServlet.WEBDAV_PREFIX)) {
// Drop the first argument
String[] args2 = new String[args.length - 1];
for (int i = 1; i < args.length; i++) {
args2[i - 1] = args[i];
if (logger.isDebugEnabled()) {
logger.debug("Added segment " + args2[i - 1]);
}
}
NodeRef nodeRef = resolveWebDAVPath(fc, args2);
currentNodeId = nodeRef.getId();
} else {
currentNodeId = args[1];
}
if (logger.isDebugEnabled()) {
logger.debug("currentNodeId: " + currentNodeId);
}
// if a GUID was passed, use it to init the NavigationBean current context
NavigationBean navigator = (NavigationBean) FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME);
navigator.setCurrentNodeId(currentNodeId);
browseBean.setupSpaceAction(currentNodeId, true);
// setup the Document on the browse bean
// avoid java.lang.NullPointerException
// at org.alfresco.web.bean.content.InviteContentUsersWizard.getPermissionsForType(InviteContentUsersWizard.java:49)
// at org.alfresco.web.bean.wizard.BaseInviteUsersWizard.getRoles(BaseInviteUsersWizard.java:562)
browseBean.setupContentAction(currentNodeId, true);
}
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, outcome + ':' + args[0]);
}
} else if (OUTCOME_LOGOUT.equals(outcome)) {
// special case for logout
// invalidate ticket and clear the Security context for this thread
Application.logOut(fc);
res.sendRedirect(req.getContextPath() + FACES_SERVLET + Application.getLoginPage(getServletContext()));
return;
}
// perform the forward to the page processed by the Faces servlet
String viewId = fc.getViewRoot().getViewId();
ViewSequenceUtils.nextViewSequence(fc);
getServletContext().getRequestDispatcher(FACES_SERVLET + viewId).forward(req, res);
}
use of javax.faces.application.NavigationHandler in project core by weld.
the class MyExceptionHandler method handle.
@Override
public void handle() throws FacesException {
if (getUnhandledExceptionQueuedEvents().iterator().hasNext()) {
FacesContext facesContext = FacesContext.getCurrentInstance();
NavigationHandler navHandler = facesContext.getApplication().getNavigationHandler();
navHandler.handleNavigation(facesContext, null, "/error.jsf?faces-redirect=true");
}
}
use of javax.faces.application.NavigationHandler in project muikku by otavanopisto.
the class ExceptionHandler method renderView.
private void renderView(String viewId) {
FacesContext facesContext = FacesContext.getCurrentInstance();
NavigationHandler navigationHandler = facesContext.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(facesContext, null, viewId);
facesContext.renderResponse();
}
use of javax.faces.application.NavigationHandler in project spring-framework by spring-projects.
the class DecoratingNavigationHandler method callNextHandlerInChain.
/**
* Method to be called by subclasses when intending to delegate to the next
* handler in the NavigationHandler chain. Will always call the most
* appropriate next handler, either the decorated NavigationHandler passed
* in as constructor argument or the original NavigationHandler as passed
* into this method - according to the position of this instance in the chain.
* <p>Will call the decorated NavigationHandler specified as constructor
* argument, if any. In case of a DecoratingNavigationHandler as target, the
* original NavigationHandler as passed into this method will be passed on to
* the next element in the chain: This ensures propagation of the original
* handler that the last element in the handler chain might delegate back to.
* In case of a standard NavigationHandler as target, the original handler
* will simply not get passed on; no delegating back to the original is
* possible further down the chain in that scenario.
* <p>If no decorated NavigationHandler specified as constructor argument,
* this instance is the last element in the chain. Hence, this method will
* call the original NavigationHandler as passed into this method. If no
* original NavigationHandler has been passed in (for example if this
* instance is the last element in a chain with standard NavigationHandlers
* as earlier elements), this method corresponds to a no-op.
* @param facesContext the current JSF context
* @param fromAction the action binding expression that was evaluated to retrieve the
* specified outcome, or {@code null} if the outcome was acquired by some other means
* @param outcome the logical outcome returned by a previous invoked application action
* (which may be {@code null})
* @param originalNavigationHandler the original NavigationHandler,
* or {@code null} if none
*/
protected final void callNextHandlerInChain(FacesContext facesContext, String fromAction, String outcome, NavigationHandler originalNavigationHandler) {
NavigationHandler decoratedNavigationHandler = getDecoratedNavigationHandler();
if (decoratedNavigationHandler instanceof DecoratingNavigationHandler) {
// DecoratingNavigationHandler specified through constructor argument:
// Call it with original NavigationHandler passed in.
DecoratingNavigationHandler decHandler = (DecoratingNavigationHandler) decoratedNavigationHandler;
decHandler.handleNavigation(facesContext, fromAction, outcome, originalNavigationHandler);
} else if (decoratedNavigationHandler != null) {
// Standard NavigationHandler specified through constructor argument:
// Call it through standard API, without original NavigationHandler passed in.
// The called handler will not be able to redirect to the original handler.
decoratedNavigationHandler.handleNavigation(facesContext, fromAction, outcome);
} else if (originalNavigationHandler != null) {
// No NavigationHandler specified through constructor argument:
// Call original handler, marking the end of this chain.
originalNavigationHandler.handleNavigation(facesContext, fromAction, outcome);
}
}
Aggregations