Author: ehillenius
Date: Tue Jan  9 15:05:50 2007
New Revision: 494645

URL: http://svn.apache.org/viewvc?view=rev&rev=494645
Log:
fix to let coding strat take page map into account

Modified:
    
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java

Modified: 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java?view=diff&rev=494645&r1=494644&r2=494645
==============================================================================
--- 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java
 (original)
+++ 
incubator/wicket/branches/wicket-1.x/wicket/src/main/java/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java
 Tue Jan  9 15:05:50 2007
@@ -14,117 +14,125 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package wicket.request.target.component;
-
-import wicket.Component;
-import wicket.Page;
-import wicket.PageParameters;
-import wicket.RequestCycle;
-import wicket.RequestListenerInterface;
-import wicket.protocol.http.request.WebRequestCodingStrategy;
-import wicket.util.string.AppendingStringBuffer;
-import wicket.util.string.Strings;
-
-/**
- * Request target for bookmarkable page links that also contain component path
- * and interface name. This is used for stateless forms and stateless links.
- * 
- * @author Matej Knopp
- */
-public class BookmarkableListenerInterfaceRequestTarget extends 
BookmarkablePageRequestTarget
-{
-       private String componentPath;
-       private String interfaceName;
-
-       /**
-        * This constructor is called when a stateless link is clicked on but 
the page
-        * wasn't found in the session. Then this class will recreate the page 
and call
-        * the interface method on the component that is targetted with the 
component path.
-        * 
-        * @param pageMapName
-        * @param pageClass
-        * @param pageParameters
-        * @param componentPath
-        * @param interfaceName
-        */
-       public BookmarkableListenerInterfaceRequestTarget(String pageMapName,
-                       Class pageClass, PageParameters pageParameters, String 
componentPath,
-                       String interfaceName)
-       {
-               super(pageMapName, pageClass, pageParameters);
-               this.componentPath = componentPath;
-               this.interfaceName = interfaceName;
-       }
-
-       /**
-        * This constructor is called for generating the urls 
(RequestCycle.urlFor())
-        * So it will alter the PageParameters to include the 2 wicket params
-        * [EMAIL PROTECTED] 
WebRequestCodingStrategy#BOOKMARKABLE_PAGE_PARAMETER_NAME} and
-        * [EMAIL PROTECTED] WebRequestCodingStrategy#INTERFACE_PARAMETER_NAME}
-        * 
-        * @param pageMapName
-        * @param pageClass
-        * @param pageParameters
-        * @param component
-        * @param listenerInterface
-        */
-       public BookmarkableListenerInterfaceRequestTarget(String pageMapName,
-                       Class pageClass, PageParameters pageParameters, 
Component component,
-                       RequestListenerInterface listenerInterface)
-       {
-               this(pageMapName, pageClass, pageParameters, 
component.getPath(),
-                               listenerInterface.getName());
-               
-               int version = component.getPage().getCurrentVersionNumber();
-
-               // add the wicket:interface param to the params.
-               AppendingStringBuffer param = new AppendingStringBuffer(3 + 
componentPath.length() + interfaceName.length());
-               if(pageMapName != null)
-               {
-                       param.append(pageMapName);
-               }
-               param.append(Component.PATH_SEPARATOR);
-               param.append(getComponentPath());
-               param.append(Component.PATH_SEPARATOR);
-               if(version != 0)
-               {
-                       param.append(version);
-               }
-               param.append(Component.PATH_SEPARATOR);
-               param.append(getInterfaceName());
-               
-               
pageParameters.put(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME,param.toString());
-       }
-
-       public void processEvents(RequestCycle requestCycle)
-       {
-               Page page = getPage(requestCycle);
-               final String pageRelativeComponentPath = 
Strings.afterFirstPathComponent(componentPath,
-                               Component.PATH_SEPARATOR);
-               Component component = page.get(pageRelativeComponentPath);
-               RequestListenerInterface listenerInterface = 
RequestListenerInterface
-                               .forName(interfaceName);
-               listenerInterface.invoke(page, component);
-       }
-
-       public void respond(RequestCycle requestCycle)
-       {
-               getPage(requestCycle).renderPage();
-       }
-
-       /**
-        * @return The component path.
-        */
-       public String getComponentPath()
-       {
-               return componentPath;
-       }
-
-       /**
-        * @return The interface name
-        */
-       public String getInterfaceName()
-       {
-               return interfaceName;
-       }
-}
+package wicket.request.target.component;
+
+import wicket.Component;
+import wicket.Page;
+import wicket.PageParameters;
+import wicket.RequestCycle;
+import wicket.RequestListenerInterface;
+import wicket.WicketRuntimeException;
+import wicket.protocol.http.request.WebRequestCodingStrategy;
+import wicket.util.string.AppendingStringBuffer;
+import wicket.util.string.Strings;
+
+/**
+ * Request target for bookmarkable page links that also contain component path
+ * and interface name. This is used for stateless forms and stateless links.
+ * 
+ * @author Matej Knopp
+ */
+public class BookmarkableListenerInterfaceRequestTarget extends 
BookmarkablePageRequestTarget
+{
+       private String componentPath;
+       private String interfaceName;
+
+       /**
+        * This constructor is called when a stateless link is clicked on but 
the
+        * page wasn't found in the session. Then this class will recreate the 
page
+        * and call the interface method on the component that is targetted 
with the
+        * component path.
+        * 
+        * @param pageMapName
+        * @param pageClass
+        * @param pageParameters
+        * @param componentPath
+        * @param interfaceName
+        */
+       public BookmarkableListenerInterfaceRequestTarget(String pageMapName, 
Class pageClass,
+                       PageParameters pageParameters, String componentPath, 
String interfaceName)
+       {
+               super(pageMapName, pageClass, pageParameters);
+               this.componentPath = componentPath;
+               this.interfaceName = interfaceName;
+       }
+
+       /**
+        * This constructor is called for generating the urls
+        * (RequestCycle.urlFor()) So it will alter the PageParameters to 
include
+        * the 2 wicket params
+        * [EMAIL PROTECTED] 
WebRequestCodingStrategy#BOOKMARKABLE_PAGE_PARAMETER_NAME} and
+        * [EMAIL PROTECTED] WebRequestCodingStrategy#INTERFACE_PARAMETER_NAME}
+        * 
+        * @param pageMapName
+        * @param pageClass
+        * @param pageParameters
+        * @param component
+        * @param listenerInterface
+        */
+       public BookmarkableListenerInterfaceRequestTarget(String pageMapName, 
Class pageClass,
+                       PageParameters pageParameters, Component component,
+                       RequestListenerInterface listenerInterface)
+       {
+               this(pageMapName, pageClass, pageParameters, 
component.getPath(), listenerInterface
+                               .getName());
+
+               int version = component.getPage().getCurrentVersionNumber();
+
+               // add the wicket:interface param to the params.
+               AppendingStringBuffer param = new AppendingStringBuffer(3 + 
componentPath.length()
+                               + interfaceName.length());
+               if (pageMapName != null)
+               {
+                       param.append(pageMapName);
+               }
+               param.append(Component.PATH_SEPARATOR);
+               param.append(getComponentPath());
+               param.append(Component.PATH_SEPARATOR);
+               if (version != 0)
+               {
+                       param.append(version);
+               }
+               param.append(Component.PATH_SEPARATOR);
+               param.append(getInterfaceName());
+
+               
pageParameters.put(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME, 
param.toString());
+       }
+
+       public void processEvents(RequestCycle requestCycle)
+       {
+               Page page = getPage(requestCycle);
+               final String pageRelativeComponentPath = 
Strings.afterFirstPathComponent(componentPath,
+                               Component.PATH_SEPARATOR);
+               Component component = page.get(pageRelativeComponentPath);
+               if (component == null)
+               {
+                       throw new WicketRuntimeException("unable to find 
component with path "
+                                       + pageRelativeComponentPath + " on page 
" + page);
+               }
+               RequestListenerInterface listenerInterface = 
RequestListenerInterface
+                               .forName(interfaceName);
+               listenerInterface.invoke(page, component);
+       }
+
+       public void respond(RequestCycle requestCycle)
+       {
+               getPage(requestCycle).renderPage();
+       }
+
+       /**
+        * @return The component path.
+        */
+       public String getComponentPath()
+       {
+               return componentPath;
+       }
+
+       /**
+        * @return The interface name
+        */
+       public String getInterfaceName()
+       {
+               return interfaceName;
+       }
+}


Reply via email to