List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:org.hippoecm.frontend.session.PluginUserSession.java
License:Apache License
@Override public HippoRepository getHippoRepository() throws RepositoryException { Main main = (Main) Application.get(); return main.getRepository(); }
From source file:org.hippoecm.frontend.skin.IconUtilTest.java
License:Apache License
@Before public void setUp() { final IResourceSettings resourceSettings = Application.get().getResourceSettings(); final IPackageResourceGuard packageResourceGuard = resourceSettings.getPackageResourceGuard(); if (packageResourceGuard instanceof SecurePackageResourceGuard) { SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard; guard.setAllowAccessToRootResources(true); }/*from ww w .ja v a 2s . co m*/ }
From source file:org.hippoecm.frontend.translation.components.document.NodeNameCodecBehavior.java
License:Apache License
@Override public void onRequest() { final RequestCycle requestCycle = RequestCycle.get(); StringValue name = requestCycle.getRequest().getRequestParameters().getParameterValue("name"); final JSONObject response = new JSONObject(); try {/*from w w w . jav a 2 s .c om*/ if (name != null) { response.put("data", codec.getObject().encode(name.toString())); response.put("success", true); } else { response.put("success", false); } } catch (JSONException e) { log.error(e.getMessage()); } IRequestHandler requestHandler = new IRequestHandler() { public void respond(IRequestCycle requestCycle) { WebResponse webResponse = (WebResponse) requestCycle.getResponse(); // Determine encoding final String encoding = Application.get().getRequestCycleSettings().getResponseRequestEncoding(); webResponse.setContentType("application/json;charset=" + encoding); // Make sure it is not cached webResponse.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); webResponse.setHeader("Cache-Control", "no-cache, must-revalidate"); webResponse.setHeader("Pragma", "no-cache"); webResponse.write(response.toString()); } public void detach(IRequestCycle requestCycle) { } }; requestCycle.scheduleRequestHandlerAfterCurrent(requestHandler); }
From source file:org.hippoecm.frontend.util.WebApplicationHelper.java
License:Apache License
public static boolean isDevelopmentMode() { return Application.get().getConfigurationType().equals(RuntimeConfigurationType.DEVELOPMENT); }
From source file:org.jaulp.wicket.behaviors.popupoverlay.PopupoverlayBehavior.java
License:Apache License
/** * {@inheritDoc}/*from w w w .ja v a 2 s . c om*/ */ @Override public void renderHead(Component c, final IHeaderResponse response) { response.render(JavaScriptHeaderItem .forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference())); response.render(JavaScriptHeaderItem.forReference(PopupoverlayBehavior.POPUPOVERLAY_PLUGIN_REFERENCE)); response.render(OnLoadHeaderItem.forScript(generateJS(popupoverlayTemplate))); }
From source file:org.obiba.onyx.ruby.core.wicket.wizard.TubeRegistrationPanel.java
License:Open Source License
public ApplicationContext getApplicationContext() { return ((ISpringWebApplication) Application.get()).getSpringContextLocator().getSpringContext(); }
From source file:org.obiba.onyx.webapp.base.panel.MenuBuilder.java
License:Open Source License
/** * Build the default menu.// ww w. ja va 2 s .co m * @param container where adding the menu items * @param fullMenu add logout menu item if true */ public static void build(final MarkupContainer container, boolean fullMenu) { final List<MenuItem> menuItems = new ArrayList<MenuItem>(); if (OnyxAuthenticatedSession.get().isSignedIn()) { menuItems.add(new MenuItem(Application.get().getHomePage(), "Home")); menuItems.add(new MenuItem(ParticipantSearchPage.class, "Participant")); if (hasWorkstationWidget(WorkstationPage.WORKSTATION_CONTENT) && Session.get().getAuthorizationStrategy().isInstantiationAuthorized(WorkstationPage.class)) { MenuItem item = new MenuItem(WorkstationPage.class, "Workstation"); menuItems.add(item); } } // Creating the DataView containing the whole menu container.add(new DataView<MenuItem>("menuItem", new ListDataProvider<MenuItem>(menuItems)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item<MenuItem> item) { MenuItem menuItem = menuItems.get(item.getIndex()); Component menuLink = getLink("menuLink", menuItem.getPage(), menuItem.getParameters(), "menuLabel", menuItem.getLabel(), container); item.add(menuLink); // Creating the DataView holding all items of a submenu DataView<MenuItem> menuItemDataView = new DataView<MenuItem>("subMenuItem", new ListDataProvider<MenuItem>(menuItem.getSubMenuItems())) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item<MenuItem> subItem) { MenuItem subMenuItem = subItem.getModelObject(); Component link = getLink("subMenuLink", subMenuItem.getPage(), subMenuItem.getParameters(), "subMenuLabel", subMenuItem.getLabel(), container); subItem.add(link); setPageview(subItem, subMenuItem); } }; item.add(menuItemDataView); if (menuItem.getRoles() != null) { MetaDataRoleAuthorizationStrategy.authorize(item, RENDER, menuItem.getRoles().toString()); } } }); }
From source file:org.obiba.onyx.wicket.model.SpringStringResourceModel.java
License:Open Source License
protected Object load() { // Initialize information that we need to work successfully Session session = Session.get();/* w ww.j a v a 2s .co m*/ if (session != null) { locale = session.getLocale(); } Application application = Application.get(); if (application instanceof SpringWebApplication) { context = ((SpringWebApplication) application).getSpringContextLocator().getSpringContext(); } else if (application instanceof ISpringWebApplication) { context = ((ISpringWebApplication) application).getSpringContextLocator().getSpringContext(); } if (locale == null || context == null) { throw new WicketRuntimeException( "Cannot attach a string resource model without a Session context or a valid Application context because that is required to get a Spring application Context"); } return getStringResource(); }
From source file:org.objetdirect.wickext.core.commons.CoreJavaScriptResourceReference.java
License:Open Source License
/** * Returns the library name regarding the configuration type setting, * e.g. loads the jQuery packed version in production mode and * loads the jQuery full version in development mode. *//*from w w w.j a va2 s. c o m*/ private static String resolveLibrary() { String configurationType = Application.get().getConfigurationType(); if (configurationType.equals(Application.DEVELOPMENT)) { return "jquery/jquery.js"; } return "jquery/jquery.pack.js"; }
From source file:org.odlabs.wiquery.core.commons.listener.JQueryUICoreRenderingListener.java
License:Open Source License
/** * {@inheritDoc}/*from w w w.j av a 2 s. c om*/ * * @see org.odlabs.wiquery.core.commons.listener.WiQueryPluginRenderingListener#onRender(org.odlabs.wiquery.core.commons.IWiQueryPlugin, * org.odlabs.wiquery.core.commons.WiQueryResourceManager, * org.apache.wicket.markup.html.IHeaderResponse) */ public void onRender(IWiQueryPlugin plugin, WiQueryResourceManager resourceManager, IHeaderResponse response) { if (WiQuerySettings.get().isAutoImportJQueryUIResource()) { if (plugin.getClass().isAnnotationPresent(WiQueryUIPlugin.class)) { Application application = Application.get(); if (application instanceof IThemableApplication) { // if application is themable, imports the given theme response.renderCSSReference(((IThemableApplication) application).getTheme(Session.get())); } else { // application is not themed, imports default theme response.renderCSSReference(DEFAULT_THEME); } response.renderJavascriptReference(CoreUIJavaScriptResourceReference.get()); } } }