$(function() { var app = new WebApp(); }); function WebApp() { //members this.webSocket = null; this.workdata = null; $('#wait').show(); this.initializeWebsocket(); this.getURLParameter = function(sParam) { //retrieves GET-PARAMETER } this.initializeWebsocket = function() { //websocket connection } }
function WebApp() { //members this.webSocket = null; this.workdata = null; $('#wait').show(); this.initializeWebsocket(); this.getURLParameter = function(sParam) { //retrieves GET-PARAMETER } this.initializeWebsocket = function() { //websocket connection } } $(function() { var app = new WebApp(); });
function WebApp() { var self = this; // Reference to this is in variable called self. //members this.webSocket = null; this.workdata = null; //constructor $( 'document' ).ready(function() { $('#wait').show(); self.initializeWebsocket(); // Here this refers to different scope.. so use self }); this.getURLParameter = function(sParam) { //retrieves GET-PARAMETER } this.initializeWebsocket = function() { //websocket connection console.log("inside websocket") } } var app = new WebApp();
/** * Obtains the {@link WebApp} associated with the given {@link ServletContext}. */ public static WebApp get(ServletContext context) { Object o = context.getAttribute(WebApp.class.getName()); if(o==null) { synchronized (WebApp.class) { o = context.getAttribute(WebApp.class.getName()); if(o==null) { o = new WebApp(context); context.setAttribute(WebApp.class.getName(),o); } } } return (WebApp)o; }
/** * Obtains the {@link WebApp} associated with the given {@link ServletContext}. */ public static WebApp get(ServletContext context) { Object o = context.getAttribute(WebApp.class.getName()); if(o==null) { synchronized (WebApp.class) { o = context.getAttribute(WebApp.class.getName()); if(o==null) { o = new WebApp(context); context.setAttribute(WebApp.class.getName(),o); } } } return (WebApp)o; }
/** * Obtains the {@link WebApp} associated with the given {@link ServletContext}. */ public static WebApp get(ServletContext context) { Object o = context.getAttribute(WebApp.class.getName()); if(o==null) { synchronized (WebApp.class) { o = context.getAttribute(WebApp.class.getName()); if(o==null) { o = new WebApp(context); context.setAttribute(WebApp.class.getName(),o); } } } return (WebApp)o; }
@Override protected void setUp() throws Exception { super.setUp(); ServletContext servletContext = Mockito.mock(ServletContext.class); webApp = new WebApp(servletContext); ServletConfig servletConfig = Mockito.mock(ServletConfig.class); Mockito.when(servletConfig.getServletContext()).thenReturn(servletContext); stapler.init(servletConfig); rawRequest = Mockito.mock(HttpServletRequest.class); rawResponse = Mockito.mock(HttpServletResponse.class); this.request = new RequestImpl(stapler, rawRequest,new ArrayList<AncestorImpl>(),new TokenList("")); Stapler.CURRENT_REQUEST.set(this.request); this.response = new ResponseImpl(stapler, rawResponse); Stapler.CURRENT_RESPONSE.set(this.response); } }
private RequestImpl createFakeRequest() { Stapler s = new Stapler(); s.setWebApp(new WebApp(new MockServletContext())); return new RequestImpl(s, new MockRequest(), Collections.<AncestorImpl>emptyList(), null); }