/** test disable */
  @Test
  public void testDisable() {
    Page page = getTestPage();
    page.setEnabled(false);

    tester.startPage(page);

    Assert.assertTrue(tester.getLastResponse().getDocument().contains(MarkupConstants.READONLY));
  }
 /** @throws Exception */
 @Test
 public void formComponentFeedbackIndicator() throws Exception {
   Page page = tester.startPage(FeedbackIndicatorFormPage.class);
   tester.assertRenderedPage(FeedbackIndicatorFormPage.class);
   tester.assertResultPage(getClass(), "FeedbackIndicatorFormPage_result1.html");
   tester.executeListener(page.get("form"));
   tester.assertRenderedPage(FeedbackIndicatorFormPage.class);
   tester.assertResultPage(getClass(), "FeedbackIndicatorFormPage_result2.html");
 }
  public void onRequestHandlerResolved(RequestCycle cycle, IRequestHandler handler) {
    String cid = cycle.getRequest().getRequestParameters().getParameterValue("cid").toString();
    Page page = getPage(handler);

    if (cid == null && page != null) {
      cid = page.getMetaData(CID_KEY);
    }

    container.activateConversationalContext(cycle, cid);
  }
    @Override
    public Page createPage() {
      context.callingPageReference = context.getCallingPage().getPageReference();

      AssignableOrgSelectionPanel selectionPanel =
          new AssignableOrgSelectionPanel(
              AssignableOrgSelectionPage.ID_ASSIGNABLE_ORG_SELECTION_PANEL, context);

      Page page = new AssignableOrgSelectionPage(selectionPanel, context.getCallingPage());
      context.setModalWindowPageReference(page.getPageReference());

      selectionPanel.setType(context.getDefaultType());
      return page;
    }
  @Override
  public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler) {
    Conversation conversation = container.getCurrentConversation(cycle);

    if (conversation == null) {
      return;
    }

    // propagate a conversation across non-bookmarkable page instances

    Page page = getPage(handler);
    if (!conversation.isTransient() && page != null) {
      page.setMetaData(CID_KEY, conversation.getId());
    }
  }
Beispiel #6
0
 /**
  * Convenience method for setting next page to be rendered.
  *
  * @param page
  */
 public void setResponsePage(IRequestablePage page) {
   if (page instanceof Page) {
     ((Page) page).setStatelessHint(false);
   }
   scheduleRequestHandlerAfterCurrent(
       new RenderPageRequestHandler(
           new PageProvider(page), RenderPageRequestHandler.RedirectPolicy.AUTO_REDIRECT));
 }
  /**
   * @see
   *     org.apache.wicket.core.request.handler.IPageRequestHandler#respond(org.apache.wicket.request.IRequestCycle)
   */
  @Override
  public final void respond(final IRequestCycle requestCycle) {
    final RequestCycle rc = (RequestCycle) requestCycle;
    final WebResponse response = (WebResponse) requestCycle.getResponse();

    if (shouldRedirectToPage(requestCycle)) {
      // the page itself has been added to the request target, we simply issue a redirect
      // back to the page
      IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page));
      final String url = rc.urlFor(handler).toString();
      response.sendRedirect(url);
      return;
    }

    respondersFrozen = true;

    for (ITargetRespondListener listener : respondListeners) {
      listener.onTargetRespond(this);
    }

    final Application app = page.getApplication();

    page.send(app, Broadcast.BREADTH, this);

    // Determine encoding
    final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding();

    // Set content type based on markup type for page
    update.setContentType(response, encoding);

    // Make sure it is not cached by a client
    response.disableCaching();

    final StringResponse bodyResponse = new StringResponse();
    update.writeTo(bodyResponse, encoding);
    CharSequence filteredResponse = invokeResponseFilters(bodyResponse);
    response.write(filteredResponse);
  }
  public void onRequestHandlerScheduled(RequestCycle cycle, IRequestHandler handler) {
    Conversation conversation = container.getCurrentConversation(cycle);

    if (conversation == null || conversation.isTransient()) {
      return;
    }

    // propagate a converastion across non-bookmarkable page instances

    Page page = getPage(handler);
    if (page != null && !conversation.isTransient()) {
      page.setMetaData(CID_KEY, conversation.getId());
    }

    if (propagation == ConversationPropagation.ALL) {
      // propagate cid to a scheduled bookmarkable page

      PageParameters parameters = getPageParameters(handler);
      if (parameters != null) {
        parameters.add(CID, conversation.getId());
      }
    }
  }
 /** @return the markup id of the focused element in the browser */
 @Override
 public String getLastFocusedElementId() {
   WebRequest request = (WebRequest) page.getRequest();
   String id = request.getHeader("Wicket-FocusedElementId");
   return Strings.isEmpty(id) ? null : id;
 }
Beispiel #10
0
 /**
  * Search the FeedbackPanel on the given page.
  *
  * @param page
  * @return null or FeedbackPanel
  */
 public BricketFeedbackPanel getBricketFeedbackPanel(Page page) {
   return (BricketFeedbackPanel) page.visitChildren(new FeedbackPanelVisitor());
 }
Beispiel #11
0
 /** @see org.apache.wicket.markup.html.form.Form#onSubmit() */
 @Override
 public void onSubmit() {
   Page page = new SuccessPage();
   page.info(getString("book.save.success", new Model<Book>(book)));
   setResponsePage(page);
 }
 @Override
 public Class<? extends IRequestablePage> getPageClass() {
   return page.getPageClass();
 }
  @Override
  public boolean isActive() {

    Page responsePage = RequestCycle.get().getResponsePage();
    return responsePage.contains(getComponent(), true) && getComponent().isVisibleInHierarchy();
  }
  @Override
  protected void writeComponent(
      Response response, String markupId, Component component, String encoding) {
    if (component.getRenderBodyOnly() == true) {
      throw new IllegalStateException(
          "A partial update is not possible for a component that has renderBodyOnly enabled. Component: "
              + component.toString());
    }

    component.setOutputMarkupId(true);

    // Initialize temporary variables
    final Page page = component.findParent(Page.class);
    if (page == null) {
      // dont throw an exception but just ignore this component, somehow
      // it got removed from the page.
      LOG.warn(
          "Component '{}' with markupid: '{}' not rendered because it was already removed from page",
          component,
          markupId);
      return;
    }

    // substitute our encoding response for the old one so we can capture
    // component's markup in a manner safe for transport inside CDATA block
    Response oldResponse = RequestCycle.get().setResponse(bodyBuffer);

    try {
      bodyBuffer.reset();

      page.startComponentRender(component);

      try {
        component.prepareForRender();

        // render any associated headers of the component
        writeHeaderContribution(response, component);
      } catch (RuntimeException e) {
        try {
          component.afterRender();
        } catch (RuntimeException e2) {
          // ignore this one could be a result off.
        }
        bodyBuffer.reset();
        throw e;
      }

      try {
        component.render();
      } catch (RuntimeException e) {
        bodyBuffer.reset();
        throw e;
      }

      page.endComponentRender(component);
    } finally {
      // Restore original response
      RequestCycle.get().setResponse(oldResponse);
    }

    response.write("<component id=\"");
    response.write(markupId);
    response.write("\" ><![CDATA[");
    response.write(encode(bodyBuffer.getContents()));
    response.write("]]></component>");

    bodyBuffer.reset();
  }
 @Override
 public final Integer getRenderCount() {
   return page.getRenderCount();
 }
 @Override
 public PageParameters getPageParameters() {
   return page.getPageParameters();
 }
 @Override
 public Integer getPageId() {
   return page.getPageId();
 }