org.apache.wicket.core.request.mapper.HomePageMapper Java Examples
The following examples show how to use
org.apache.wicket.core.request.mapper.HomePageMapper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WicketApplicationBase.java From webanno with Apache License 2.0 | 5 votes |
protected void initDefaultPageMounts() { mountPage("/login.html", getSignInPageClass()); mountPage("/welcome.html", getHomePage()); // Mount the other pages via @MountPath annotation on the page classes AnnotatedMountList mounts = new AnnotatedMountScanner().scanPackage("de.tudarmstadt.ukp"); for (IRequestMapper mapper : mounts) { if (mapper instanceof HomePageMapper) { System.out.println(mapper); } } mounts.mount(this); }
Example #2
Source File: OrienteerWebApplication.java From Orienteer with Apache License 2.0 | 5 votes |
private void mountOrUnmountPackage(String packageName, ClassLoader classLoader, boolean mount) { ClassPath classPath; try { classPath = ClassPath.from(classLoader); } catch (IOException e) { throw new WicketRuntimeException("Can't scan classpath", e); } for(ClassInfo classInfo : classPath.getTopLevelClassesRecursive(packageName)) { Class<?> clazz = classInfo.load(); MountPath mountPath = clazz.getAnnotation(MountPath.class); if(mountPath!=null) { if(IRequestablePage.class.isAssignableFrom(clazz)) { Class<? extends IRequestablePage> pageClass = (Class<? extends IRequestablePage>) clazz; forEachOnMountPath(mountPath, path -> { if(mount) { if ("/".equals(path)) { mount(new HomePageMapper(pageClass)); } mount(new MountedMapper(path, pageClass)); } else { unmount(path); } }); } else if(IResource.class.isAssignableFrom(clazz)) { if(mount) { String resourceKey = clazz.getName(); getSharedResources().add(resourceKey, (IResource) getServiceInstance(clazz)); SharedResourceReference reference = new SharedResourceReference(resourceKey); forEachOnMountPath(mountPath, path -> mountResource(path, reference)); } else { forEachOnMountPath(mountPath, this::unmount); } } else { throw new WicketRuntimeException("@"+MountPath.class.getSimpleName()+" should be only on pages or resources"); } } } }