Search in sources :

Example 96 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class PropertyEditor method beginRender.

/**
 * Returns a Block for rendering the property. The Block will be able to access the {@link PropertyEditContext} via
 * the {@link Environmental} annotation.
 */
Block beginRender() {
    Block override = overrides.getOverrideBlock(propertyModel.getId());
    if (override != null) {
        return override;
    }
    String dataType = propertyModel.getDataType();
    if (dataType == null)
        throw new RuntimeException(String.format("The data type for property '%s' of %s is null.", propertyModel.getPropertyName(), object));
    try {
        return beanBlockSource.getEditBlock(dataType);
    } catch (RuntimeException ex) {
        String message = messages.format("core-block-error", propertyModel.getPropertyName(), dataType, object, ex);
        throw new TapestryException(message, resources.getLocation(), ex);
    }
}
Also used : TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException)

Example 97 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class AbstractComponentEventLink method beginRender.

void beginRender(MarkupWriter writer) {
    if (isDisabled())
        return;
    Link link = createLink(context);
    writeLink(writer, link);
    writer.attributes("data-update-zone", zone);
    if (async) {
        javaScriptSupport.require("t5/core/zone");
        writer.attributes("data-async-trigger", true);
    }
}
Also used : Link(org.apache.tapestry5.http.Link)

Example 98 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class AbstractConditional method beginRender.

/**
 * Returns null if the {@link #test()} is true, which allows normal rendering (of the body). If the test parameter
 * is false, returns the else parameter (this may also be null).
 */
Object beginRender(MarkupWriter writer) {
    boolean enabled = test();
    Block toRender = enabled ? (thenBlock == null ? resources.getBody() : thenBlock) : elseBlock;
    String elementName = resources.getElementName();
    if (enabled && elementName != null) {
        renderTag = true;
        writer.element(elementName);
        resources.renderInformalParameters(writer);
    }
    return toRender;
}
Also used : Block(org.apache.tapestry5.Block)

Example 99 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class AjaxFormLoop method setupRender.

void setupRender(MarkupWriter writer) {
    pushContext();
    iterator = source == null ? Collections.EMPTY_LIST.iterator() : source.iterator();
    Link removeRowLink = resources.createEventLink("triggerRemoveRow", context);
    Link injectRowLink = resources.createEventLink("injectRow", context);
    injectRowLink.addParameter(RequestConstants.FORM_CLIENTID_PARAMETER, formSupport.getClientId());
    injectRowLink.addParameter(RequestConstants.FORM_COMPONENTID_PARAMETER, formSupport.getFormComponentId());
    // Fix for TAP5-227 - AjaxFormLoop dont work well inside a table tag
    Element element = writer.getElement();
    this.wrapper = element.getAttribute("data-container-type") != null || element.getAttribute("data-remove-row-url") != null || element.getAttribute("data-inject-row-url") != null ? writer.element("div") : null;
    writer.attributes("data-container-type", "core/AjaxFormLoop", "data-remove-row-url", removeRowLink, "data-inject-row-url", injectRowLink);
}
Also used : Element(org.apache.tapestry5.dom.Element) Link(org.apache.tapestry5.http.Link)

Example 100 with Link

use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.

the class Select method beginRender.

void beginRender(MarkupWriter writer) {
    writer.element("select", "name", getControlName(), "id", getClientId(), "class", cssClass);
    putPropertyNameIntoBeanValidationContext("value");
    validate.render(writer);
    removePropertyNameFromBeanValidationContext();
    resources.renderInformalParameters(writer);
    decorateInsideField();
    if (this.zone != null) {
        javaScriptSupport.require("t5/core/select");
        Link link = resources.createEventLink(CHANGE_EVENT, context);
        writer.attributes("data-update-zone", zone, "data-update-url", link);
    }
}
Also used : Link(org.apache.tapestry5.http.Link)

Aggregations

Link (org.apache.tapestry5.http.Link)66 Test (org.testng.annotations.Test)37 Response (org.apache.tapestry5.http.services.Response)19 MarkupWriter (org.apache.tapestry5.MarkupWriter)10 JSONObject (org.apache.tapestry5.json.JSONObject)10 ComponentEventLinkEncoder (org.apache.tapestry5.services.ComponentEventLinkEncoder)10 Request (org.apache.tapestry5.http.services.Request)8 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)8 Element (org.apache.tapestry5.dom.Element)7 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)7 Link (org.apache.tapestry5.Link)6 LinkCreationListener2 (org.apache.tapestry5.services.LinkCreationListener2)6 EventContext (org.apache.tapestry5.EventContext)5 ComponentClassResolver (org.apache.tapestry5.services.ComponentClassResolver)5 IOException (java.io.IOException)4 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)4 BaseURLSource (org.apache.tapestry5.http.services.BaseURLSource)4 Page (org.apache.tapestry5.internal.structure.Page)4 List (java.util.List)3 ComponentResources (org.apache.tapestry5.ComponentResources)3