Permalink
Browse files

Fix for AjaxFormLoop

  • Loading branch information...
1 parent 440d999 commit ec59e21df75a06561c77c37e1aca096e360843e3 @ffacon ffacon committed Oct 12, 2012
@@ -1,4 +1,4 @@
-// Copyright 2005 The Apache Software Foundation
+// Copyright 20012 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -186,8 +186,7 @@ public PortletApplicationInitializer build(
@InjectService("PipelineBuilder") PipelineBuilder builder) {
PortletApplicationInitializer terminator = new PortletApplicationInitializer() {
public void initializeApplication(PortletContext context) {
- initializer.initializeApplication(new PortletContextImpl(
- context));
+ initializer.initializeApplication(new PortletContextImpl(context));
}
};
@@ -213,13 +212,10 @@ public boolean service(ActionRequest request,
String pageName = pageResolver.resolve(request);
log.info("PORTLET ACTION REQUEST HANDLER for page " + pageName);
- Request portletRequest = PortletUtilities.buildPortlet(request,
- pageName, analyzer);
- Response portletResponse = new PortletResponseImpl(response,
- portletRequest);
+ Request portletRequest = PortletUtilities.buildPortlet(request,pageName, analyzer);
+ Response portletResponse = new PortletResponseImpl(response,portletRequest);
- requestGlobals.storeRequestResponse(portletRequest,
- portletResponse);
+ requestGlobals.storeRequestResponse(portletRequest, portletResponse);
portletRequestGlobals.store(request, response);
return handler.service(portletRequest, portletResponse);
@@ -255,22 +251,15 @@ public boolean service(RenderRequest request,
PortletConstants.LAST_ACTION_EXCEPTION) != null) {
pageName = exceptionPage;
Page page = pageCache.get(exceptionPage);
- ExceptionReporter rootComponent = (ExceptionReporter) page
- .getRootComponent();
- rootComponent.reportException((Throwable) request
- .getPortletSession().getAttribute(
- PortletConstants.LAST_ACTION_EXCEPTION));
- request.getPortletSession().removeAttribute(
- PortletConstants.LAST_ACTION_EXCEPTION);
+ ExceptionReporter rootComponent = (ExceptionReporter) page.getRootComponent();
+ rootComponent.reportException((Throwable) request.getPortletSession().getAttribute(PortletConstants.LAST_ACTION_EXCEPTION));
+ request.getPortletSession().removeAttribute(PortletConstants.LAST_ACTION_EXCEPTION);
}
- Request portletRequest = PortletUtilities.buildPortlet(request,
- pageName, analyzer);
- Response portletResponse = new PortletRenderResponseImpl(
- response);
+ Request portletRequest = PortletUtilities.buildPortlet(request, pageName, analyzer);
+ Response portletResponse = new PortletRenderResponseImpl(response);
- requestGlobals.storeRequestResponse(portletRequest,
- portletResponse);
+ requestGlobals.storeRequestResponse(portletRequest, portletResponse);
portletRequestGlobals.store(request, response);
return handler.service(portletRequest, portletResponse);
@@ -296,16 +285,12 @@ public boolean service(ResourceRequest request,
ResourceResponse response) throws IOException,
PortletException {
String pageName = pageResolver.resolve(request);
- log.info("PORTLET RESSOURCES REQUEST HANDLER for page "
- + pageName);
+ log.info("PORTLET RESSOURCES REQUEST HANDLER for page " + pageName);
- Request portletRequest = PortletUtilities.buildPortlet(request,
- pageName, analyzer);
- Response portletResponse = new PortletResourceResponseImpl(
- response);
+ Request portletRequest = PortletUtilities.buildPortlet(request, pageName, analyzer);
+ Response portletResponse = new PortletResourceResponseImpl( response);
- requestGlobals.storeRequestResponse(portletRequest,
- portletResponse);
+ requestGlobals.storeRequestResponse(portletRequest,portletResponse);
portletRequestGlobals.store(request, response);
return handler.service(portletRequest, portletResponse);
@@ -340,11 +325,9 @@ public boolean service(EventRequest request, EventResponse response)
pageName + ":" + request.getEvent().getName() + "/"
+ request.getEvent().getValue().toString(),
analyzer);
- Response portletResponse = new PortletResponseImpl(response,
- portletRequest);
+ Response portletResponse = new PortletResponseImpl(response,portletRequest);
- requestGlobals.storeRequestResponse(portletRequest,
- portletResponse);
+ requestGlobals.storeRequestResponse(portletRequest, portletResponse);
portletRequestGlobals.store(request, response);
return handler.service(portletRequest, portletResponse);
@@ -445,11 +428,9 @@ public void renderMarkup(MarkupWriter writer, JSONObject reply,
String namespace = "_" + uid;
- IdAllocator idAllocator = iaFactory
- .getNewPortletIdAllocator(namespace);
+ IdAllocator idAllocator = iaFactory.getNewPortletIdAllocator(namespace);
- DocumentLinker linker = environment
- .peekRequired(DocumentLinker.class);
+ DocumentLinker linker = environment.peekRequired(DocumentLinker.class);
JavaScriptSupportImpl support = new JavaScriptSupportImpl(
linker, javascriptStackSource,
@@ -520,8 +501,7 @@ public ComponentEventRequestHandler buildPortletComponentEventRequestHandler(
public ComponentEventResultProcessor buildPorletComponentEventResultProcessor(
Map<Class, ComponentEventResultProcessor> configuration,
StrategyBuilder strategyBuilder) {
- return constructComponentEventResultProcessor(configuration,
- strategyBuilder);
+ return constructComponentEventResultProcessor(configuration,strategyBuilder);
}
/**
@@ -532,20 +512,13 @@ public ComponentEventResultProcessor buildPorletComponentEventResultProcessor(
public void contributePorletComponentEventResultProcessor(
MappedConfiguration<Class, ComponentEventResultProcessor> configuration,
final PortletRequestGlobals portletGlobals) {
- configuration.addInstance(PortletRenderable.class,
- PortletActionResultProcessor.class);
- configuration.addInstance(Event.class,
- PortletEventResultProcessor.class);
- configuration.addInstance(StreamResponse.class,
- StreamResponseResultProcessor.class);
- configuration.addInstance(Class.class,
- PortletClassResultProcessor.class);
- configuration.addInstance(String.class,
- PortletPageNameComponentEventResultProcessor.class);
- configuration.addInstance(Component.class,
- PortletComponentInstanceEventResultProcessor.class);
- configuration.addInstance(PortalPage.class,
- PortalPageNameComponentEventResultProcessor.class);
+ configuration.addInstance(PortletRenderable.class,PortletActionResultProcessor.class);
+ configuration.addInstance(Event.class,PortletEventResultProcessor.class);
+ configuration.addInstance(StreamResponse.class, StreamResponseResultProcessor.class);
+ configuration.addInstance(Class.class,PortletClassResultProcessor.class);
+ configuration.addInstance(String.class,PortletPageNameComponentEventResultProcessor.class);
+ configuration.addInstance(Component.class,PortletComponentInstanceEventResultProcessor.class);
+ configuration.addInstance(PortalPage.class,PortalPageNameComponentEventResultProcessor.class);
/**
* Explicit redirect is done through URL
@@ -561,15 +534,12 @@ public void processResultValue(URL value) throws IOException {
new ComponentEventResultProcessor<Link>() {
public void processResultValue(Link value)
throws IOException {
- StateAwareResponse response = (StateAwareResponse) portletGlobals
- .getPortletResponse();
+ StateAwareResponse response = (StateAwareResponse) portletGlobals.getPortletResponse();
for (String name : value.getParameterNames()) {
response.setRenderParameter(name,
value.getParameterValue(name));
}
- response.setRenderParameter(
- PortletConstants.PORTLET_PAGE, PortletUtilities
- .stripQueryString(value.toURI()));
+ response.setRenderParameter(PortletConstants.PORTLET_PAGE, PortletUtilities.stripQueryString(value.toURI()));
}
});
@@ -694,52 +664,36 @@ public static void contributePortletResourceResponseIdentifier(
Configuration<DeclaredResourceResponseSender> configuration) {
// declare core component that will return resource response form ajax
// call
- configuration.add(new DeclaredResourceResponseSender(DateField.class
- .getName()));
- configuration.add(new DeclaredResourceResponseSender(FormInjector.class
- .getName()));
- configuration.add(new DeclaredResourceResponseSender(BeanEditForm.class
- .getName()));
+ configuration.add(new DeclaredResourceResponseSender(DateField.class.getName()));
+ configuration.add(new DeclaredResourceResponseSender(FormInjector.class.getName()));
+ configuration.add(new DeclaredResourceResponseSender(BeanEditForm.class.getName()));
// ajaxFormLoop
- DeclaredResourceResponseSender ajaxFormLoop = new DeclaredResourceResponseSender(
- AjaxFormLoop.class.getName());
- ajaxFormLoop.addEvent(EventConstants.ADD_ROW);
- ajaxFormLoop.addEvent(EventConstants.REMOVE_ROW);
+ DeclaredResourceResponseSender ajaxFormLoop = new DeclaredResourceResponseSender(
+ AjaxFormLoop.class.getName());
+ ajaxFormLoop.addEvent(EventConstants.ADD_ROW);
+ ajaxFormLoop.addEvent(EventConstants.REMOVE_ROW);
+ ajaxFormLoop.addEvent("triggerRemoveRow"); //See AjaxFormLoop.formLoopContext for more details
configuration.add(ajaxFormLoop);
// declare core mixin that will return resource response form ajax call
- configuration.add(new DeclaredResourceResponseSender(Autocomplete.class
- .getName(), true));
+ configuration.add(new DeclaredResourceResponseSender(Autocomplete.class.getName(), true));
// declare tapestry-jquery component that will return resource response
// form ajax call
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.components.AjaxUpload"));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.components.CarouselItem"));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.components.DataTable"));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.components.DialogAjaxLink"));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.components.InPlaceEditor"));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.components.ProgressiveDisplay"));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.components.RangeSlider"));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.components.Slider"));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.components.Tabs"));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.components.TwitterView"));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.components.AjaxUpload"));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.components.CarouselItem"));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.components.DataTable"));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.components.DialogAjaxLink"));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.components.InPlaceEditor"));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.components.ProgressiveDisplay"));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.components.RangeSlider"));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.components.Slider"));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.components.Tabs"));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.components.TwitterView"));
// declare tapestry-jquery mixin that will return resource response form
// ajax call
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.mixins.Autocomplete", true));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.mixins.ZoneDroppable", true));
- configuration.add(new DeclaredResourceResponseSender(
- "org.got5.tapestry5.jquery.mixins.ZoneRefresh", true));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.mixins.Autocomplete", true));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.mixins.ZoneDroppable", true));
+ configuration.add(new DeclaredResourceResponseSender("org.got5.tapestry5.jquery.mixins.ZoneRefresh", true));
// for page or mixin like org.got5.tapestry5.jquery.mixins.Bind you have
// to declare the full pagename
// and the eventname that should be treat as resource URL
@@ -758,10 +712,9 @@ public static void contributePortletResourceResponseIdentifier(
public void contributePersistentFieldManager(
MappedConfiguration<String, PersistentFieldStrategy> configuration,
@InjectService("PortletRequestGlobals") PortletRequestGlobals globals) {
- configuration.add(
- PortletPersistenceConstants.PORTLET_SESSION_APPLICATION_SCOPE,
+ configuration.add(PortletPersistenceConstants.PORTLET_SESSION_APPLICATION_SCOPE,
new PortletApplicationScopePersistentFieldStrategy(globals));
}
-}
+}
@@ -129,6 +129,24 @@
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
+<servlet-name>Grid</servlet-name>
+<servlet-class>org.apache.pluto.container.driver.PortletServlet</servlet-class>
+<init-param>
+<param-name>portlet-name</param-name>
+<param-value>Grid</param-value>
+</init-param>
+<load-on-startup>1</load-on-startup>
+</servlet>
+<servlet>
+<servlet-name>AjaxFormLoopExample</servlet-name>
+<servlet-class>org.apache.pluto.container.driver.PortletServlet</servlet-class>
+<init-param>
+<param-name>portlet-name</param-name>
+<param-value>AjaxFormLoopExample</param-value>
+</init-param>
+<load-on-startup>1</load-on-startup>
+</servlet>
+<servlet>
<servlet-name>AboutPortlet</servlet-name>
<servlet-class>org.apache.pluto.container.driver.PortletServlet</servlet-class>
<init-param>
@@ -198,6 +216,14 @@
<url-pattern>/PlutoInvoker/About</url-pattern>
</servlet-mapping>
<servlet-mapping>
+<servlet-name>Grid</servlet-name>
+<url-pattern>/PlutoInvoker/Grid</url-pattern>
+</servlet-mapping>
+<servlet-mapping>
+<servlet-name>AjaxFormLoopExample</servlet-name>
+<url-pattern>/PlutoInvoker/AjaxFormLoopExample</url-pattern>
+</servlet-mapping>
+<servlet-mapping>
<servlet-name>AboutPortlet</servlet-name>
<url-pattern>/PlutoInvoker/AboutPortlet</url-pattern>
</servlet-mapping>
@@ -128,6 +128,13 @@
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
+<servlet-class>org.apache.pluto.container.driver.PortletServlet</servlet-class>
+<init-param>
+<param-name>portlet-name</param-name>
+<param-value>Grid</param-value>
+</init-param>
+<load-on-startup>1</load-on-startup>
+</servlet>
<servlet>
<servlet-name>AboutPortlet</servlet-name>
<servlet-class>org.apache.pluto.container.driver.PortletServlet</servlet-class>
@@ -54,10 +54,12 @@ limitations under the License.
<page name="About" uri="/WEB-INF/themes/pluto-default-theme.jsp">
<portlet context="/tapestry5-portlet" name="About"/>
<portlet context="/tapestry5-portlet" name="EventReceiver"/>
+ <portlet context="/tapestry5-portlet" name="AjaxFormLoopExample"/>
</page>
<page name="Grid" uri="/WEB-INF/themes/pluto-default-theme.jsp">
<portlet context="/tapestry5-portlet" name="Grid"/>
<portlet context="/tapestry5-portlet" name="Grid"/>
+ <portlet context="/tapestry5-portlet" name="About"/>
</page>
</render-config>
@@ -82,6 +82,24 @@
<value>true</value>
</container-runtime-option>
</portlet>
+
+ <portlet>
+ <portlet-name>AjaxFormLoopExample</portlet-name>
+ <portlet-class>org.apache.tapestry5.portlet.ApplicationPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Tapestry Porlet AjaxFormLoop</title>
+ <short-title>T5 Portlet AjaxFormLoop</short-title>
+ <keywords>Portlet Tapestry AjaxFormLoop</keywords>
+ </portlet-info>
+ <container-runtime-option>
+ <name>javax.portlet.renderHeaders</name>
+ <value>true</value>
+ </container-runtime-option>
+ </portlet>
<portlet>
<description>AboutPortletDescription</description>
Oops, something went wrong.

0 comments on commit ec59e21

Please sign in to comment.