You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by gv...@apache.org on 2005/08/27 04:45:59 UTC

svn commit: r240380 - in /struts/shale/trunk/use-cases/src: java/org/apache/shale/usecases/rolodex/ test/org/apache/shale/usecases/rolodex/ web/WEB-INF/

Author: gvanmatre
Date: Fri Aug 26 19:45:41 2005
New Revision: 240380

URL: http://svn.apache.org/viewcvs?rev=240380&view=rev
Log:
Cleaned up some missing copyright's and minor refactoring.

Added:
    struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/QueryParam.java
Removed:
    struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/states.xml
Modified:
    struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Address.java
    struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Contact.java
    struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/GenericComparator.java
    struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Rolodex.java
    struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/RolodexDao.java
    struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/State.java
    struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/dex.xml
    struts/shale/trunk/use-cases/src/test/org/apache/shale/usecases/rolodex/RolodexTestCase.java
    struts/shale/trunk/use-cases/src/web/WEB-INF/clay-config.xml
    struts/shale/trunk/use-cases/src/web/WEB-INF/faces-config.xml

Modified: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Address.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Address.java?rev=240380&r1=240379&r2=240380&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Address.java (original)
+++ struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Address.java Fri Aug 26 19:45:41 2005
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2004-2005 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.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.shale.usecases.rolodex;
 
 /**

Modified: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Contact.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Contact.java?rev=240380&r1=240379&r2=240380&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Contact.java (original)
+++ struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Contact.java Fri Aug 26 19:45:41 2005
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2004-2005 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.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.shale.usecases.rolodex;
 
 import java.io.UnsupportedEncodingException;

Modified: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/GenericComparator.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/GenericComparator.java?rev=240380&r1=240379&r2=240380&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/GenericComparator.java (original)
+++ struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/GenericComparator.java Fri Aug 26 19:45:41 2005
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2004-2005 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.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.shale.usecases.rolodex;
 
 import java.util.ArrayList;

Added: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/QueryParam.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/QueryParam.java?rev=240380&view=auto
==============================================================================
--- struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/QueryParam.java (added)
+++ struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/QueryParam.java Fri Aug 26 19:45:41 2005
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2004-2005 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.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shale.usecases.rolodex;
+
+/**
+ * <p>This class simulates the classic struts FormBean.  The 
+ * request query parameter will be  populated via the managed 
+ * bean property setter injection.</p>
+ 
+ */
+public class QueryParam {
+
+    /**
+     * <p>Holds the value of the target tab index when 
+     * clicking on a tab, <code>"#{managed-bean-name.changeTab}"}</code>.
+     * </p>
+     */
+    private String tabIndex = null;
+    
+    /**
+     * <p>Holds the selected name when clicking on a contact,
+     * <code>"#{managed-bean-name.selectContact}"</code>.</p>
+     */    
+    private String selectedName = null;
+    
+
+    /**
+     * @return Returns the tabIndex.
+     */
+    public String getTabIndex() {
+        return tabIndex;
+    }
+    
+
+    /**
+     * @param tabIndex The tabIndex to set.
+     */
+    public void setTabIndex(String tabIndex) {
+        this.tabIndex = tabIndex;
+    }
+
+
+    /**
+     * @return Returns the selectedName.
+     */
+    public String getSelectedName() {
+        return selectedName;
+    }
+    
+
+    /**
+     * @param selectedName The selectedName to set.
+     */
+    public void setSelectedName(String selectedName) {
+        this.selectedName = selectedName;
+    }
+        
+}

Modified: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Rolodex.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Rolodex.java?rev=240380&r1=240379&r2=240380&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Rolodex.java (original)
+++ struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/Rolodex.java Fri Aug 26 19:45:41 2005
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2004-2005 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.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.shale.usecases.rolodex;
 
 import java.io.UnsupportedEncodingException;
@@ -247,8 +263,10 @@
             log.info("changeTab()");
 
         FacesContext context = FacesContext.getCurrentInstance();
