use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.
the class RequestSecurityManagerImpl method checkForInsecurePageRenderRequest.
public boolean checkForInsecurePageRenderRequest(PageRenderRequestParameters parameters) throws IOException {
if (!needsRedirect(parameters.getLogicalPageName()))
return false;
// Page is secure but request is not, so redirect.
Link link = componentEventLinkEncoder.createPageRenderLink(parameters);
response.sendRedirect(link);
return true;
}
use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.
the class RenderCommandComponentEventResultProcessor method renderMarkup.
/**
* As a filter, this class does three things:
* <ul>
* <li>It creates an outer element to capture the partial page content that will be rendered</li>
* <li>It does setup and cleanup with the {@link AjaxFormUpdateController}</li>
* <li>It extracts the child markup and stuffs it into the reply's "content" property.</li>
* </ul>
*/
public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer) {
// The partial will quite often contain multiple elements (or just a block of plain text),
// so those must be enclosed in a root element.
Element root = writer.element("ajax-partial");
ajaxFormUpdateController.setupBeforePartialZoneRender(writer);
renderer.renderMarkup(writer, reply);
ajaxFormUpdateController.cleanupAfterPartialZoneRender();
writer.end();
String content = root.getChildMarkup().trim();
reply.put("content", content);
}
use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.
the class ClientPersistentFieldStorageImplTest method null_value_is_a_remove.
@Test
public void null_value_is_a_remove() {
Request request = mockRequest(null);
Link link = mockLink();
String pageName = "Foo";
String componentId = "bar.baz";
String fieldName = "woops";
replay();
ClientPersistentFieldStorage storage = new ClientPersistentFieldStorageImpl(request, clientDataEncoder, analyzer);
storage.postChange(pageName, componentId, fieldName, 99);
storage.postChange(pageName, componentId, fieldName, null);
storage.updateLink(link);
assertTrue(storage.gatherFieldChanges(pageName).isEmpty());
verify();
}
use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.
the class ClientPersistentFieldStorageImplTest method store_and_restore_a_change.
@SuppressWarnings("unchecked")
@Test
public void store_and_restore_a_change() {
Request request = mockRequest(null);
Link link = mockLink();
String pageName = "Foo";
String componentId = "bar.baz";
String fieldName = "biff";
Object value = 99;
final Holder<String> holder = captureLinkModification(link);
replay();
ClientPersistentFieldStorage storage1 = new ClientPersistentFieldStorageImpl(request, clientDataEncoder, analyzer);
storage1.postChange(pageName, componentId, fieldName, value);
List<PersistentFieldChange> changes1 = newList(storage1.gatherFieldChanges(pageName));
storage1.updateLink(link);
verify();
assertEquals(changes1.size(), 1);
PersistentFieldChange change1 = changes1.get(0);
assertEquals(change1.getComponentId(), componentId);
assertEquals(change1.getFieldName(), fieldName);
assertEquals(change1.getValue(), value);
// Now more training ...
train_getParameter(request, ClientPersistentFieldStorageImpl.PARAMETER_NAME, holder.get());
replay();
ClientPersistentFieldStorage storage2 = new ClientPersistentFieldStorageImpl(request, clientDataEncoder, analyzer);
List<PersistentFieldChange> changes2 = newList(storage2.gatherFieldChanges(pageName));
verify();
assertEquals(changes2.size(), 1);
PersistentFieldChange change2 = changes2.get(0);
assertEquals(change2.getComponentId(), componentId);
assertEquals(change2.getFieldName(), fieldName);
assertEquals(change2.getValue(), value);
assertNotSame(change1, change2);
}
use of org.apache.tapestry5.http.Link 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();
}
Aggregations