Subversion Repositories SmartDukaan

Rev

Rev 590 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 590 Rev 650
Line 32... Line 32...
32
/**
32
/**
33
 * 
33
 * 
34
 * @author rajveer
34
 * @author rajveer
35
 *
35
 *
36
 */
36
 */
37
@Results({
-
 
38
	@Result(name="success", location="/home-index")
-
 
39
})
37
 
40
public class HomeController extends BaseController 
38
public class HomeController extends BaseController {
41
	implements  ModelDriven<Object>, ServletContextAware  {
-
 
42
		  
39
		  
43
	private PageManager pageManager = null;
-
 
44
	
-
 
45
	/**
-
 
46
	 * 
-
 
47
	 */
-
 
48
	private static Log log = LogFactory.getLog(HomeController.class);
-
 
49
	
-
 
50
	/**
40
	/**
51
	 * 
41
	 * 
52
	 */
42
	 */
53
	@SuppressWarnings("unused")
-
 
54
	private ServletContext servletContext = null;
43
	private static final long serialVersionUID = 1L;
55
	
44
 
56
	/**
45
	/**
57
	 * 
46
	 * 
58
	 */
47
	 */
59
	private String id;
-
 
60
	
-
 
61
	private Map<String,String> htmlSnippets;
48
	private static Log log = LogFactory.getLog(HomeController.class);
62
	
-
 
63
	
49
	
64
	public HomeController(){
50
	public HomeController(){
65
		super();
51
		super();
66
		pageManager = PageManager.getPageManager();
-
 
67
	}
52
	}
68
 
53
 
69
 
54
 
70
    public HttpHeaders index() throws SecurityException, IOException {
55
    public String index() throws SecurityException, IOException {
71
    	log.info("userinfo:" + userinfo.toString());
56
    	log.info("userinfo:" + userinfo.toString());
72
    	Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
-
 
73
    	
-
 
74
    	params.put(PageContentKeys.USER_ID, new Long(userinfo.getUserId()).toString());
-
 
75
    	params.put(PageContentKeys.CART_ID, new Long(userinfo.getCartId()).toString());
-
 
76
    	params.put(PageContentKeys.USER_NAME, userinfo.getNameOfUser());
-
 
77
    	params.put(PageContentKeys.ITEM_COUNT, new Long(userinfo.getTotalItems()).toString());
-
 
78
    	params.put(PageContentKeys.IS_LOGGED_IN, Boolean.valueOf(userinfo.isLoggedIn()).toString());
-
 
79
    	
57
    	
-
 
58
    	htmlSnippets.put("MAIN_BANNER", pageLoader.getMainBannerHtml());
80
    	htmlSnippets = pageManager.getPageContents(PageEnum.HOME_PAGE, params);
59
    	htmlSnippets.put("BEST_DEALS", pageLoader.getBestDealsHtml());
81
    	
-
 
-
 
60
    	htmlSnippets.put("BEST_SELLERS", pageLoader.getBestSellersHtml());
-
 
61
    	htmlSnippets.put("LATEST_ARRIVALS", pageLoader.getLatestArrivalsHtml());
82
        return new DefaultHttpHeaders("index");
62
    	return "index";
83
    }
63
    }
84
    
64
    
85
    /**
-
 
86
     * 
-
 
87
     * @param id
-
 
88
     */
-
 
89
    public void setId(String id) {
-
 
90
    	StringTokenizer tokenizer = new StringTokenizer(id,"-");
-
 
91
    	while(tokenizer.hasMoreTokens()){
-
 
92
    		this.id = tokenizer.nextToken();
-
 
93
    	}
-
 
94
    }
-
 
95
 
-
 
96
	/* (non-Javadoc)
-
 
97
	 * @see com.opensymphony.xwork2.ModelDriven#getModel()
-
 
98
	 */
-
 
99
	@Override
-
 
100
	public Object getModel() {
-
 
101
		System.out.println(" getModel  is called");
-
 
102
		return htmlSnippets;
-
 
103
		//return this.id;
-
 
104
	}
-
 
105
	
-
 
106
	/**
-
 
107
	 * 
-
 
108
	 */
-
 
109
	@Override
-
 
110
	public void setServletContext(ServletContext servletContext) {
-
 
111
		this.servletContext = servletContext;
-
 
112
	}
-
 
113
	
-
 
114
	public Map<String,String> getHtmlSnippets(){
-
 
115
		System.out.println(" getHtmlSnippets  is called");
-
 
116
		return htmlSnippets;
-
 
117
	}
-
 
118
	
-
 
119
	public String getHeaderSnippet(){
-
 
120
		return htmlSnippets.get("HEADER");
-
 
121
	}
-
 
122
 
-
 
123
	public String getSlideGuideSnippet(){
-
 
124
		return htmlSnippets.get("SLIDE_GUIDE");
-
 
125
	}
-
 
126
 
-
 
127
	public String getMainMenuSnippet(){
-
 
128
		return htmlSnippets.get("MAIN_MENU");
-
 
129
	}
-
 
130
	
-
 
131
	public String getSearchBarSnippet(){
-
 
132
		return htmlSnippets.get("SEARCH_BAR");
-
 
133
	}
-
 
134
    		
-
 
135
 
-
 
136
	public String getMainBannerSnippet(){
65
	public String getMainBannerSnippet(){
137
		return htmlSnippets.get("MAIN_BANNER");
66
		return htmlSnippets.get("MAIN_BANNER");
138
	}
67
	}
139
	
68
	
140
	public String getBestDealsSnippet(){
69
	public String getBestDealsSnippet(){
Line 146... Line 75...
146
	}
75
	}
147
	
76
	
148
	public String getBestSellersSnippet(){
77
	public String getBestSellersSnippet(){
149
		return htmlSnippets.get("BEST_SELLERS");
78
		return htmlSnippets.get("BEST_SELLERS");
150
	}
79
	}
151
	
-
 
152
	public String getCustomerServiceSnippet(){
-
 
153
		return htmlSnippets.get("CUSTOMER_SERVICE");
-
 
154
	}
-
 
155
	
-
 
156
	public String getMyResearchSnippet(){
-
 
157
		return htmlSnippets.get("MY_RESEARCH");
-
 
158
	}
-
 
159
	
-
 
160
 
-
 
161
	public String getRecommendationsSnippet(){
-
 
162
		return htmlSnippets.get("RECOMMENDATIONS");
-
 
163
	}
-
 
164
 
-
 
165
	public String getBrowseHistorySnippet(){
-
 
166
		return htmlSnippets.get("BROWSE_HISTORY");
-
 
167
	}
-
 
168
			
-
 
169
	public String getFooterSnippet(){
-
 
170
		return htmlSnippets.get("FOOTER");
-
 
171
	}
-
 
172
 
-
 
173
	public String getJsFileSnippet(){
-
 
174
		return htmlSnippets.get("JS_FILES");
-
 
175
	}
-
 
176
	
-
 
177
	public String getCssFileSnippet(){
-
 
178
		return htmlSnippets.get("CSS_FILES");
-
 
179
	}
-
 
180
	
-
 
181
}
80
}