Author: pete.muir(a)jboss.org
Date: 2008-09-21 17:00:08 -0400 (Sun, 21 Sep 2008)
New Revision: 9072
Modified:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBookingAction.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java
trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java
trunk/src/wicket/org/jboss/seam/wicket/WicketManager.java
trunk/src/wicket/org/jboss/seam/wicket/web/WicketRedirectFilter.java
Log:
JBSEAM-2992
Modified:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBookingAction.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBookingAction.java 2008-09-21
20:57:08 UTC (rev 9071)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBookingAction.java 2008-09-21
21:00:08 UTC (rev 9072)
@@ -48,6 +48,7 @@
public void selectHotel(Hotel hotel)
{
+ StatusMessages.instance().add("foo");
this.hotel = hotel;
}
@@ -89,7 +90,7 @@
public void confirm()
{
em.persist(booking);
- StatusMessages.instance().addToControl("body", "Thank you,
#{user.name}, your confimation number for #{hotel.name} is #{booking.id}");
+ StatusMessages.instance().add("Thank you, #{user.name}, your confimation
number for #{hotel.name} is #{booking.id}");
log.info("New booking: #{booking.id} for #{user.username}");
}
Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java 2008-09-21
20:57:08 UTC (rev 9071)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java 2008-09-21
21:00:08 UTC (rev 9072)
@@ -25,6 +25,7 @@
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
+import org.apache.wicket.feedback.ContainerFeedbackMessageFilter;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
@@ -33,6 +34,7 @@
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.model.PropertyModel;
@@ -78,7 +80,7 @@
hotelSearchForm = new HotelSearchForm("searchCriteria");
body.add(hotelSearchForm);
- messages = new ComponentFeedbackPanel("messages",
body).setOutputMarkupId(true);
+ messages = new FeedbackPanel("messages", new
ContainerFeedbackMessageFilter(this)).setOutputMarkupId(true);
body.add(messages);
/*
Modified: trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java 2008-09-21 20:57:08 UTC
(rev 9071)
+++ trunk/src/wicket/org/jboss/seam/wicket/SeamWebApplication.java 2008-09-21 21:00:08 UTC
(rev 9072)
@@ -77,24 +77,14 @@
IFormSubmitListener.INTERFACE.getName().equals(name) ||
ILinkListener.INTERFACE.getName().equals(name) ||
IBehaviorListener.INTERFACE.getName().equals(name) ||
- IOnChangeListener.INTERFACE.getName().equals(name) ))
+ IOnChangeListener.INTERFACE.getName().equals(name) ||
+ IRedirectListener.INTERFACE.getName().equals(name) ))
{
// TODO Do this nicely
StringBuilder stringBuilder = new StringBuilder(url);
stringBuilder.append("&" +
Manager.instance().getConversationIdParameter() + "=" +
Conversation.instance().getId());
url = stringBuilder.subSequence(0, stringBuilder.length());
}
- else if ( IRedirectListener.INTERFACE.getName().equals(name) )
- {
- if (!Manager.instance().isLongRunningConversation())
- {
- Manager.instance().beforeRedirect();
- }
-
- StringBuilder stringBuilder = new StringBuilder(url);
- stringBuilder.append("&" +
Manager.instance().getConversationIdParameter() + "=" +
Conversation.instance().getId());
- url = stringBuilder.subSequence(0, stringBuilder.length());
- }
return url;
}
Modified: trunk/src/wicket/org/jboss/seam/wicket/WicketManager.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/WicketManager.java 2008-09-21 20:57:08 UTC (rev
9071)
+++ trunk/src/wicket/org/jboss/seam/wicket/WicketManager.java 2008-09-21 21:00:08 UTC (rev
9072)
@@ -6,6 +6,7 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.core.ConversationPropagation;
import org.jboss.seam.core.Manager;
@Scope(ScopeType.EVENT)
@@ -15,32 +16,16 @@
public class WicketManager extends Manager
{
- private boolean controllingRedirect;
-
- public String appendConversationIdFromRedirectFilter(String url, String viewId)
+ public String appendConversationIdFromRedirectFilter(String url)
{
- boolean appendConversationId = !controllingRedirect;
- if (appendConversationId)
+ super.beforeRedirect();
+ if (ConversationPropagation.instance().getConversationId() != null)
{
- beforeRedirect(viewId);
- url = encodeConversationId(url, viewId);
+ url = encodeConversationIdParameter( url, getConversationIdParameter(),
ConversationPropagation.instance().getConversationId() );
}
return url;
}
- /**
- * Temporarily promote a temporary conversation to
- * a long running conversation for the duration of
- * a browser redirect. After the redirect, the
- * conversation will be demoted back to a temporary
- * conversation. Handle any changes to the conversation
- * id, due to propagation via natural id.
- */
- public void beforeRedirect(String viewId)
- {
- // TODO - do something here!
- }
-
public static WicketManager instance()
{
return (WicketManager) Manager.instance();
Modified: trunk/src/wicket/org/jboss/seam/wicket/web/WicketRedirectFilter.java
===================================================================
--- trunk/src/wicket/org/jboss/seam/wicket/web/WicketRedirectFilter.java 2008-09-21
20:57:08 UTC (rev 9071)
+++ trunk/src/wicket/org/jboss/seam/wicket/web/WicketRedirectFilter.java 2008-09-21
21:00:08 UTC (rev 9072)
@@ -2,6 +2,7 @@
import static org.jboss.seam.ScopeType.APPLICATION;
import static org.jboss.seam.annotations.Install.FRAMEWORK;
+import static org.jboss.seam.core.Manager.REDIRECT_FROM_MANAGER;
import java.io.IOException;
@@ -9,12 +10,17 @@
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.annotations.web.Filter;
+import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.web.AbstractFilter;
+import org.jboss.seam.wicket.WicketManager;
/**
* Disable the redirect filter when using Wicket (as JSF is an EE library, we
@@ -26,19 +32,32 @@
@Name("org.jboss.seam.web.redirectFilter")
@Install(precedence = FRAMEWORK,
classDependencies="org.apache.wicket.Application")
@BypassInterceptors
+@Filter
public class WicketRedirectFilter extends AbstractFilter
{
-
-
- @Override
- public boolean isDisabled()
+
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain) throws IOException, ServletException
{
- return true;
+ chain.doFilter( request, wrapResponse( (HttpServletResponse) response ) );
}
-
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException, ServletException
+
+ private static ServletResponse wrapResponse(HttpServletResponse response)
{
-
-
+ return new HttpServletResponseWrapper(response)
+ {
+ @Override
+ public void sendRedirect(String url) throws IOException
+ {
+ if ( Contexts.isEventContextActive() &&
!Contexts.getEventContext().isSet(REDIRECT_FROM_MANAGER) )
+ {
+ if ( Contexts.isConversationContextActive() )
+ {
+ url =
WicketManager.instance().appendConversationIdFromRedirectFilter(url);
+ }
+ }
+ super.sendRedirect(url);
+ }
+ };
}
}