Exemplo n.º 1
0
 private Url encode(BrixNodeWebPage page) {
   BrixNode node = page.getModelObject();
   // This is a URL for redirect. Allow components to contribute state to
   // URL if they want to
   final BrixPageParameters parameters = page.getBrixPageParameters();
   for (NamedPair namedPair : parameters.getAllNamed()) {
     if (isNumber(namedPair.getKey())) {
       parameters.remove(namedPair.getKey());
     }
   }
   page.visitChildren(
       PageParametersAware.class,
       new IVisitor<Component, PageParametersAware>() {
         @Override
         public void component(Component component, IVisit iVisit) {
           ((PageParametersAware) component).contributeToPageParameters(parameters);
         }
       });
   return encode(node, parameters, null);
 }
Exemplo n.º 2
0
 @Override
 public Url mapHandler(IRequestHandler requestHandler) {
   if (requestHandler instanceof BrixNodeRequestHandler) {
     BrixNodeRequestHandler handler = (BrixNodeRequestHandler) requestHandler;
     String nodeURL = handler.getNodeURL();
     return encode(nodeURL, handler.getPageParameters(), null);
   } else if (requestHandler instanceof ListenerInterfaceRequestHandler) {
     ListenerInterfaceRequestHandler handler = (ListenerInterfaceRequestHandler) requestHandler;
     if (handler.getPage() instanceof BrixNodeWebPage) {
       BrixNodeWebPage page = (BrixNodeWebPage) handler.getPage();
       String componentPath = handler.getComponentPath();
       RequestListenerInterface listenerInterface = handler.getListenerInterface();
       Integer renderCount = null;
       if (listenerInterface.isIncludeRenderCount()) {
         renderCount = page.getRenderCount();
       }
       PageInfo pageInfo = new PageInfo(page.getPageId());
       ComponentInfo componentInfo =
           new ComponentInfo(
               renderCount,
               requestListenerInterfaceToString(listenerInterface),
               componentPath,
               handler.getBehaviorIndex());
       PageComponentInfo info = new PageComponentInfo(pageInfo, componentInfo);
       Url url = encode(page);
       encodePageComponentInfo(url, info);
       return url;
     } else {
       return null;
     }
   } else if (requestHandler instanceof RenderPageRequestHandler) {
     RenderPageRequestHandler handler = (RenderPageRequestHandler) requestHandler;
     if (handler.getPage() instanceof BrixNodeWebPage) {
       BrixNodeWebPage page = (BrixNodeWebPage) handler.getPage();
       PageInfo i = new PageInfo(page.getPageId());
       PageComponentInfo info = new PageComponentInfo(i, null);
       Url url = encode(page);
       encodePageComponentInfo(url, info);
       return url;
     } else {
       return null;
     }
   } else if (requestHandler instanceof BookmarkableListenerInterfaceRequestHandler) {
     BookmarkableListenerInterfaceRequestHandler target =
         (BookmarkableListenerInterfaceRequestHandler) requestHandler;
     BrixNodeWebPage page = (BrixNodeWebPage) target.getPage();
     BrixNode node = page.getModelObject();
     PageInfo info = new PageInfo(page.getPageId());
     return encode(node, page.getBrixPageParameters(), info);
   } else if (requestHandler instanceof BookmarkablePageRequestHandler
       && ((BookmarkablePageRequestHandler) requestHandler)
           .getPageClass()
           .equals(HomePage.class)) {
     BrixNode node =
         ((BrixRequestCycleProcessor) RequestCycle.get().getActiveRequestHandler())
             .getNodeForUriPath(Path.ROOT);
     return mapHandler(new BrixNodeRequestHandler(new BrixNodeModel(node)));
   } else {
     return null;
   }
 }