public ComponentEventRequestParameters decodeComponentEventRequest(String requestPath) {
    Matcher matcher = COMPONENT_EVENT_REQUEST_PATH_PATTERN.matcher(requestPath);

    if (!matcher.matches()) return null;

    String nestedComponentId = matcher.group(NESTED_ID);

    String eventType = matcher.group(EVENT_NAME);

    if (nestedComponentId == null && eventType == null) return null;

    String activePageName = matcher.group(LOGICAL_PAGE_NAME);

    if (!componentClassResolver.isPageName(activePageName)) return null;

    activePageName = componentClassResolver.canonicalizePageName(activePageName);

    EventContext eventContext = new EmptyEventContext();
    // we first encode the value because the link is not built by tapestry and can contain
    // white spaces and other characters that need to be encoded.
    String context = matcher.group(CONTEXT);
    if (context != null) {
      String[] contextSplit = context.split("/");
      StringBuilder encodedContext = new StringBuilder();
      for (String contextToEncode : contextSplit) {
        encodedContext.append(contextPathEncoder.encodeValue(contextToEncode));
        encodedContext.append("/");
      }
      eventContext = contextPathEncoder.decodePath(encodedContext.toString());
    }

    EventContext activationContext = new EmptyEventContext();
    // .decodePath(request.getParameter(InternalConstants.PAGE_CONTEXT_NAME));

    // The event type is often omitted, and defaults to "action".

    if (eventType == null) eventType = EventConstants.ACTION;

    if (nestedComponentId == null) nestedComponentId = "";

    String containingPageName = activePageName;

    return new ComponentEventRequestParameters(
        activePageName,
        containingPageName,
        nestedComponentId,
        eventType,
        activationContext,
        eventContext);
  }
예제 #2
0
 protected final void train_canonicalizePageName(
     ComponentClassResolver resolver, String pageName, String canonicalized) {
   expect(resolver.canonicalizePageName(pageName)).andReturn(canonicalized);
 }