Search in sources :

Example 86 with Link

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

the class Element method getChildMarkup.

/**
 * @return the concatenation of the String representations {@link #toString()} of its children.
 */
public final String getChildMarkup() {
    PrintOutCollector collector = new PrintOutCollector();
    writeChildMarkup(getDocument(), collector.getPrintWriter(), null);
    return collector.getPrintOut();
}
Also used : PrintOutCollector(org.apache.tapestry5.internal.util.PrintOutCollector)

Example 87 with Link

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

the class Node method toString.

/**
 * Invokes {@link #toMarkup(PrintWriter)}, collecting output in a string, which is returned.
 */
@Override
public String toString() {
    PrintOutCollector collector = new PrintOutCollector();
    toMarkup(collector.getPrintWriter());
    return collector.getPrintOut();
}
Also used : PrintOutCollector(org.apache.tapestry5.internal.util.PrintOutCollector)

Example 88 with Link

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

the class AppComponentEventLinkTransformer method transformComponentEventLink.

public Link transformComponentEventLink(Link defaultLink, ComponentEventRequestParameters parameters) {
    Link link = defaultLink.copyWithBasePath("/event");
    for (String name : defaultLink.getParameterNames()) {
        link.removeParameter(name);
    }
    Locale locale = persistentLocale.get();
    if (locale != null) {
        link.addParameter("x:locale", locale.toString());
    }
    link.addParameter("x:type", parameters.getEventType());
    addEventContext(link, "x:ec", parameters.getEventContext());
    addEventContext(link, "x:pac", parameters.getPageActivationContext());
    link.addParameter("x:page", parameters.getActivePageName());
    link.addParameter("x:id", parameters.getNestedComponentId());
    if (!parameters.getActivePageName().equals(parameters.getContainingPageName()))
        link.addParameter("x:container", parameters.getContainingPageName());
    return link;
}
Also used : PersistentLocale(org.apache.tapestry5.services.PersistentLocale) Locale(java.util.Locale) Link(org.apache.tapestry5.http.Link)

Example 89 with Link

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

the class ActionLinkTest method click_link.

@Test
public void click_link() {
    tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
    Document doc = tester.renderPage("TestPageForActionLink");
    Element link = doc.getElementById("link1");
    doc = tester.clickLink(link);
    assertTrue(doc.toString().contains("You chose: 123"));
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) Element(org.apache.tapestry5.dom.Element) Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

Example 90 with Link

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

the class SaxTemplateParser method classicParameter.

/**
 * Handler for Tapestry 5.0's "classic" <t:parameter> element. This
 * turns into a {@link org.apache.tapestry5.internal.parser.ParameterToken}
 * and the body and end element are provided normally.
 */
private void classicParameter(TemplateParserState state) {
    String parameterName = getSingleParameter("name");
    if (InternalUtils.isBlank(parameterName))
        throw new TapestryException("The name attribute of the <parameter> element must be specified.", getLocation(), null);
    ensureParameterWithinComponent(state);
    tokenAccumulator.add(new ParameterToken(parameterName, getLocation()));
    processBody(state.insideComponent(false));
}
Also used : TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException)

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