-        Map requestMap = context.getExternalContext().getRequestParameterMap();
-        String tabIndex = (String) requestMap.get("tabIndex");
+        
+        QueryParam paramObj = (QueryParam) getBean("queryParam");
+        String tabIndex = paramObj.getTabIndex();
+        
         if (tabIndex != null) {
             setSelectedTab(Integer.parseInt(tabIndex));
 
@@ -344,8 +362,9 @@
         FacesContext context = FacesContext.getCurrentInstance();
 
         // look for the commandLink query parameter
-        Map requestMap = context.getExternalContext().getRequestParameterMap();
-        String name = (String) requestMap.get("selectedName");
+        QueryParam paramObj = (QueryParam) getBean("queryParam");
+        String name = paramObj.getSelectedName();
+        
         if (name != null) {
             // find the dao cached in application scope
             RolodexDao dao = (RolodexDao) getBean("rolodexDao");

Modified: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/RolodexDao.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/RolodexDao.java?rev=240380&r1=240379&r2=240380&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/RolodexDao.java (original)
+++ struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/RolodexDao.java Fri Aug 26 19:45:41 2005
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2004-2005 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.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.shale.usecases.rolodex;
 
 import java.io.IOException;

Modified: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/State.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/State.java?rev=240380&r1=240379&r2=240380&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/State.java (original)
+++ struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/State.java Fri Aug 26 19:45:41 2005
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2004-2005 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.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.shale.usecases.rolodex;
 
 /**

Modified: struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/dex.xml
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/dex.xml?rev=240380&r1=240379&r2=240380&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/dex.xml (original)
+++ struts/shale/trunk/use-cases/src/java/org/apache/shale/usecases/rolodex/dex.xml Fri Aug 26 19:45:41 2005
@@ -1,3 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+ Copyright 2004-2005 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.
+ You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
 <dex>
 <states>
 	<state abbrState="AL" state="Alabama" country="United States" abbrCountry="US"/>

Modified: struts/shale/trunk/use-cases/src/test/org/apache/shale/usecases/rolodex/RolodexTestCase.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/test/org/apache/shale/usecases/rolodex/RolodexTestCase.java?rev=240380&r1=240379&r2=240380&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/test/org/apache/shale/usecases/rolodex/RolodexTestCase.java (original)
+++ struts/shale/trunk/use-cases/src/test/org/apache/shale/usecases/rolodex/RolodexTestCase.java Fri Aug 26 19:45:41 2005
@@ -119,10 +119,13 @@
     // simulate clicking a tab
     public void testChangeTab() {
 
+        QueryParam paramObj = new QueryParam();
         for (int t = 0; t < RolodexDao.TAB_INDEX.length; t++) {
 
             // tab links add a param of the tab index
-            request.addParameter("tabIndex", String.valueOf(t));
+            paramObj.setTabIndex(String.valueOf(t));
+            ValueBinding vb = application.createValueBinding("queryParam");
+            vb.setValue(facesContext, paramObj);
 
             // add a dummy contact
             viewController.setSelectedContact(new Contact());
@@ -163,6 +166,7 @@
         // return the contacts on the first page
         List contacts = viewController.getContactsForTab();
 
+        QueryParam paramObj = new QueryParam();
         Iterator ci = contacts.iterator();
         while (ci.hasNext()) {
             Contact contact = (Contact) ci.next();
@@ -175,7 +179,9 @@
             // clear out the selected contact
             viewController.setSelectedContact(null);
 
-            request.addParameter("selectedName", nameParam);
+            paramObj.setSelectedName(nameParam);
+            ValueBinding vb = application.createValueBinding("queryParam");
+            vb.setValue(facesContext, paramObj);
 
             // invoke the method on the view controller as if it was fired
             // via an action method binding event on the name collumn in the
@@ -223,7 +229,10 @@
         } catch (UnsupportedEncodingException e) {
         }
 
-        request.addParameter("selectedName", nameParam);
+        QueryParam paramObj = new QueryParam();
+        paramObj.setSelectedName(nameParam);
+        ValueBinding vb = application.createValueBinding("queryParam");
+        vb.setValue(facesContext, paramObj);
 
         // invoke the method on the view controller as if it was fired
         // via an action method binding event on the name collumn in the

Modified: struts/shale/trunk/use-cases/src/web/WEB-INF/clay-config.xml
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/web/WEB-INF/clay-config.xml?rev=240380&r1=240379&r2=240380&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/web/WEB-INF/clay-config.xml (original)
+++ struts/shale/trunk/use-cases/src/web/WEB-INF/clay-config.xml Fri Aug 26 19:45:41 2005
@@ -1,3 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+ Copyright 2004-2005 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.
+ You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
 <!DOCTYPE view PUBLIC "-//Apache Software Foundation//DTD Shale Clay View//EN" "http://jakarta.apache.org/struts/dtds/clay-config_1_1.dtd">
 <view>
 	

Modified: struts/shale/trunk/use-cases/src/web/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/use-cases/src/web/WEB-INF/faces-config.xml?rev=240380&r1=240379&r2=240380&view=diff
==============================================================================
--- struts/shale/trunk/use-cases/src/web/WEB-INF/faces-config.xml (original)
+++ struts/shale/trunk/use-cases/src/web/WEB-INF/faces-config.xml Fri Aug 26 19:45:41 2005
@@ -459,7 +459,7 @@
 
   <managed-bean>
     <description>
-       View controller for the rolodex usecase
+       View controller for the JSP view rolodex usecase
     </description>
     <managed-bean-name>rolodex</managed-bean-name>
     <managed-bean-class>
@@ -470,13 +470,33 @@
 
   <managed-bean>
     <description>
-       View controller for the rolodex usecase
+       View controller for the HTML view rolodex usecase
     </description>
     <managed-bean-name>rolodex$hrolodex</managed-bean-name>
     <managed-bean-class>
       org.apache.shale.usecases.rolodex.Rolodex
     </managed-bean-class>
     <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
+
+  <managed-bean>
+    <description>
+        This class simulates the classic Struts FormBean where
+        request parameters are populated in a POJO object.     
+    </description>
+    <managed-bean-name>queryParam</managed-bean-name>
+    <managed-bean-class>
+      org.apache.shale.usecases.rolodex.QueryParam
+    </managed-bean-class>
+    <managed-bean-scope>request</managed-bean-scope>
+    <managed-property>
+        <property-name>tabIndex</property-name>
+        <value>#{param.tabIndex}</value>
+    </managed-property>
+    <managed-property>
+        <property-name>selectedName</property-name>
+        <value>#{param.selectedName}</value>
+    </managed-property>
   </managed-bean>
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org