Exemplo n.º 1
0
 @Override
 public void beforePhase(PhaseEvent event) {
   FacesContext context = event.getFacesContext();
   HttpServletRequest httpRequest = (HttpServletRequest) context.getExternalContext().getRequest();
   try {
     URLPolicyService service = getURLPolicyService();
     if (service.isCandidateForDecoding(httpRequest)) {
       // Make sure we're in a transaction, and that Seam knows it.
       // Sometimes, when there is a page action, SeamPhaseListener
       // commits the transaction in RENDER_RESPONSE before this
       // phase listener executes, but does not start a new one.
       // (SeamPhaseListener.handleTransactionsAfterPageActions)
       if (!Transaction.instance().isActiveOrMarkedRollback()) {
         Transaction.instance().begin();
       }
       // hot reload hook, maybe to move up so that it's handled on
       // all requests, not only the ones using the URLservice
       // framework (?)
       resetHotReloadContext(context);
       // restore state
       service.navigate(context);
       // apply requests parameters after - they may need the state
       // to be restored first.
       service.applyRequestParameters(context);
     }
   } catch (RuntimeException | SystemException | NotSupportedException e) {
     handleException(context, e);
   }
 }
Exemplo n.º 2
0
 protected String getCurrentMainTabFromRequest() {
   URLPolicyService service = Framework.getService(URLPolicyService.class);
   ServletRequest request =
       (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
   if (request instanceof HttpServletRequest) {
     DocumentView docView = service.getDocumentViewFromRequest((HttpServletRequest) request);
     if (docView == null) {
       return null;
     }
     String tabIds = docView.getParameter(WebActions.TAB_IDS_PARAMETER);
     String mainTabId = docView.getParameter(WebActions.MAIN_TAB_ID_PARAMETER);
     if (mainTabId != null && !mainTabId.isEmpty()) {
       tabIds = mainTabId;
     }
     if (tabIds != null && tabIds.contains(WebActions.MAIN_TABS_CATEGORY)) {
       String[] encodedActions = tabIds.split(",");
       for (String encodedAction : encodedActions) {
         if (encodedAction.startsWith(WebActions.MAIN_TABS_CATEGORY)) {
           String[] actionInfo = encodedAction.split(":");
           if (actionInfo != null && actionInfo.length > 1) {
             return actionInfo[1];
           }
         }
       }
     }
   }
   return null;
 }
Exemplo n.º 3
0
 public String getPatternFor(String mainTabId) {
   URLPolicyService service = Framework.getService(URLPolicyService.class);
   // FIXME: find some way to reference the pattern in the action,
   // assume the pattern will be the same than the default one for
   // now, or use the default one.
   if (!WebActions.DOCUMENTS_MAIN_TAB_ID.equals(mainTabId) && service.hasPattern(mainTabId)) {
     return mainTabId;
   }
   return service.getDefaultPatternName();
 }