Package org.apache.wicket.util.string

Examples of org.apache.wicket.util.string.AppendingStringBuffer


    {
      // get the hidden field id
      String nameAndId = getHiddenFieldId();

      // render the hidden field
      AppendingStringBuffer buffer = new AppendingStringBuffer(HIDDEN_DIV_START).append(
        "<input type=\"hidden\" name=\"")
        .append(nameAndId)
        .append("\" id=\"")
        .append(nameAndId)
        .append("\" />");

      // if it's a get, did put the parameters in the action attribute,
      // and have to write the url parameters as hidden fields
      if (encodeUrlInHiddenFields())
      {
        String url = getActionUrl().toString();
        int i = url.indexOf('?');
        String[] params = ((i > -1) ? url.substring(i + 1) : url).split("&");

        writeParamsAsHiddenFields(params, buffer);
      }
      buffer.append("</div>");
      getResponse().write(buffer);

      // if a default submitting component was set, handle the rendering of that
      if (defaultSubmittingComponent instanceof Component)
      {
View Full Code Here


   *            the Ajax {@link Response} body
   * @return filtered response
   */
  private AppendingStringBuffer invokeResponseFilters(final StringResponse contentResponse)
  {
    AppendingStringBuffer responseBuffer = new AppendingStringBuffer(
      contentResponse.getBuffer());

    List<IResponseFilter> responseFilters = Application.get()
      .getRequestCycleSettings()
      .getResponseFilters();
View Full Code Here

   *
   * @return javascript that opens the window
   */
  protected final String getWindowOpenJavaScript()
  {
    AppendingStringBuffer buffer = new AppendingStringBuffer(500);

    if (isCustomComponent() == true)
    {
      buffer.append("var element = document.getElementById(\"");
      buffer.append(getContentMarkupId());
      buffer.append("\");\n");
    }

    buffer.append("var settings = new Object();\n");

    appendAssignment(buffer, "settings.minWidth", getMinimalWidth());
    appendAssignment(buffer, "settings.minHeight", getMinimalHeight());
    appendAssignment(buffer, "settings.className", getCssClassName());
    appendAssignment(buffer, "settings.width", getInitialWidth());

    if ((isUseInitialHeight() == true) || (isCustomComponent() == false))
    {
      appendAssignment(buffer, "settings.height", getInitialHeight());
    }
    else
    {
      buffer.append("settings.height=null;\n");
    }

    appendAssignment(buffer, "settings.resizable", isResizable());

    if (isResizable() == false)
    {
      appendAssignment(buffer, "settings.widthUnit", getWidthUnit());
      appendAssignment(buffer, "settings.heightUnit", getHeightUnit());
    }

    if (isCustomComponent() == false)
    {
      Page page = createPage();
      if (page == null)
      {
        throw new WicketRuntimeException("Error creating page for modal dialog.");
      }

      IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page));
      appendAssignment(buffer, "settings.src", RequestCycle.get().urlFor(handler));
    }
    else
    {
      buffer.append("settings.element=element;\n");
    }

    if (getCookieName() != null)
    {
      appendAssignment(buffer, "settings.cookieId", getCookieName());
    }

    Object title = getTitle() != null ? getTitle().getObject() : null;
    if (title != null)
    {
      appendAssignment(buffer, "settings.title", escapeQuotes(title.toString()));
    }

    if (getMaskType() == MaskType.TRANSPARENT)
    {
      buffer.append("settings.mask=\"transparent\";\n");
    }
    else if (getMaskType() == MaskType.SEMI_TRANSPARENT)
    {
      buffer.append("settings.mask=\"semi-transparent\";\n");
    }

    appendAssignment(buffer, "settings.autoSize", autoSize);


    // set true if we set a windowclosedcallback
    boolean haveCloseCallback = false;

    // in case user is interested in window close callback or we have a pagemap to clean attach
    // notification request
    if (windowClosedCallback != null)
    {
      WindowClosedBehavior behavior = getBehaviors(WindowClosedBehavior.class).get(0);
      buffer.append("settings.onClose = function() { ");
      buffer.append(behavior.getCallbackScript());
      buffer.append(" };\n");

      haveCloseCallback = true;
    }

    // in case we didn't set windowclosecallback, we need at least callback on close button, to
    // close window property (thus cleaning the shown flag)
    if ((closeButtonCallback != null) || (haveCloseCallback == false))
    {
      CloseButtonBehavior behavior = getBehaviors(CloseButtonBehavior.class).get(0);
      buffer.append("settings.onCloseButton = function() { ");
      buffer.append(behavior.getCallbackScript());
      buffer.append("};\n");
    }

    postProcessSettings(buffer);

    buffer.append(getShowJavaScript());
    return buffer.toString();
  }
View Full Code Here

   * @return The javascript code that submits the form.
   */
  public final CharSequence getJsForInterfaceUrl(CharSequence url)
  {
    Form<?> root = getRootForm();
    return new AppendingStringBuffer("document.getElementById('").append(
      root.getHiddenFieldId()).append("').value='").append(url).append(
      "';document.getElementById('").append(root.getMarkupId()).append("').submit();");
  }
View Full Code Here

   */
  protected void appendDefaultButtonField(final MarkupStream markupStream,
    final ComponentTag openTag)
  {

    AppendingStringBuffer buffer = new AppendingStringBuffer();

    // div that is not visible (but not display:none either)
    buffer.append("<div style=\"width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden\">");

    // add an empty textfield (otherwise IE doesn't work)
    buffer.append("<input type=\"text\" autocomplete=\"false\"/>");

    // add the submitting component
    final Component submittingComponent = (Component)defaultSubmittingComponent;
    buffer.append("<input type=\"submit\" name=\"");
    buffer.append(defaultSubmittingComponent.getInputName());
    buffer.append("\" onclick=\" var b=document.getElementById('");
    buffer.append(submittingComponent.getMarkupId());
    buffer.append("'); if (b!=null&amp;&amp;b.onclick!=null&amp;&amp;typeof(b.onclick) != 'undefined') {  var r = b.onclick.bind(b)(); if (r != false) b.click(); } else { b.click(); };  return false;\" ");
    buffer.append(" />");

    // close div
    buffer.append("</div>");

    getResponse().write(buffer);
  }
View Full Code Here

    {
      // get the hidden field id
      String nameAndId = getHiddenFieldId();

      // render the hidden field
      AppendingStringBuffer buffer = new AppendingStringBuffer(
        "<div style=\"display:none\"><input type=\"hidden\" name=\"").append(nameAndId)
        .append("\" id=\"")
        .append(nameAndId)
        .append("\" />");

      // if it's a get, did put the parameters in the action attribute,
      // and have to write the url parameters as hidden fields
      if (encodeUrlInHiddenFields())
      {
        String url = urlFor(IFormSubmitListener.INTERFACE).toString();
        int i = url.indexOf('?');
        String[] params = ((i > -1) ? url.substring(i + 1) : url).split("&");

        writeParamsAsHiddenFields(params, buffer);
      }
      buffer.append("</div>");
      getResponse().write(buffer);

      // if a default submitting component was set, handle the rendering of that
      if (defaultSubmittingComponent instanceof Component)
      {
View Full Code Here

   *            True, if only the markup shall be returned
   * @return String
   */
  public final String toString(final boolean markupOnly)
  {
    final AppendingStringBuffer buf = new AppendingStringBuffer(400);

    if (markupOnly == false)
    {
      if (markupResourceStream != null)
      {
        buf.append(markupResourceStream.toString());
      }
      else
      {
        buf.append("null MarkupResouceStream");
      }
      buf.append("\n");
    }

    if (markupElements != null)
    {
      for (MarkupElement markupElement : markupElements)
      {
        buf.append(markupElement);
      }
    }

    return buf.toString();
  }
View Full Code Here

    return toString(false);
  }

  public String toString(boolean markupOnly)
  {
    final AppendingStringBuffer buf = new AppendingStringBuffer(400);
    if (markupOnly == false)
    {
      buf.append(getRootMarkup().getMarkupResourceStream().toString());
      buf.append("\n");
    }

    for (int i = 0; i < size(); i++)
    {
      buf.append(get(i));
    }
    return buf.toString();
  }
View Full Code Here

   * @param contentResponse
   *            the Ajax {@link Response} body
   */
  private void invokeResponseFilters(final StringResponse contentResponse)
  {
    AppendingStringBuffer responseBuffer = new AppendingStringBuffer(
      contentResponse.getBuffer());

    List<IResponseFilter> responseFilters = Application.get()
      .getRequestCycleSettings()
      .getResponseFilters();
View Full Code Here

  }

  protected final AppendingStringBuffer createLogString(RequestData rd, SessionData sd,
    boolean includeRuntimeInfo)
  {
    AppendingStringBuffer asb = new AppendingStringBuffer(150);
    asb.append("time=");
    asb.append(rd.getTimeTaken());
    asb.append(",event=");
    asb.append(rd.getEventTarget());
    asb.append(",response=");
    asb.append(rd.getResponseTarget());
    if (rd.getSessionInfo() != null && !rd.getSessionInfo().equals(""))
    {
      asb.append(",sessioninfo=");
      asb.append(rd.getSessionInfo());
    }
    else
    {
      asb.append(",sessionid=");
      asb.append(rd.getSessionId());
    }
    asb.append(",sessionsize=");
    asb.append(rd.getSessionSize());
    if (sd != null)
    {
      asb.append(",sessionstart=");
      asb.append(sd.getStartDate());
      asb.append(",requests=");
      asb.append(sd.getNumberOfRequests());
      asb.append(",totaltime=");
      asb.append(sd.getTotalTimeTaken());
    }
    asb.append(",activerequests=");
    asb.append(rd.getActiveRequest());
    if (includeRuntimeInfo)
    {
      Runtime runtime = Runtime.getRuntime();
      long max = runtime.maxMemory() / 1000000;
      long total = runtime.totalMemory() / 1000000;
      long used = total - runtime.freeMemory() / 1000000;
      asb.append(",maxmem=");
      asb.append(max);
      asb.append("M,total=");
      asb.append(total);
      asb.append("M,used=");
      asb.append(used);
      asb.append("M");
    }
    return asb;
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.string.AppendingStringBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.