Package org.apache.wicket.util.string

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


    final String style, final String variation)
  {
    String cacheKey = key;
    if (component != null)
    {
      AppendingStringBuffer buffer = new AppendingStringBuffer(200);
      buffer.append(key);

      Component cursor = component;
      while (cursor != null)
      {
        buffer.append("-").append(metaDatabase.id(cursor.getClass()));

        if (cursor instanceof Page)
        {
          break;
        }

        /*
         * only append component id if parent is not a repeater because (a) these ids are
         * irrelevant when generating resource cache keys (b) they cause a lot of redundant
         * keys to be generated
         */
        if (cursor.getParent() != null && !(cursor.getParent() instanceof AbstractRepeater))
        {
          buffer.append(":").append(cursor.getId());
        }

        cursor = cursor.getParent();
      }

      buffer.append("-").append(locale);
      buffer.append("-").append(style);
      buffer.append("-").append(variation);
      cacheKey = buffer.toString();
    }
    else
    {
      // locale is guaranteed to be != null
      cacheKey += "-" + locale.toString();
View Full Code Here


      {
        IRequestHandler handler = new ListenerInterfaceRequestHandler(
          new PageAndComponentProvider(getPage(), this), ILinkListener.INTERFACE);
        Url componentUrl = RequestCycle.get().mapUrlFor(handler);
        componentUrl.addQueryParameter("anticache", Math.random());
        return new AppendingStringBuffer("new Ajax.Updater('counter', '").append(
          componentUrl)
          .append("', {method:'get'}); return false;")
          .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

      {
        option = getLocalizer().getString("nullValid", this, "");
      }

      // The <option> tag buffer
      final AppendingStringBuffer buffer = new AppendingStringBuffer(64 + option.length());

      // Add option tag
      buffer.append("\n<option");

      // If null is selected, indicate that
      if ("".equals(selectedValue))
      {
        buffer.append(" selected=\"selected\"");
      }

      // Add body of option tag
      buffer.append(" value=\"\">").append(option).append("</option>");
      return buffer;
    }
    else
    {
      // Null is not valid. Is it selected anyway?
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.");
      }
      CharSequence pageUrl = null;
      RequestCycle requestCycle = RequestCycle.get();

      if (page.isPageStateless())
      {
        pageUrl = requestCycle.urlFor(page.getClass(), page.getPageParameters());
        appendAssignment(buffer, "settings.ie8_src", pageUrl);
      }
      else
      {
        IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page));

        pageUrl = requestCycle.urlFor(handler);
        String ie8_pageUrl = requestCycle.getUrlRenderer().renderRelativeUrl(
          requestCycle.mapUrlFor(handler));
        appendAssignment(buffer, "settings.ie8_src", ie8_pageUrl);
      }

      appendAssignment(buffer, "settings.src", pageUrl);
    }
    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);

    appendAssignment(buffer, "settings.unloadConfirmation", showUnloadConfirmation());

    // 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

    {
      renderer.setBaseUrl(oldBase);
    }

    Form<?> root = getRootForm();
    return new AppendingStringBuffer("document.getElementById('").append(
      root.getHiddenFieldId())
      .append("').value='")
      .append(url)
      .append("';document.getElementById('")
      .append(root.getMarkupId())
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(HIDDEN_DIV_START);

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

    // 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 = Wicket.bind(b.onclick, 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(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 queryString = (i > -1) ? url.substring(i + 1) : url;
        String[] params = Strings.split(queryString, '&');

        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

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.