Search in sources :

Example 1 with IStringResourceLoader

use of org.apache.wicket.resource.loader.IStringResourceLoader in project wicket by apache.

the class ApplicationSettingsTest method testDefaultStringResourceLoaderSetup.

/**
 */
@Test
public void testDefaultStringResourceLoaderSetup() {
    ResourceSettings settings = new ResourceSettings(new MockApplication());
    List<IStringResourceLoader> loaders = settings.getStringResourceLoaders();
    Assert.assertEquals("There should be 5 default loaders", 5, loaders.size());
    Assert.assertTrue("First loader one should be the component one", loaders.get(0) instanceof ComponentStringResourceLoader);
    Assert.assertTrue("Second loader should be the package one", loaders.get(1) instanceof PackageStringResourceLoader);
    Assert.assertTrue("Third loader should be the application one", loaders.get(2) instanceof ClassStringResourceLoader);
    Assert.assertTrue("Fourth loader should be the validator one", loaders.get(3) instanceof ValidatorStringResourceLoader);
    Assert.assertTrue("Fifth should be the initializer one", loaders.get(4) instanceof InitializerStringResourceLoader);
}
Also used : PackageStringResourceLoader(org.apache.wicket.resource.loader.PackageStringResourceLoader) ComponentStringResourceLoader(org.apache.wicket.resource.loader.ComponentStringResourceLoader) MockApplication(org.apache.wicket.mock.MockApplication) ResourceSettings(org.apache.wicket.settings.ResourceSettings) InitializerStringResourceLoader(org.apache.wicket.resource.loader.InitializerStringResourceLoader) IStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader) ValidatorStringResourceLoader(org.apache.wicket.resource.loader.ValidatorStringResourceLoader) ClassStringResourceLoader(org.apache.wicket.resource.loader.ClassStringResourceLoader) Test(org.junit.Test)

Example 2 with IStringResourceLoader

use of org.apache.wicket.resource.loader.IStringResourceLoader in project wicket by apache.

the class ComponentStringResourceLoaderTest method loaderUnknownResources.

/**
 * @see org.apache.wicket.resource.StringResourceLoaderTestBase#testLoaderUnknownResources()
 */
@Override
@Test
public void loaderUnknownResources() {
    Component c = new DummyComponent("hello", tester.getApplication()) {

        private static final long serialVersionUID = 1L;
    };
    DummyPage page = new DummyPage();
    page.add(c);
    IStringResourceLoader loader = new ComponentStringResourceLoader();
    assertNull("Missing resource should return null", loader.loadStringResource(c.getClass(), "test.string.bad", Locale.getDefault(), null, null));
}
Also used : ComponentStringResourceLoader(org.apache.wicket.resource.loader.ComponentStringResourceLoader) IStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader) Component(org.apache.wicket.Component) Test(org.junit.Test)

Example 3 with IStringResourceLoader

use of org.apache.wicket.resource.loader.IStringResourceLoader in project wicket by apache.

the class ComponentStringResourceLoaderTest method loadDirectFromPage.

/**
 */
@Test
public void loadDirectFromPage() {
    DummyPage p = new DummyPage();
    IStringResourceLoader loader = new ComponentStringResourceLoader();
    assertEquals("Valid resourse string should be found", "Another string", loader.loadStringResource(p.getClass(), "another.test.string", Locale.getDefault(), null, null));
}
Also used : ComponentStringResourceLoader(org.apache.wicket.resource.loader.ComponentStringResourceLoader) IStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader) Test(org.junit.Test)

Example 4 with IStringResourceLoader

use of org.apache.wicket.resource.loader.IStringResourceLoader in project wicket by apache.

the class ComponentStringResourceLoaderTest method multiLevelEmbeddedComponentLoadFromComponent.

/**
 */
@Test
public void multiLevelEmbeddedComponentLoadFromComponent() {
    DummyPage p = new DummyPage();
    Panel panel = new EmptyPanel("panel");
    p.add(panel);
    DummyComponent c = new DummyComponent("hello", tester.getApplication());
    panel.add(c);
    IStringResourceLoader loader = new ComponentStringResourceLoader();
    assertEquals("Valid resourse string should be found", "Component string", loader.loadStringResource(c.getClass(), "component.string", Locale.getDefault(), null, null));
}
Also used : Panel(org.apache.wicket.markup.html.panel.Panel) EmptyPanel(org.apache.wicket.markup.html.panel.EmptyPanel) EmptyPanel(org.apache.wicket.markup.html.panel.EmptyPanel) ComponentStringResourceLoader(org.apache.wicket.resource.loader.ComponentStringResourceLoader) IStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader) Test(org.junit.Test)

Example 5 with IStringResourceLoader

use of org.apache.wicket.resource.loader.IStringResourceLoader in project webanno by webanno.

the class WicketApplicationBase method initNestedStringResourceLoader.

protected void initNestedStringResourceLoader() {
    List<IStringResourceLoader> loaders = new ArrayList<>(getResourceSettings().getStringResourceLoaders());
    NestedStringResourceLoader nestedLoader = new NestedStringResourceLoader(loaders, Pattern.compile("#\\(([^ ]*?)\\)"));
    getResourceSettings().getStringResourceLoaders().clear();
    getResourceSettings().getStringResourceLoaders().add(nestedLoader);
}
Also used : NestedStringResourceLoader(org.apache.wicket.resource.loader.NestedStringResourceLoader) IStringResourceLoader(org.apache.wicket.resource.loader.IStringResourceLoader) ArrayList(java.util.ArrayList)

Aggregations

IStringResourceLoader (org.apache.wicket.resource.loader.IStringResourceLoader)10 Test (org.junit.Test)7 ComponentStringResourceLoader (org.apache.wicket.resource.loader.ComponentStringResourceLoader)6 ResourceSettings (org.apache.wicket.settings.ResourceSettings)3 MockApplication (org.apache.wicket.mock.MockApplication)2 BundleStringResourceLoader (org.apache.wicket.resource.loader.BundleStringResourceLoader)2 MidPointApplicationConfiguration (com.evolveum.midpoint.gui.api.util.MidPointApplicationConfiguration)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 PageMounter (com.evolveum.midpoint.web.application.PageMounter)1 MidPointResourceStreamLocator (com.evolveum.midpoint.web.util.MidPointResourceStreamLocator)1 MidPointStringResourceLoader (com.evolveum.midpoint.web.util.MidPointStringResourceLoader)1 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)1 ArrayList (java.util.ArrayList)1 ServletContext (javax.servlet.ServletContext)1 Component (org.apache.wicket.Component)1 AbstractDefaultAjaxBehavior (org.apache.wicket.ajax.AbstractDefaultAjaxBehavior)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxRequestAttributes (org.apache.wicket.ajax.attributes.AjaxRequestAttributes)1 MountedMapper (org.apache.wicket.core.request.mapper.MountedMapper)1 IResourceStreamLocator (org.apache.wicket.core.util.resource.locator.IResourceStreamLocator)1