1 package com.tonbeller.wcf.scroller; 2 3 import java.io.IOException ; 4 5 import javax.servlet.jsp.JspWriter ; 6 7 import com.tonbeller.wcf.controller.RequestContext; 8 9 13 public class Scroller { 14 15 private static String SCROLLER_KEY = Scroller.class.getName(); 16 public static final String FORCE_SCROLLER = "forcescroller"; 17 18 public void handleRequest(RequestContext context, JspWriter out) throws IOException { 19 writeCoordParam(context, out, "wcfXCoord"); 21 writeCoordParam(context, out, "wcfYCoord"); 22 } 23 24 private void writeCoordParam(RequestContext context, JspWriter out, String coordName) throws IOException { 25 String coordVal = "0"; 26 if(isScrollerEnabled(context)) { 27 String val = context.getParameter(coordName); 28 if (val != null) 29 coordVal = val; 30 } 31 out.print("<input type=\"hidden\" name=\""+coordName+"\" value=\""+coordVal+"\"/>"); 32 } 33 34 42 public static void enableScroller(RequestContext context) { 43 if(isScrollerEnabled(context)) 44 return; 45 context.getRequest().setAttribute(SCROLLER_KEY, "true"); 46 } 47 48 public static boolean isScrollerEnabled(RequestContext context) { 49 if(context.getParameter(FORCE_SCROLLER)!=null) 51 return true; 52 53 return context.getRequest().getAttribute(SCROLLER_KEY)!=null; 55 } 56 } 57 | Popular Tags |