Search in sources :

Example 6 with Core

use of org.apache.tapestry5.services.Core in project tapestry-5 by apache.

the class GridPager method writePageLink.

private void writePageLink(MarkupWriter writer, int pageIndex) {
    if (pageIndex < 1 || pageIndex > maxPages)
        return;
    if (pageIndex <= lastIndex)
        return;
    final boolean isBootstrap4 = isBootstrap4();
    if (pageIndex != lastIndex + 1) {
        writer.element("li", "class", isBootstrap4 ? "disabled page-item" : "disabled");
        writer.element("a", "href", "#", "aria-disabled", "true");
        addClassAttributeToPageLinkIfNeeded(writer, isBootstrap4);
        writer.write(" ... ");
        writer.end();
        writer.end();
    }
    lastIndex = pageIndex;
    if (pageIndex == currentPage) {
        writer.element("li", "aria-current", "page", "class", isBootstrap4 ? "active page-item" : "active");
        writer.element("a", "href", "#", "aria-disabled", "true");
        addClassAttributeToPageLinkIfNeeded(writer, isBootstrap4);
        writer.write(Integer.toString(pageIndex));
        writer.end();
        writer.end();
        return;
    }
    writer.element("li");
    if (isBootstrap4) {
        writer.getElement().attribute("class", "page-item");
    }
    Link link = resources.createEventLink(EventConstants.ACTION, pageIndex);
    if (zone != null) {
        link.addParameter("t:inplace", "true");
    }
    writer.element("a", "href", link, "data-update-zone", zone, "title", messages.format("core-goto-page", pageIndex));
    addClassAttributeToPageLinkIfNeeded(writer, isBootstrap4);
    writer.write(Integer.toString(pageIndex));
    writer.end();
    // li
    writer.end();
}
Also used : Link(org.apache.tapestry5.http.Link)

Example 7 with Core

use of org.apache.tapestry5.services.Core in project tapestry-5 by apache.

the class Label method updateAttributes.

@HeartbeatDeferred
private void updateAttributes() {
    String fieldId = field.getClientId();
    if (!productionMode && fieldId == null) {
        // TAP5-2500
        String warningText = "The Label component " + resources.getCompleteId() + " is linked to a Field that failed to return a clientId. The 'for' attibute will not be rendered.";
        javaScriptSupport.require("t5/core/console").invoke("warn").with(warningText);
    }
    String id = clientId != null ? clientId : javaScriptSupport.allocateClientId(fieldId + "-label");
    labelElement.attribute("id", id);
    labelElement.forceAttributes("for", fieldId);
    if (fieldId != null) {
        Element input = labelElement.getDocument().getElementById(field.getClientId());
        if (input != null) {
            input.attribute("aria-labelledby", id);
        }
    }
    decorator.insideLabel(field, labelElement);
}
Also used : Element(org.apache.tapestry5.dom.Element) HeartbeatDeferred(org.apache.tapestry5.annotations.HeartbeatDeferred)

Example 8 with Core

use of org.apache.tapestry5.services.Core in project tapestry-5 by apache.

the class Autocomplete method afterRender.

@Import(stylesheet = "typeahead-bootstrap3.css")
void afterRender() {
    Link link = resources.createEventLink(EVENT_NAME, context);
    JSONObject spec = new JSONObject("id", field.getClientId(), "url", link.toString()).put("minChars", minChars).put("limit", maxSuggestions);
    jsSupport.require("t5/core/autocomplete").with(spec);
}
Also used : JSONObject(org.apache.tapestry5.json.JSONObject) Link(org.apache.tapestry5.http.Link)

Example 9 with Core

use of org.apache.tapestry5.services.Core in project tapestry-5 by apache.

the class TriggerFragment method beginRender.

@HeartbeatDeferred
void beginRender() {
    String fragmentId = fragment.getClientId();
    if (fragmentId == null) {
        throw new IllegalStateException("The fragment has returned a null client-side ID");
    }
    JSONObject spec = new JSONObject("triggerId", container.getClientId(), "fragmentId", fragmentId);
    if (invert) {
        spec.put("invert", true);
    }
    javascriptSupport.require("t5/core/form-fragment").invoke("linkTrigger").with(spec);
}
Also used : JSONObject(org.apache.tapestry5.json.JSONObject) HeartbeatDeferred(org.apache.tapestry5.annotations.HeartbeatDeferred)

Example 10 with Core

use of org.apache.tapestry5.services.Core in project tapestry-5 by apache.

the class DashboardModule method defaultTabs.

@Contribute(DashboardManager.class)
public static void defaultTabs(OrderedConfiguration<DashboardTab> configuration) {
    configuration.add("Pages", new DashboardTab("Pages", "core/PageCatalog"));
    configuration.add("Services", new DashboardTab("Services", "core/ServiceStatus"));
    configuration.add("Libraries", new DashboardTab("ComponentLibraries", "core/ComponentLibraries"));
}
Also used : DashboardTab(org.apache.tapestry5.services.dashboard.DashboardTab) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Aggregations

Link (org.apache.tapestry5.http.Link)8 Element (org.apache.tapestry5.dom.Element)5 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)5 Resource (org.apache.tapestry5.commons.Resource)3 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)3 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Date (java.util.Date)2 ComponentResources (org.apache.tapestry5.ComponentResources)2 MarkupWriter (org.apache.tapestry5.MarkupWriter)2 PropertyOverrides (org.apache.tapestry5.PropertyOverrides)2 HeartbeatDeferred (org.apache.tapestry5.annotations.HeartbeatDeferred)2 Location (org.apache.tapestry5.commons.Location)2 ComponentActionSink (org.apache.tapestry5.corelib.internal.ComponentActionSink)2 MessageCatalogResource (org.apache.tapestry5.internal.util.MessageCatalogResource)2 JSONObject (org.apache.tapestry5.json.JSONObject)2 Heartbeat (org.apache.tapestry5.services.Heartbeat)2 EOFException (java.io.EOFException)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectStreamException (java.io.ObjectStreamException)1