Refine search
/** * Get temporary directory path for storing temporary files for e.g images. * * @return temporary directory path for storing temporary files for e.g images. */ public static String getTemporaryDirPath() { ServletContext servletContext = WebApplication.get().getServletContext(); return ((File)servletContext.getAttribute("javax.servlet.context.tempdir")).getPath() + File.separatorChar + Session.get().getId() + File.separatorChar; }
@Override protected void init() { super.init(); autoMountPages(); }
@Override public Object getObject() { parameters.put("id", componentMarkupId); parameters.put("filterName", WebApplication.get().getWicketFilter().getFilterConfig().getFilterName()); return parameters; } }
/** * The rules if and when to insert an xml decl in the response are a bit tricky. Allow the user * to replace the default per page and per application. */ protected void renderXmlDecl() { WebApplication.get().renderXmlDecl(this, false); }
protected boolean isMetaInfResourcesSupported() { if (META_INF_RESOURCES_SUPPORTED == null) { int majorVersion = WebApplication.get().getServletContext().getMajorVersion(); META_INF_RESOURCES_SUPPORTED = majorVersion >= 3; } return META_INF_RESOURCES_SUPPORTED; }
@Override public String getContentType() { return WebApplication.get().getServletContext().getMimeType(url); }
/** * Construct. */ public SimpleSynchronousFilePageStore() { this((File)((WebApplication)Application.get()).getServletContext().getAttribute( "javax.servlet.context.tempdir")); }
private Manifest getWebAppManifest() throws IOException { final ServletContext servletContext = WebApplication.get().getServletContext(); final InputStream manifestInputStream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF"); if (manifestInputStream != null) { return new Manifest(manifestInputStream); } final File manifestFile = new File(servletContext.getRealPath("/"), "META-INF/MANIFEST.MF"); if (manifestFile.exists()) { return new Manifest(new FileInputStream(manifestFile)); } return null; }
@Override protected void init() { super.init(); Args.notNull(adminUser, "<adminUser>"); anonymousUser = props.getProperty("anonymousUser"); Args.notNull(anonymousUser, "<anonymousUser>"); anonymousKey = props.getProperty("anonymousKey"); Args.notNull(anonymousKey, "<anonymousKey>"); getAttribute(EnduserInitializer.CLASSPATH_LOOKUP); for (Class<? extends AbstractResource> resource : lookup.getResources()) { Resource annotation = resource.getAnnotation(Resource.class);
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); String path = WebApplication.get().getServletContext().getContextPath(); if (StringUtils.isBlank(path)) { path = "/"; } tag.put("href", path); } });
/** * @param name the file name * @param disposition the disposition * @param ref the reference * @return the URL do download */ public String addAttachment(String name, ContentDisposition disposition, IAttachmentRef ref) { WebApplication app = WebApplication.get(); attachments.put(ref.getId(), new Attachment(name, disposition, ref)); String path = app.getServletContext().getContextPath() + "/" + app.getWicketFilter().getFilterPath() + getDownloadURL(Session.get().getId(), ref.getId()); return path.replaceAll("\\*", "").replaceAll("//", "/"); }
/** * Imports from a relative url. * * @param url * the url to import * @return the imported url's contents */ private String importRelativeUrl(String url) { Args.notEmpty(url, "url"); if (url.charAt(0) != '/') { url = '/' + url; } try { ServletContext servletContext = getWebApplication().getServletContext(); URL resource = servletContext.getResource(url); return importUrl(resource); } catch (MalformedURLException mux) { throw new WicketRuntimeException(mux); } }
@Override public String getMimeType(String fileName) { String mimeType = getServletContext().getMimeType(fileName); return mimeType != null ? mimeType : super.getMimeType(fileName); }
Args.notNull(wicketTester, "wicketTester"); Args.notNull(page, "page"); if (webApplication.getWicketFilter().getFilterPath() == null) webApplication.getWicketFilter().setFilterPath("");
: !init && application.getServletContext() != null ? application.getServletContext() : new MockServletContext(application, null); if(application.getWicketFilter() == null) application.setWicketFilter(filter); if (application.getName() == null) application.setName("WicketTesterApplication-" + UUID.randomUUID()); application.setServletContext(servletContext); application.initApplication(); application.getResourceSettings().setResourcePollFrequency(getResourcePollFrequency()); application.setPageRendererProvider(new LastPageRecordingPageRendererProvider( application.getPageRendererProvider())); application.setRequestCycleProvider(new TestRequestCycleProvider( application.getRequestCycleProvider())); originalFeedbackMessageCleanupFilter = application.getApplicationSettings() .getFeedbackMessageCleanupFilter(); application.getApplicationSettings().setFeedbackMessageCleanupFilter( IFeedbackMessageFilter.NONE); IPageManagerProvider pageManagerProvider = newTestPageManagerProvider(); if (pageManagerProvider != null)
final String inputType, IMarkupFragment pageMarkup) Args.notNull(component, "component"); new StringResourceStream(markup), containerInfo, page.getClass()); MarkupParser markupParser = getApplication().getMarkupSettings() .getMarkupFactory() .newMarkupParser(markupResourceStream);
/** * Creates and registers an instance of this class with the wicket web application. Uses * {@link WebApplicationContextUtils#getRequiredWebApplicationContext(ServletContext)} to get * spring web application context. If more fine grained registration is needed use * {@link #register(Application, SpringReferenceSupporter)}. If you want to use * {@link SpringReference} you have to use one of the register methods in your wicket * applications init(). * * @param application * wicket web application, not null */ public static void register(WebApplication application) { Args.notNull(application, "application"); ServletContext servletContext = application.getServletContext(); WebApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); register(application, new SpringReferenceSupporter(applicationContext)); }
/** * Gets the name of the cookie where the session id is stored. * * @param application * The current we application holding the {@link javax.servlet.ServletContext}. * * @return The name set in {@link javax.servlet.SessionCookieConfig} or the default value 'JSESSIONID' if not set */ public String getSessionIdCookieName(WebApplication application) { String jsessionCookieName = application.getServletContext().getSessionCookieConfig().getName(); return jsessionCookieName == null ? DEFAULT_SESSIONID_COOKIE_NAME : jsessionCookieName; }
private void post(AtmosphereResource resource, PageKey pageKey, Collection<EventSubscription> subscriptionsForPage, AtmosphereEvent event) { String filterPath = WebApplication.get() .getWicketFilter() .getFilterConfig() .getInitParameter(WicketFilter.FILTER_MAPPING_PARAM); filterPath = filterPath.substring(1, filterPath.length() - 1); HttpServletRequest httpRequest = new HttpServletRequestWrapper(resource.getRequest()) { @Override public String getContextPath() { String ret = super.getContextPath(); return ret == null ? "" : ret; } }; AtmosphereWebRequest request = new AtmosphereWebRequest( (ServletWebRequest)application.newWebRequest(httpRequest, filterPath), pageKey, subscriptionsForPage, event); Response response = new AtmosphereWebResponse(resource.getResponse()); if (application.createRequestCycle(request, response).processRequestAndDetach()) broadcaster.broadcast(response.toString(), resource); }
/** * A convenience method to return the WebApplication. Same as {@link WebApplication#get()}. * * @return the current WebApplication */ public final WebApplication getWebApplication() { return WebApplication.get(); } }