Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011-2013, James Zhan 詹波 (jfinal@126.com). 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 com.jfinal.ext.interceptor;
 
 import java.util.Map;
SessionInViewInterceptor.
 
 public class SessionInViewInterceptor implements Interceptor {
 	
 	private boolean createSession = false;
 	
 	}
 	
 	public SessionInViewInterceptor(boolean createSession) {
 		this. = createSession;
 	}
 	
 	@SuppressWarnings({"rawtypes""unchecked"})	
 	public void intercept(ActionInvocation ai) {
 		ai.invoke();
 		
 		Controller c = ai.getController();
 		if (hs != null) {
 			Map session = new JFinalSession(hs);
 			for (Enumeration<Stringnames=hs.getAttributeNames(); names.hasMoreElements();) {
 				String name = names.nextElement();
 				session.put(namehs.getAttribute(name));
 			}
 			c.setAttr("session"session);
 		}
 	}
 }
 
 @SuppressWarnings({"rawtypes""deprecation"})
 class JFinalSession extends HashMap implements HttpSession {
 	private static final long serialVersionUID = -6148316613614087335L;
 	private HttpSession session;
 	
 	public JFinalSession(HttpSession session) {
 		this. = session;
 	}
 	
 	public Object getAttribute(String key) {
 		return .getAttribute(key);
 	}
 	
 	@SuppressWarnings("unchecked")
 	}
 	
 	public long getCreationTime() {
 	}
 	
 	public String getId() {
 		return .getId();
 	}
 	
 	public long getLastAccessedTime() {
 	}
 	
 	public int getMaxInactiveInterval() {
 	}
 	
 	}
 	
 	}
	public Object getValue(String key) {
		return .getValue(key);
	}
	public String[] getValueNames() {
	}
	public void invalidate() {
	}
	public boolean isNew() {
		return .isNew();
	}
	public void putValue(String keyObject value) {
		.putValue(keyvalue);
	}
	public void removeAttribute(String key) {
	}
	public void removeValue(String key) {
	}
	public void setAttribute(String keyObject value) {
		.setAttribute(keyvalue);
	}
	public void setMaxInactiveInterval(int maxInactiveInterval) {
		.setMaxInactiveInterval(maxInactiveInterval);
	}
/*
public void intercept(ActionInvocation ai) {
	ai.invoke();
	Controller c = ai.getController();
	HttpSession hs = c.getSession(createSession);
	if (hs != null) {
		c.setAttr("session", new JFinalSession(hs));
	}
*/
New to GrepCode? Check out our FAQ X