Source Code Cross Referenced for CategoryAction.java in  » J2EE » jfox » org » jfox » petstore » action » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » jfox » org.jfox.petstore.action 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JFox - The most lightweight Java EE Application Server!
003:         * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
004:         *
005:         * JFox is licenced and re-distributable under GNU LGPL.
006:         */
007:        package org.jfox.petstore.action;
008:
009:        import java.util.List;
010:        import javax.ejb.EJB;
011:
012:        import org.jfox.framework.annotation.Service;
013:        import org.jfox.mvc.ActionContext;
014:        import org.jfox.mvc.ActionSupport;
015:        import org.jfox.mvc.Invocation;
016:        import org.jfox.mvc.PageContext;
017:        import org.jfox.mvc.SessionContext;
018:        import org.jfox.mvc.annotation.ActionMethod;
019:        import org.jfox.mvc.util.PagedList;
020:        import org.jfox.petstore.bo.AccountBO;
021:        import org.jfox.petstore.bo.CategoryBO;
022:        import org.jfox.petstore.bo.ProductBO;
023:        import org.jfox.petstore.entity.Category;
024:        import org.jfox.petstore.entity.Product;
025:
026:        /**
027:         * @author <a href="mailto:jfox.young@gmail.com">Young Yang</a>
028:         */
029:        @Service(id="category")
030:        public class CategoryAction extends ActionSupport {
031:
032:            @EJB
033:            AccountBO accountBO;
034:
035:            @EJB(name="CategoryBOImpl")
036:            CategoryBO categoryBO;
037:
038:            @EJB
039:            ProductBO productBO;
040:
041:            public void postInject() {
042:                super .postInject();
043:            }
044:
045:            /**
046:             * index page
047:             *
048:             * @param actionContext invocationContext
049:             * @throws Exception exception
050:             */
051:            @ActionMethod(name="view",successView="Category.vhtml",invocationClass=CategoryInvocation.class,httpMethod=ActionMethod.HttpMethod.GET)
052:            public void doGetView(ActionContext actionContext) throws Exception {
053:                CategoryInvocation invocation = (CategoryInvocation) actionContext
054:                        .getInvocation();
055:                Category category = categoryBO.getCategory(invocation
056:                        .getCategoryId());
057:
058:                PageContext pageContext = actionContext.getPageContext();
059:                SessionContext sessionContext = actionContext
060:                        .getSessionContext();
061:
062:                PagedList<Product> productPagedList;
063:
064:                //product list cached by JPA Cache
065:                //        if (!sessionContext.containsAttribute("ProductPageList")) {
066:                List<Product> products = productBO
067:                        .getProductsByCategory(invocation.getCategoryId());
068:                productPagedList = new PagedList<Product>(products, 4);
069:                sessionContext
070:                        .setAttribute("ProductPageList", productPagedList);
071:                //        }
072:                //        else {
073:                //            productPagedList = (PagedList<Product>)sessionContext.getAttribute("ProductPageList");
074:                //        }
075:                for (int i = 0; i < invocation.getPage(); i++) {
076:                    productPagedList.nextPage();
077:                }
078:
079:                int nextPage = invocation.getPage();
080:                if (!productPagedList.isLastPage()) {
081:                    nextPage++;
082:                }
083:
084:                int previousPage = invocation.getPage();
085:                if (!productPagedList.isFirstPage()) {
086:                    previousPage--;
087:                }
088:
089:                /*
090:                 if ("next".equals(invocation.getPage())) {
091:                 productPagedList.nextPage();
092:                 }
093:                 else if ("previous".equals(invocation.getPage())) {
094:                 productPagedList.previousPage();
095:                 }
096:                 */
097:
098:                //        Account account = accountBO.getAccount();
099:                //        account.setFirstName("Yang Yong");
100:                //        sessionContext.setAttribute("account", account);
101:                pageContext.setAttribute("account", sessionContext
102:                        .getAttribute("account"));
103:                pageContext.setAttribute("category", category);
104:                pageContext.setAttribute("categoryId", invocation
105:                        .getCategoryId());
106:                pageContext.setAttribute("pageList", productPagedList);
107:                pageContext.setAttribute("previousPage", previousPage);
108:                pageContext.setAttribute("nextPage", nextPage);
109:
110:            }
111:
112:            public static class CategoryInvocation extends Invocation {
113:
114:                private String categoryId = "BIRDS";
115:
116:                private int page = 0;
117:
118:                public String getCategoryId() {
119:                    return categoryId;
120:                }
121:
122:                public void setCategoryId(String categoryId) {
123:                    this .categoryId = categoryId;
124:                }
125:
126:                public int getPage() {
127:                    return page;
128:                }
129:
130:                public void setPage(int page) {
131:                    this .page = page;
132:                }
133:            }
134:
135:            public static void main(String[] args) {
136:
137:            }
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.