List of usage examples for org.apache.wicket.resource.loader ComponentStringResourceLoader ComponentStringResourceLoader
public ComponentStringResourceLoader()
From source file:com.evolveum.midpoint.web.security.MidPointAuthWebSession.java
License:Apache License
@Override public boolean authenticate(String username, String password) { LOGGER.debug("Authenticating '{}' {} password in web session.", new Object[] { username, (StringUtils.isEmpty(password) ? "without" : "with") }); boolean authenticated; try {//from ww w . j a v a 2 s . c om Authentication authentication = authenticationProvider .authenticate(new UsernamePasswordAuthenticationToken(username, password)); SecurityContextHolder.getContext().setAuthentication(authentication); authenticated = authentication.isAuthenticated(); auditEvent(authentication, username, OperationResultStatus.SUCCESS); } catch (AuthenticationException ex) { ComponentStringResourceLoader comp = new ComponentStringResourceLoader(); error(comp.loadStringResource(MidPointApplication.class, ex.getMessage(), getLocale(), "", "")); LOGGER.debug("Couldn't authenticate user.", ex); authenticated = false; auditEvent(null, username, OperationResultStatus.FATAL_ERROR); } return authenticated; }
From source file:com.userweave.application.UserWeaveApplication.java
License:Open Source License
private void setDefaultResourceLocale(final Locale defaultResourceLocale) { Collection<IStringResourceLoader> stringResourceLoaders = new ArrayList<IStringResourceLoader>( getResourceSettings().getStringResourceLoaders()); for (IStringResourceLoader loader : stringResourceLoaders) { getResourceSettings().getStringResourceLoaders().add(loader); }//from w w w . j a v a 2 s. co m // support for default _en.properties files getResourceSettings().getStringResourceLoaders().add(new ComponentStringResourceLoader() { @Override public String loadStringResource(Class<?> clazz, String key, Locale locale, String style, String variation) { return super.loadStringResource(clazz, key, defaultResourceLocale, style, variation); } }); getResourceSettings().getStringResourceLoaders().add(new ClassStringResourceLoader(this.getClass()) { @Override public String loadStringResource(Class<?> clazz, String key, Locale locale, String style, String variation) { return super.loadStringResource(clazz, key, defaultResourceLocale, style, variation); } }); }
From source file:nl.knaw.dans.common.wicket.components.editablepanel.EditablePanel.java
License:Apache License
@SuppressWarnings("serial") private SubmitLink createModeLink() { final SubmitLink modeLink = new SubmitLink("modeLink") { @Override//from w ww . ja v a2 s .c o m public void onSubmit() { inEditMode = !inEditMode; setContentPanel(); } @Override public boolean isVisible() { return context.isEditModeAllowed(); } }; modeLink.add(new Label("modeLinkLabel", new AbstractReadOnlyModel<String>() { @Override public String getObject() { final ComponentStringResourceLoader resources = new ComponentStringResourceLoader(); return resources.loadStringResource(EditablePanel.this, inEditMode ? "displayLinkLabel" : "editLinkLabel"); } })); return modeLink; }
From source file:org.apache.isis.viewer.wicket.viewer.settings.IsisResourceSettings.java
License:Apache License
/** * Configures Wicket's default ResourceLoaders. * * <p>//from ww w . j a va 2s . c o m * In contrast to the default lookup strategy, Isis' searches for application-specific properties first. * * </p> * For an example in {@code FooApplication} let {@code bar.Foo} extend {@link org.apache.wicket.Component}, this * results in the following ordering: * <dl> * <dt>application specific</dt> * <dd> * <ul> * <li>FooApplication.properties</li> * <li>Application.properties</li> * </ul> * </dd> * <dt>component specific</dt> * <dd> * <ul> * <li>bar/Foo.properties</li> * <li>org/apache/wicket/Component.properties</li> * </ul> * </dd> * <dt>package specific</dt> * <dd> * <ul> * <li>bar/package.properties</li> * <li>package.properties (on Foo's class loader)</li> * <li>org/apache/wicket/package.properties</li> * <li>org/apache/package.properties</li> * <li>org/package.properties</li> * <li>package.properties (on Component's class loader)</li> * </ul> * </dd> * <dt>validator specific</dt> * <dt>Initializer specific</dt> * <dd> * <ul> * <li>bar.Foo.properties (Foo implementing IInitializer)</li> * </ul> * </dd> * </dl> * * @param application */ public IsisResourceSettings(Application application) { super(application); // consult first (the default implementation checks this only third) stringResourceLoaders.add(new ClassStringResourceLoader(application.getClass())); stringResourceLoaders.add(new ComponentStringResourceLoader()); stringResourceLoaders.add(new PackageStringResourceLoader()); // this is where the default implementation registered the search. //stringResourceLoaders.add(new ClassStringResourceLoader(application.getClass())); stringResourceLoaders.add(new ValidatorStringResourceLoader()); stringResourceLoaders.add(new InitializerStringResourceLoader(application.getInitializers())); }
From source file:org.geoserver.wicket.test.WicketTestApplication.java
License:Open Source License
@Override protected void init() { //JD: override some resource settings to allow for custom i18n lookups getResourceSettings().setResourceStreamLocator(new GeoServerResourceStreamLocator()); getResourceSettings().addStringResourceLoader(new GeoServerStringResourceLoader()); getResourceSettings().addStringResourceLoader(new ComponentStringResourceLoader()); getResourceSettings().addStringResourceLoader(new ClassStringResourceLoader(this.getClass())); getResourceSettings().setPropertiesFactory(new PropertiesFactory(this) { @Override//from www . ja v a2 s.c om public Properties load(Class clazz, String path) { if (clazz == WicketTestApplication.class && path.startsWith(wtapath)) { String newPath = path.replace(wtapath, gsapath); return super.load(GeoServerApplication.class, newPath); } return super.load(clazz, path); } }); }
From source file:org.hippoecm.frontend.editor.plugins.resource.ImageDisplayPlugin.java
License:Apache License
private String lookupLinkLabel(final String filename) { String linkLabel;/* ww w . j a v a 2s . c o m*/ if (HippoNodeType.NT_RESOURCE.equals(filename)) { ComponentStringResourceLoader componentStringResourceLoader = new ComponentStringResourceLoader(); linkLabel = componentStringResourceLoader.loadStringResource(this, "download.link", getLocale(), null, null); } else { linkLabel = filename; } return linkLabel; }
From source file:org.openengsb.ui.admin.global.menu.MenuTemplate.java
License:Apache License
@SuppressWarnings({ "unchecked", "rawtypes" }) public void addMenuItem(String index, Class<? extends WebPage> linkClass, String langKey, String langDescKey, ResourceReference icon, String... authority) { ComponentStringResourceLoader csrl = new ComponentStringResourceLoader(); String label = csrl.loadStringResource(linkClass, langKey, getSession().getLocale(), getSession().getStyle(), ""); String description = csrl.loadStringResource(linkClass, langDescKey, getSession().getLocale(), getSession().getStyle(), ""); BookmarkablePageLabelLink pageLabelLink = new BookmarkablePageLabelLink("link", linkClass, label); addAuthorizationRoles(pageLabelLink, authority); if (icon == null) { menuItems.add(new MenuItem(index, pageLabelLink, description)); } else {/*from w ww . j a v a2 s . co m*/ menuItems.add(new MenuItem(index, pageLabelLink, description, icon)); } avialableItems.add(index); }