svnno****@sourc*****
svnno****@sourc*****
2007年 11月 12日 (月) 17:04:26 JST
Revision: 704 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=704 Author: shinsuke Date: 2007-11-12 17:04:26 +0900 (Mon, 12 Nov 2007) Log Message: ----------- parse productId in URL and bug fixes. Modified Paths: -------------- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/PompeiConstants.java pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/pager/DefaultPager.java pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/service/ProductService.java pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/service/impl/ProductServiceImpl.java pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/admin/order/OrderListAction.java pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductDetailsAction.java pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListAction.java pompei/portlets/pompei-core/trunk/src/main/webapp/view/user/product/categoryList.html -------------- next part -------------- Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/PompeiConstants.java =================================================================== --- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/PompeiConstants.java 2007-11-12 08:02:32 UTC (rev 703) +++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/PompeiConstants.java 2007-11-12 08:04:26 UTC (rev 704) @@ -11,11 +11,11 @@ public static final String VALUE = "value"; - public static final int DEFULAT_PAGE_SIZE = 15; + public static final int DEFAULT_PAGE_SIZE = 15; - public static final int DEFULAT_PAGE_RANGE_SIZE = 5; + public static final int DEFAULT_PAGE_RANGE_SIZE = 5; - public static final int DEFULAT_CURRENT_PAGE_NUMBER = 1; + public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1; public static final String JPEG = ".jpg"; @@ -53,6 +53,8 @@ public static final String CATEGORY_ID = "categoryId"; + public static final String PRODUCT_ID = "productId"; + public static final String BREADCRUMB = "breadcrumb"; public static final String PRODUCT_DESCRIPTION_LIST = "productDescriptionList"; @@ -259,4 +261,20 @@ public static final String SUB_TOTAL_PRICE = PREFIX + "SubTotalPrice"; public static final String TAX = PREFIX + "Tax"; + + public static final String TYPE_OF_TOP_PRODUCTS = PREFIX + + "TypeOfTopProducts"; + + public static final String RATING = "rating"; + + public static final String ORDERED = "ordered"; + + public static final String REVIEDED = "reviewed"; + + public static final String DEFAULT_TYPE_OF_TOP_PRODUCTS = RATING; + + public static final String NUM_OF_TOP_PRODUCTS = PREFIX + + "NumOfTopProducts"; + + public static final int DEFAULT_NUM_OF_TOP_PRODUCTS = 8; } Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/pager/DefaultPager.java =================================================================== --- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/pager/DefaultPager.java 2007-11-12 08:02:32 UTC (rev 703) +++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/pager/DefaultPager.java 2007-11-12 08:04:26 UTC (rev 704) @@ -14,7 +14,7 @@ */ public int getPageSize() { if (pageSize <= 0) { - pageSize = PompeiConstants.DEFULAT_PAGE_SIZE; + pageSize = PompeiConstants.DEFAULT_PAGE_SIZE; } return pageSize; } @@ -31,7 +31,7 @@ */ public int getCurrentPageNumber() { if (currentPageNumber <= 0) { - currentPageNumber = PompeiConstants.DEFULAT_CURRENT_PAGE_NUMBER; + currentPageNumber = PompeiConstants.DEFAULT_CURRENT_PAGE_NUMBER; } return currentPageNumber; } Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/service/ProductService.java =================================================================== --- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/service/ProductService.java 2007-11-12 08:02:32 UTC (rev 703) +++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/service/ProductService.java 2007-11-12 08:04:26 UTC (rev 704) @@ -38,4 +38,6 @@ public ProductImage getProductImageByProductIdAndType(BigDecimal productId, BigDecimal type); + + public PagingResultBean<Product> getTopProductList(String type, int num); } Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/service/impl/ProductServiceImpl.java =================================================================== --- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/service/impl/ProductServiceImpl.java 2007-11-12 08:02:32 UTC (rev 703) +++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/service/impl/ProductServiceImpl.java 2007-11-12 08:04:26 UTC (rev 704) @@ -290,6 +290,30 @@ return getProductImageBhv().selectEntity(cb); } + public PagingResultBean<Product> getTopProductList(String type, int num) { + ProductCB cb = new ProductCB(); + + // pager + cb.fetchFirst(num); + cb.fetchPage(1); + + // setup + cb.setupSelect_Manufacturer(); + + if (PompeiConstants.RATING.equals(type)) { + cb.query().addOrderBy_Rating_Desc(); + } else if (PompeiConstants.ORDERED.equals(type)) { + cb.query().addOrderBy_Ordered_Desc(); + } else if (PompeiConstants.REVIEDED.equals(type)) { + cb.query().addOrderBy_Reviewed_Desc(); + } + + PagingResultBean<Product> productList = getProductBhv().selectPage(cb); + //TODO there may be better method.. + getProductBhv().loadProductDescriptionList(productList); + return productList; + } + public ProductDescriptionBhv getProductDescriptionBhv() { return productDescriptionBhv; } Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/admin/order/OrderListAction.java =================================================================== --- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/admin/order/OrderListAction.java 2007-11-12 08:02:32 UTC (rev 703) +++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/admin/order/OrderListAction.java 2007-11-12 08:04:26 UTC (rev 704) @@ -84,7 +84,7 @@ getOrderListPage()); // page range - orderFormList.setPageRangeSize(PompeiConstants.DEFULAT_PAGE_RANGE_SIZE); + orderFormList.setPageRangeSize(PompeiConstants.DEFAULT_PAGE_RANGE_SIZE); int[] pageNumberArray = orderFormList.pageRange() .createPageNumberArray(); List<Map<String, Object>> pageNumberItems = new ArrayList<Map<String, Object>>(); Modified: pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductDetailsAction.java =================================================================== --- pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductDetailsAction.java 2007-11-12 08:02:32 UTC (rev 703) +++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductDetailsAction.java 2007-11-12 08:04:26 UTC (rev 704) @@ -47,6 +47,21 @@ return null; } + private boolean isProductDetails() { + String productId = (String) FacesContext.getCurrentInstance() + .getExternalContext().getRequestParameterMap().get( + PompeiConstants.PRODUCT_ID); + if (productId != null) { + try { + long id = Long.parseLong(productId); + getProductDetailsPage().setProductId(BigDecimal.valueOf(id)); + return true; + } catch (NumberFormatException e) { + } + } + return false; + } + public Class<?> prerender() { // check login @@ -79,8 +94,10 @@ } // check product - if (getProductDetailsPage().getProductId() == null) { - return ProductListPage.class; + if (!isProductDetails()) { + if (getProductDetailsPage().getProductId() == null) { + return ProductListPage.class; + } } ProductDescription description = productService 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 08:02:32 UTC (rev 703) +++ pompei/portlets/pompei-core/trunk/src/main/java/jp/sf/pal/pompei/web/user/product/ProductListAction.java 2007-11-12 08:04:26 UTC (rev 704) @@ -9,6 +9,7 @@ import javax.faces.context.FacesContext; +import jp.sf.pal.common.util.FacesMessageUtil; import jp.sf.pal.pompei.PompeiConstants; import jp.sf.pal.pompei.allcommon.cbean.PagingResultBean; import jp.sf.pal.pompei.dxo.CategoryDxo; @@ -73,7 +74,25 @@ .getFromApplicationScope(PompeiConstants.CURRENT_CATEGORY_ID); } + private boolean isProductDetails() { + String productId = (String) FacesContext.getCurrentInstance() + .getExternalContext().getRequestParameterMap().get( + PompeiConstants.PRODUCT_ID); + if (productId != null) { + try { + long id = Long.parseLong(productId); + getProductListPage().setProductId(BigDecimal.valueOf(id)); + return true; + } catch (NumberFormatException e) { + } + } + return false; + } + public Class<?> prerender() { + if (isProductDetails()) { + return ProductDetailsPage.class; + } BigDecimal currentCategoryId = getCurrentCategoryId(); @@ -82,7 +101,16 @@ //TODO should put it to session? } - //TODO check previous category + // check previous category + BigDecimal previousCategoryId = (BigDecimal) SessionUtil + .getFromLocalScope(PompeiConstants.CURRENT_CATEGORY_ID); + if (previousCategoryId != null + && !previousCategoryId.equals(currentCategoryId)) { + // change category + getProductListPage().setPageNumber( + PompeiConstants.DEFAULT_CURRENT_PAGE_NUMBER); + getProductListPage().setPageSize(PompeiConstants.DEFAULT_PAGE_SIZE); + } // store category id to local session SessionUtil.putToLocalScope(PompeiConstants.CURRENT_CATEGORY_ID, @@ -134,7 +162,7 @@ getProductListPage()); // page range - productList.setPageRangeSize(PompeiConstants.DEFULAT_PAGE_RANGE_SIZE); + productList.setPageRangeSize(PompeiConstants.DEFAULT_PAGE_RANGE_SIZE); int[] pageNumberArray = productList.pageRange().createPageNumberArray(); List<Map<String, Object>> pageNumberItems = new ArrayList<Map<String, Object>>(); for (int i : pageNumberArray) { @@ -152,6 +180,9 @@ getProductListPage().setDisplayMode( PompeiConstants.THUMBNAIL_DISPLAY); } + + // render faces messages + FacesMessageUtil.renderMessages(); return null; } Modified: pompei/portlets/pompei-core/trunk/src/main/webapp/view/user/product/categoryList.html =================================================================== --- pompei/portlets/pompei-core/trunk/src/main/webapp/view/user/product/categoryList.html 2007-11-12 08:02:32 UTC (rev 703) +++ pompei/portlets/pompei-core/trunk/src/main/webapp/view/user/product/categoryList.html 2007-11-12 08:04:26 UTC (rev 704) @@ -18,14 +18,14 @@ </script><form id="categoryForm"><input id="doFinish" type="submit" style="display: none;"/><input type="hidden" id="targetId" /> <div id="breadcrumbItems"> <div id="isNotSelected"> -<span id="depth-breadcrumbItems" te:escape="false"> </span>» <input type="hidden" id="categoryId-breadcrumbItems" /><a id="goCategoryList-breadcrmb" href="./categoryList.html?categoryId=0" onclick="setCategoryId(this.previousSibling.form,this.previousSibling.value);"><span id="name">カテゴリ</span></a><br/> +<span id="depth-breadcrumbItems" te:escape="false"> </span>» <input type="hidden" id="categoryId-breadcrumbItems" /><a id="goCategoryList-breadcrmb" href="./categoryList.html?categoryId=0" onclick="setCategoryId(this.previousSibling.form,this.previousSibling.value);return false;"><span id="name">カテゴリ</span></a><br/> </div> <div id="isSelected"> <span id="depth-breadcrumbItems-selected" te:escape="false"> </span>» <span id="name">カテゴリ</span><br/> </div> </div> <div id="categoryItems"> - <span id="depth-categoryItems" te:escape="false"> </span>- <input type="hidden" id="categoryId-categoryItems" /><a id="goCategoryList" href="./categoryList.html?categoryId=1" onclick="setCategoryId(this.previousSibling.form,this.previousSibling.value);"><span id="name">スニーカー</span></a><br/> + <span id="depth-categoryItems" te:escape="false"> </span>- <input type="hidden" id="categoryId-categoryItems" /><a id="goCategoryList" href="./categoryList.html?categoryId=1" onclick="setCategoryId(this.previousSibling.form,this.previousSibling.value);return false;"><span id="name">スニーカー</span></a><br/> </div> </form> </body>