use of org.apache.tapestry5.internal.services.ArrayEventContext in project tapestry-5 by apache.
the class LinkSourceImpl method createComponentEventLink.
public Link createComponentEventLink(Page page, String nestedId, String eventType, boolean forForm, Object... eventContext) {
assert page != null;
assert InternalUtils.isNonBlank(eventType);
Page activePage = pageRenderQueue.getRenderingPage();
// See TAPESTRY-2184
if (activePage == null)
activePage = page;
String activePageName = activePage.getName();
Object[] pageActivationContext = contextCollector.collectPageActivationContext(activePageName);
ComponentEventRequestParameters parameters = new ComponentEventRequestParameters(activePageName, page.getName(), toBlank(nestedId), eventType, new ArrayEventContext(typeCoercer, pageActivationContext), new ArrayEventContext(typeCoercer, eventContext));
Link link = linkEncoder.createComponentEventLink(parameters, forForm);
for (LinkCreationListener2 listener : listeners) listener.createdComponentEventLink(link, parameters);
return link;
}
use of org.apache.tapestry5.internal.services.ArrayEventContext in project tapestry-5 by apache.
the class AppPageRenderLinkTransformer method decodePageRenderRequest.
public PageRenderRequestParameters decodePageRenderRequest(Request request) {
String path = request.getPath();
String[] split = path.substring(1).split("/");
if (split.length == 1 && split[0].equals(""))
return null;
int pacx = 0;
String possibleLocaleName = split[0];
// Might be just the page activation context, or it might be locale then page
// activation context
boolean localeSpecified = localizationSetter.isSupportedLocaleName(possibleLocaleName);
if (localeSpecified) {
pacx++;
}
if (pacx >= split.length)
return null;
if (localeSpecified)
localizationSetter.setLocaleFromLocaleName(possibleLocaleName);
boolean isLoopback = request.getParameter(TapestryConstants.PAGE_LOOPBACK_PARAMETER_NAME) != null;
return new PageRenderRequestParameters("View", new ArrayEventContext(typeCoercer, split[pacx]), isLoopback);
}
use of org.apache.tapestry5.internal.services.ArrayEventContext in project tapestry-5 by apache.
the class StreamPageContentResultProcessor method processResultValue.
public void processResultValue(StreamPageContent value) throws IOException {
Class<?> pageClass = value.getPageClass();
Object[] activationContext = value.getPageActivationContext();
final String pageName = pageClass == null ? requestGlobals.getActivePageName() : resolver.resolvePageClassNameToPageName(pageClass.getName());
final EventContext context = activationContext == null ? new EmptyEventContext() : new ArrayEventContext(typeCoercer, activationContext);
if (value.isBypassActivation()) {
request.setAttribute(InternalConstants.BYPASS_ACTIVATION, true);
}
request.setAttribute(TapestryConstants.RESPONSE_RENDERER, new IOOperation<Void>() {
public Void perform() throws IOException {
handler.handle(new PageRenderRequestParameters(pageName, context, false));
return null;
}
});
}
use of org.apache.tapestry5.internal.services.ArrayEventContext in project tapestry-5 by apache.
the class ComponentEventLinkEncoderImplTest method index_stripped_off.
@Test
public void index_stripped_off() {
RequestSecurityManager manager = mockRequestSecurityManager();
Response response = mockResponse();
ContextPathEncoder contextPathEncoder = getService(ContextPathEncoder.class);
expect(manager.checkPageSecurity("admin/Index")).andReturn(LinkSecurity.INSECURE);
train_encodeURL(response, "/admin/abc", "MAGIC");
replay();
ComponentEventLinkEncoder encoder = new ComponentEventLinkEncoderImpl(null, contextPathEncoder, null, response, manager, null, null, false, "", "", null, null);
PageRenderRequestParameters parameters = new PageRenderRequestParameters("admin/Index", new ArrayEventContext(typeCoercer, "abc"));
Link link = encoder.createPageRenderLink(parameters);
assertEquals(link.toURI(), "MAGIC");
verify();
}
use of org.apache.tapestry5.internal.services.ArrayEventContext in project tapestry-5 by apache.
the class EventContextTests method array_event_context_to_strings.
@Test
public void array_event_context_to_strings() {
EventContext ec = new ArrayEventContext(typeCoercer, 1, 2.3);
assertEquals(ec.toStrings(), new String[] { "1", "2.3" });
}
Aggregations