use of org.apache.tapestry5.services.PageRenderLinkSource in project flowlogix by flowlogix.
the class SessionTrackerUtil method redirectToSelf.
public static void redirectToSelf(RequestGlobals rg, PageRenderLinkSource linkSource) throws IOException {
final Link link = linkSource.createPageRenderLink(rg.getRequest().getPath().replaceFirst("\\..*", "").substring(1));
final String url = link.toAbsoluteURI(rg.getRequest().isSecure());
if (rg.getRequest().isXHR()) {
try (PrintWriter writer = rg.getResponse().getPrintWriter("application/json")) {
writer.write("{\n\t\"redirectURL\" : \"" + url + "\"\n}");
}
} else {
rg.getResponse().sendRedirect(url);
}
}
use of org.apache.tapestry5.services.PageRenderLinkSource in project tapestry-5 by apache.
the class PageRenderLinkSourceImplTest method override_passivate_context.
@Test
public void override_passivate_context() {
ComponentClassResolver resolver = mockComponentClassResolver();
LinkSource source = mockLinkSource();
Link link = mockLink();
EventContext eventContext = mockEventContext();
train_resolvePageClassNameToPageName(resolver, PAGE_CLASS.getName(), PAGE_NAME);
expect(source.createPageRenderLink(PAGE_NAME, true, "fred", "barney")).andReturn(link);
train_resolvePageClassNameToPageName(resolver, PAGE_CLASS.getName(), PAGE_NAME);
train_getCount(eventContext, 2);
train_get(eventContext, Object.class, 0, "ted");
train_get(eventContext, Object.class, 1, "barney");
expect(source.createPageRenderLink(PAGE_NAME, true, "ted", "barney")).andReturn(link);
replay();
PageRenderLinkSource service = new PageRenderLinkSourceImpl(source, resolver);
assertSame(service.createPageRenderLinkWithContext(PAGE_CLASS, "fred", "barney"), link);
assertSame(service.createPageRenderLinkWithContext(PAGE_CLASS, eventContext), link);
verify();
}
use of org.apache.tapestry5.services.PageRenderLinkSource in project tapestry-5 by apache.
the class PageRenderLinkSourceImplTest method default_passivate_context.
@Test
public void default_passivate_context() {
ComponentClassResolver resolver = mockComponentClassResolver();
LinkSource source = mockLinkSource();
Link link = mockLink();
train_resolvePageClassNameToPageName(resolver, PAGE_CLASS.getName(), PAGE_NAME);
expect(source.createPageRenderLink(PAGE_NAME, false)).andReturn(link);
replay();
PageRenderLinkSource service = new PageRenderLinkSourceImpl(source, resolver);
assertSame(service.createPageRenderLink(PAGE_CLASS), link);
verify();
}
use of org.apache.tapestry5.services.PageRenderLinkSource in project tapestry-5 by apache.
the class PageCallbackTest method callback_with_no_context.
@Test
public void callback_with_no_context() {
PageRenderLinkSource source = mockPageRenderLinkSource();
Link link = mockLink();
expect(source.createPageRenderLinkWithContext("foo")).andReturn(link);
PageCallback pc = new PageCallback("foo");
assertEquals(pc.toString(), "PageCallback[foo]");
replay();
assertSame(pc.toLink(source), link);
verify();
}
use of org.apache.tapestry5.services.PageRenderLinkSource in project tapestry-5 by apache.
the class PageCallbackTest method callback_with_context.
@Test
public void callback_with_context() {
EventContext context = new ArrayEventContext(typeCoercer, 1, 2);
PageRenderLinkSource source = mockPageRenderLinkSource();
Link link = mockLink();
expect(source.createPageRenderLinkWithContext("bar", "1", "2")).andReturn(link);
PageCallback pc = new PageCallback("bar", context);
assertEquals(pc.toString(), "PageCallback[bar 1/2]");
replay();
assertSame(pc.toLink(source), link);
verify();
}
Aggregations