Package org.apache.tapestry

Examples of org.apache.tapestry.IMarkupWriter


   
  protected void writeTag(IMarkupWriter writer, IRequestCycle cycle, String name)
  {
    boolean disabled = isDisabled();
   
    IMarkupWriter wrappedWriter;
   
    if (!disabled)
    {
          PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(
                  cycle,
                  this);
 
          // make sure the submit function is on the page (once)
          if (cycle.getAttribute(ATTRIBUTE_FUNCTION_NAME) == null)
          {
              pageRenderSupport
                      .addBodyScript("function submitLink(form, elementId) { form._linkSubmit.value = elementId; if (form.onsubmit == null || form.onsubmit()) form.submit(); }");
              cycle.setAttribute(ATTRIBUTE_FUNCTION_NAME, this);
          }
 
          IForm form = getForm(cycle);
          String formName = form.getName();

            // one hidden field per form:
          String formHiddenFieldAttributeName = ATTRIBUTE_FUNCTION_NAME + formName;
          if (cycle.getAttribute(formHiddenFieldAttributeName) == null)
          {
              writer.beginEmpty("input");
              writer.attribute("type", "hidden");
              writer.attribute("name", "_linkSubmit");
              cycle.setAttribute(formHiddenFieldAttributeName, this);
          }
       
        writer.begin("a");
        writer.attribute("href", "javascript:submitLink(document." + formName + ",\"" + name
                + "\");");
   
        // Allow the wrapped components a chance to render.
        // Along the way, they may interact with this component
        // and cause the name variable to get set.
        wrappedWriter = writer.getNestedWriter();
    }
    else
      wrappedWriter = writer;

        renderBody(wrappedWriter, cycle);

    if (!disabled)
    {
        // Generate additional attributes from informal parameters.   
        renderInformalParameters(writer, cycle);
   
        // Dump in HTML provided by wrapped components
        wrappedWriter.close();
   
        // Close the <a> tag
        writer.end();
    }
View Full Code Here


        // Convert the link's query parameters into a series of
        // hidden field values (that will be rendered later).

        addHiddenFieldsForLinkParameters(link);

        IMarkupWriter nested = _writer.getNestedWriter();

        _form.renderBody(nested, _cycle);

        runDeferredRunnables();
       
        writeTag(_writer, method, link.getURL(null, false));

        _writer.attribute("name", _form.getName());

        if (_encodingType != null)
            _writer.attribute("enctype", _encodingType);

        // Write out event handlers collected during the rendering.

        emitEventHandlers();

        informalParametersRenderer.render(_writer, _cycle);

        // Finish the <form> tag

        _writer.println();

        writeHiddenField(FORM_IDS, null, buildAllocatedIdList());
        writeHiddenFields();

        // Close the nested writer, inserting its contents.

        nested.close();

        // Close the <form> tag.

        _writer.end();
    }
View Full Code Here

    public void testNoField()
    {
        IValidationDelegate delegate = new MockDelegate();
        IForm form = newForm(delegate);
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle(form);

        replayControls();

        FieldLabel fl = (FieldLabel) _creator.newInstance(FieldLabel.class, new Object[]
View Full Code Here

    }

    public void testNoFieldOrDisplayName()
    {
        IForm form = newForm();
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle(form);
        Location l = newLocation();
        IBinding binding = newBinding(l);
        IPage page = newPage();
View Full Code Here

        IValidationDelegate delegate = new MockDelegate();

        MockControl formc = newControl(IForm.class);
        IForm form = (IForm) formc.getMock();

        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle(form);
        IFormComponent field = newField("MyLabel");
        Location l = newLocation();

        FieldLabel fl = (FieldLabel) _creator.newInstance(FieldLabel.class, new Object[]
View Full Code Here

    public void testNoDisplayNameInField()
    {
        MockControl formc = newControl(IForm.class);
        IForm form = (IForm) formc.getMock();

        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle(form);

        MockControl fieldc = newControl(IFormComponent.class);

        IFormComponent field = (IFormComponent) fieldc.getMock();
View Full Code Here

    public static final ILinkRenderer SHARED_INSTANCE = new DefaultLinkRenderer();

    public void renderLink(IMarkupWriter writer, IRequestCycle cycle, ILinkComponent linkComponent)
    {
        IMarkupWriter wrappedWriter = null;

        if (cycle.getAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME) != null)
            throw new ApplicationRuntimeException(Tapestry
                    .getMessage("AbstractLinkComponent.no-nesting"), linkComponent, null, null);

        cycle.setAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME, linkComponent);

        boolean hasBody = getHasBody();

        boolean disabled = linkComponent.isDisabled();

        if (!disabled)
        {
            ILink l = linkComponent.getLink(cycle);

            if (hasBody)
                writer.begin(getElement());
            else
                writer.beginEmpty(getElement());

            writer.attribute(getUrlAttribute(), constructURL(l, linkComponent.getAnchor(), cycle));

            String target = linkComponent.getTarget();

            if (HiveMind.isNonBlank(target))
                writer.attribute(getTargetAttribute(), target);

            beforeBodyRender(writer, cycle, linkComponent);

            // Allow the wrapped components a chance to render.
            // Along the way, they may interact with this component
            // and cause the name variable to get set.

            wrappedWriter = writer.getNestedWriter();
        }
        else
            wrappedWriter = writer;

        if (hasBody)
            linkComponent.renderBody(wrappedWriter, cycle);

        if (!disabled)
        {
            afterBodyRender(writer, cycle, linkComponent);

            linkComponent.renderAdditionalAttributes(writer, cycle);

            if (hasBody)
            {
                wrappedWriter.close();

                // Close the <element> tag

                writer.end();
            }
View Full Code Here

        writer.attribute("onclick", onclick);

        component.renderAdditionalAttributes(writer, cycle);

        IMarkupWriter wrappedWriter = writer.getNestedWriter();

        component.renderBody(wrappedWriter, cycle);

        wrappedWriter.close();

        writer.end();

        cycle.removeAttribute(Tapestry.LINK_COMPONENT_ATTRIBUTE_NAME);
    }
View Full Code Here

    protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
    {
        TapestryUtils.storePageRenderSupport(cycle, this);

        IMarkupWriter nested = writer.getNestedWriter();

        renderBody(nested, cycle);

        // Start the body tag.
        writer.println();
        writer.begin(getElement());
        renderInformalParameters(writer, cycle);

        writer.println();

        // Write the page's scripting. This is included scripts
        // and dynamic JavaScript.

        _pageRenderSupport.writeBodyScript(writer, cycle);

        // Close the nested writer, which dumps its buffered content
        // into its parent.

        nested.close();

        // Any initialization should go at the very end of the document
        // just before the close body tag. Older version of Tapestry
        // would create a window.onload event handler, but this is better
        // (it doesn't have to wait for external images to load).
View Full Code Here

            contentType.setParameter(ENCODING_KEY, encoding);
        }

        PrintWriter printWriter = _webResponse.getPrintWriter(contentType);

        IMarkupWriter writer = _markupWriterSource.newMarkupWriter(printWriter, contentType);

        cycle.renderPage(writer);

        writer.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.IMarkupWriter

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.