Ejemplo 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);
 }
Ejemplo n.º 2
0
  private BrixPageParameters createBrixPageParams(Url url, Path path) {
    BrixPageParameters parameters = new BrixPageParameters();
    Path nodePath = path;
    Path requestPath = new Path("/" + url.getPath());

    if (nodePath.isAncestorOf(requestPath)) {
      Path remaining = new Path(requestPath.toString(), false).toRelative(nodePath);
      int i = 0;
      for (String s : remaining) {
        parameters.set(i, BrixNodePageUrlMapper.urlDecode(s));
        ++i;
      }
    }
    for (QueryParameter parameter : url.getQueryParameters()) {
      String parameterName = parameter.getName();
      if (PageComponentInfo.parse(parameterName) == null) {
        parameters.add(parameterName, parameter.getValue());
      }
    }
    return parameters;
  }