Exemplo n.º 1
0
 /**
  * Extracts the {@link PageComponentInfo} from the URL. The {@link PageComponentInfo} is encoded
  * as the very first query parameter and the parameter consists of name only (no value).
  *
  * @param url
  * @return PageComponentInfo instance if one was encoded in URL, <code>null</code> otherwise.
  */
 protected PageComponentInfo getPageComponentInfo(final Url url) {
   if (url == null) {
     throw new IllegalStateException("Argument 'url' may not be null.");
   } else {
     for (QueryParameter queryParameter : url.getQueryParameters()) {
       if (Strings.isEmpty(queryParameter.getValue())) {
         PageComponentInfo pageComponentInfo = PageComponentInfo.parse(queryParameter.getName());
         if (pageComponentInfo != null) {
           return pageComponentInfo;
         }
       }
     }
   }
   return null;
 }
  /**
   * @see
   *     org.apache.wicket.request.mapper.parameter.IPageParametersEncoder#decodePageParameters(org.apache.wicket.request.Request)
   */
  public PageParameters decodePageParameters(final Request request) {
    PageParameters parameters = new PageParameters();

    int i = 0;
    for (String s : request.getUrl().getSegments()) {
      parameters.set(i, s);
      ++i;
    }

    for (QueryParameter p : request.getUrl().getQueryParameters()) {
      parameters.add(p.getName(), p.getValue());
    }

    return parameters.isEmpty() ? null : parameters;
  }
Exemplo n.º 3
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;
  }