[pal-cvs 2957] [701] parse categoryId in URL.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2007年 11月 12日 (月) 12:35:49 JST


Revision: 701
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=701
Author:   shinsuke
Date:     2007-11-12 12:35:49 +0900 (Mon, 12 Nov 2007)

Log Message:
-----------
parse categoryId in URL.

Modified Paths:
--------------
    pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/CategoryListAction.java
    pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListAction.java


-------------- next part --------------
Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/CategoryListAction.java
===================================================================
--- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/CategoryListAction.java	2007-11-12 03:30:16 UTC (rev 700)
+++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/CategoryListAction.java	2007-11-12 03:35:49 UTC (rev 701)
@@ -6,6 +6,8 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.faces.context.FacesContext;
+
 import jp.sf.pal.pompei.PompeiConstants;
 import jp.sf.pal.pompei.dxo.CategoryDxo;
 import jp.sf.pal.pompei.service.CategoryService;
@@ -31,9 +33,23 @@
         return null;
     }
 
+    private BigDecimal getCurrentCategoryId() {
+        String categoryId = (String) FacesContext.getCurrentInstance()
+                .getExternalContext().getRequestParameterMap().get(
+                        PompeiConstants.CATEGORY_ID);
+        if (categoryId != null) {
+            try {
+                return new BigDecimal(Long.parseLong(categoryId));
+            } catch (NumberFormatException e) {
+            }
+        }
+        return (BigDecimal) SessionUtil
+                .getFromApplicationScope(PompeiConstants.CURRENT_CATEGORY_ID);
+    }
+
     public Class<?> prerender() {
-        BigDecimal currentCategoryId = (BigDecimal) SessionUtil
-                .getFromApplicationScope(PompeiConstants.CURRENT_CATEGORY_ID);
+        BigDecimal currentCategoryId = getCurrentCategoryId();
+
         // current category
         if (getCategoryListPage().getCategoryId() == null) {
             getCategoryListPage().setCategoryId(currentCategoryId);
@@ -55,6 +71,8 @@
                             .getCategoryId());
         } else if (!getCategoryListPage().getCategoryId().equals(
                 currentCategoryId)) {
+            // update categoryId
+            getCategoryListPage().setCategoryId(currentCategoryId);
             //  refresh breadcrumb
             List<Map<String, Object>> breadcrumbItems = new ArrayList<Map<String, Object>>();
             getCategoryDxo().convert(

Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListAction.java
===================================================================
--- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListAction.java	2007-11-12 03:30:16 UTC (rev 700)
+++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListAction.java	2007-11-12 03:35:49 UTC (rev 701)
@@ -7,6 +7,8 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.faces.context.FacesContext;
+
 import jp.sf.pal.pompei.PompeiConstants;
 import jp.sf.pal.pompei.allcommon.cbean.PagingResultBean;
 import jp.sf.pal.pompei.dxo.CategoryDxo;
@@ -57,10 +59,24 @@
         return null;
     }
 
+    private BigDecimal getCurrentCategoryId() {
+        String categoryId = (String) FacesContext.getCurrentInstance()
+                .getExternalContext().getRequestParameterMap().get(
+                        PompeiConstants.CATEGORY_ID);
+        if (categoryId != null) {
+            try {
+                return new BigDecimal(Long.parseLong(categoryId));
+            } catch (NumberFormatException e) {
+            }
+        }
+        return (BigDecimal) SessionUtil
+                .getFromApplicationScope(PompeiConstants.CURRENT_CATEGORY_ID);
+    }
+
     public Class<?> prerender() {
 
-        BigDecimal currentCategoryId = (BigDecimal) SessionUtil
-                .getFromApplicationScope(PompeiConstants.CURRENT_CATEGORY_ID);
+        BigDecimal currentCategoryId = getCurrentCategoryId();
+
         if (currentCategoryId == null) {
             currentCategoryId = PompeiConstants.ROOT_CATEGORY_ID;
             //TODO should put it to session?


pal-cvs メーリングリストの案内
Back to archive index