org.apache.wicket.resource.JQueryResourceReference Java Examples

The following examples show how to use org.apache.wicket.resource.JQueryResourceReference. 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 vote down vote up
protected void initJQueryResourceReference()
{
    // See: 
    // https://github.com/webanno/webanno/issues/1397
    // https://github.com/sebfz1/wicket-jquery-ui/issues/311
    getJavaScriptLibrarySettings().setJQueryReference(JQueryResourceReference.getV2());
}
 
Example #2
Source File: WebResources.java    From etcd-viewer with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends HeaderItem> getDependencies() {

    final ResourceReference backingLibraryReference;
    if (Application.exists()) {
        backingLibraryReference = Application.get().getJavaScriptLibrarySettings().getJQueryReference();
    } else {
        backingLibraryReference = JQueryResourceReference.get();
    }

    return Arrays.asList(CssHeaderItem.forReference(BOOTSTRAP_CSS), JavaScriptHeaderItem.forReference(backingLibraryReference));
}
 
Example #3
Source File: BootstrapDatePickerBehaviourTest.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testJSInjection() {
	getTester().getSession().setLocale(Locale.ENGLISH);

	DateTextField field = new DateTextField("field") {
		private static final long serialVersionUID = 1L;

		{
			add(new BootstrapDatePickerBehaviour());
		}};

	startFormComponentTest(field, "text");

	String doc = getTester().getLastResponse().getDocument();

	TagTester head = TagTester.createTagByName(doc, "head");
	assertNotNull(head);

	List<TagTester> scripts = TagTester.createTagsByAttribute(head.getValue(), "type", "text/javascript", false);
	assertEquals(5, scripts.size());
	for (int i = 0; i < 5; i++) {
		assertEquals("script", scripts.get(i).getName());
	}
	
	assertThat(scripts.get(0).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/bootstrap-datepicker(.*)\\.js"));
	assertThat(scripts.get(1).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/bootstrap-datepicker-extension(.*)\\.js"));
	assertThat(scripts.get(2).getAttribute("src"), matchesPattern("(.*)" + JQueryResourceReference.class.getName() + "(.*)/jquery(.*)\\.js"));
	assertThat(scripts.get(3).getAttribute("src"), matchesPattern("(.*)" + AbstractDefaultAjaxBehavior.class.getName() + "(.*)/wicket-ajax-jquery(.*)\\.js"));
	assertThat(scripts.get(4).getValue(), matchesPattern("(?s)(.*)Wicket.Event.add\\(window, \\\"domready\\\", function\\(event\\) \\{(.*)\\$\\(\"#" +
			field.getMarkupId() + "\"\\).datepicker\\(\\);(.*);\\}\\);(.*)"));
}
 
Example #4
Source File: BootstrapDatePickerBehaviourTest.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testJSInjectionNonEnglishLocale() {
	getTester().getSession().setLocale(Locale.FRENCH);

	DateTextField field = new DateTextField("field") {
		private static final long serialVersionUID = 1L;

		{
			add(new BootstrapDatePickerBehaviour());
		}};
	startFormComponentTest(field, "text");

	String doc = getTester().getLastResponse().getDocument();

	TagTester head = TagTester.createTagByName(doc, "head");
	assertNotNull(head);

	List<TagTester> scripts = TagTester.createTagsByAttribute(head.getValue(), "type", "text/javascript", false);
	assertEquals(6, scripts.size());
	for (int i = 0; i < 6; i++) {
		assertEquals("script", scripts.get(i).getName());
	}
	
	assertThat(scripts.get(0).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/bootstrap-datepicker(.*)\\.js"));
	assertThat(scripts.get(1).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/bootstrap-datepicker-extension(.*)\\.js"));
	assertThat(scripts.get(2).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/locales/bootstrap-datepicker.fr(.*)\\.js"));
	assertThat(scripts.get(3).getAttribute("src"), matchesPattern("(.*)" + JQueryResourceReference.class.getName() + "(.*)/jquery(.*)\\.js"));
	assertThat(scripts.get(4).getAttribute("src"), matchesPattern("(.*)" + AbstractDefaultAjaxBehavior.class.getName() + "(.*)/wicket-ajax-jquery(.*)\\.js"));
	assertThat(scripts.get(5).getValue(), matchesPattern("(?s)(.*)Wicket.Event.add\\(window, \\\"domready\\\", function\\(event\\) \\{(.*)\\$\\(\"#" +
			field.getMarkupId() + "\"\\).datepicker\\(\\);(.*);\\}\\);(.*)"));
}
 
Example #5
Source File: BootstrapDatePickerBehaviourTest.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testJSInjectionOneSpecialDate() {
	getTester().getSession().setLocale(Locale.ENGLISH);

	DateTextField field = new DateTextField("field") {
		private static final long serialVersionUID = 1L;

		{
			add(new BootstrapDatePickerBehaviour() {
				private static final long serialVersionUID = 1L;

				@SuppressWarnings("deprecation")
				@Override
				public java.util.Collection<SpecialDate> getSpecialDates() {
					return Arrays.asList(new SpecialDate(new Date(110, 11, 25), "holiday", "Christmas"));
				};
			});
		}};
	startFormComponentTest(field, "text");

	String doc = getTester().getLastResponse().getDocument();

	TagTester head = TagTester.createTagByName(doc, "head");
	assertNotNull(head);

	List<TagTester> scripts = TagTester.createTagsByAttribute(head.getValue(), "type", "text/javascript", false);
	assertEquals(5, scripts.size());
	for (int i = 0; i < 5; i++) {
		assertEquals("script", scripts.get(i).getName());
	}

	assertThat(scripts.get(0).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/bootstrap-datepicker(.*)\\.js"));
	assertThat(scripts.get(1).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/bootstrap-datepicker-extension(.*)\\.js"));
	assertThat(scripts.get(2).getAttribute("src"), matchesPattern("(.*)" + JQueryResourceReference.class.getName() + "(.*)/jquery(.*)\\.js"));
	assertThat(scripts.get(3).getAttribute("src"), matchesPattern("(.*)" + AbstractDefaultAjaxBehavior.class.getName() + "(.*)/wicket-ajax-jquery(.*)\\.js"));
	assertThat(scripts.get(4).getValue(), matchesPattern("(?s)(.*)Wicket.Event.add\\(window, \\\"domready\\\", function\\(event\\) \\{(.*)\\$\\(\"#" +
			field.getMarkupId() + "\"\\).datepicker\\(null, \\[" +
			"\\{dt:new Date\\('2010-12-25'\\), css:'holiday', tooltip:'Christmas'\\}" +
			"\\]\\);(.*);\\}\\);(.*)"));
}
 
Example #6
Source File: BootstrapDatePickerBehaviourTest.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testBehaviorEmptySpecialDates() {
	getTester().getSession().setLocale(Locale.ENGLISH);

	DateTextField field = new DateTextField("field") {
		private static final long serialVersionUID = 1L;

		{
			add(new BootstrapDatePickerBehaviour() {
				private static final long serialVersionUID = 1L;

				@Override
				public java.util.Collection<SpecialDate> getSpecialDates() {
					return new ArrayList<SpecialDate>();
				};
			});
		}};
	startFormComponentTest(field, "text");

	String doc = getTester().getLastResponse().getDocument();

	TagTester head = TagTester.createTagByName(doc, "head");
	assertNotNull(head);

	List<TagTester> scripts = TagTester.createTagsByAttribute(head.getValue(), "type", "text/javascript", false);
	assertEquals(5, scripts.size());
	for (int i = 0; i < 5; i++) {
		assertEquals("script", scripts.get(i).getName());
	}

	assertThat(scripts.get(0).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/bootstrap-datepicker(.*)\\.js"));
	assertThat(scripts.get(1).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/bootstrap-datepicker-extension(.*)\\.js"));
	assertThat(scripts.get(2).getAttribute("src"), matchesPattern("(.*)" + JQueryResourceReference.class.getName() + "(.*)/jquery(.*)\\.js"));
	assertThat(scripts.get(3).getAttribute("src"), matchesPattern("(.*)" + AbstractDefaultAjaxBehavior.class.getName() + "(.*)/wicket-ajax-jquery(.*)\\.js"));
	assertThat(scripts.get(4).getValue(), matchesPattern("(?s)(.*)Wicket.Event.add\\(window, \\\"domready\\\", function\\(event\\) \\{(.*)\\$\\(\"#" +
			field.getMarkupId() + "\"\\).datepicker\\(\\);(.*);\\}\\);(.*)"));

}
 
Example #7
Source File: MavenArtifactNotifierApplication.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
public void init() {
	super.init();
	
	if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) {
		getComponentPostOnBeforeRenderListeners().add(new StatelessChecker());
	}
	
	if (RuntimeConfigurationType.DEPLOYMENT.equals(getConfigurationType())) {
		addResourceReplacement(JQueryResourceReference.get(),
				new UrlResourceReference(Url.parse("//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js")));
	}
}
 
Example #8
Source File: BootstrapDatePickerBehaviourTest.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Test
public void testBehaviorManySpecialDates() {
	getTester().getSession().setLocale(Locale.ENGLISH);

	DateTextField field = new DateTextField("field") {
		private static final long serialVersionUID = 1L;

		{
			add(new BootstrapDatePickerBehaviour() {
				private static final long serialVersionUID = 1L;

				@SuppressWarnings("deprecation")
				@Override
				public java.util.Collection<SpecialDate> getSpecialDates() {
					return Arrays.asList(
							new SpecialDate(new Date(110, 11, 25), "holiday", "Christmas"),
							new SpecialDate(new Date(110, 0, 1), "holiday", "New Year"));
				};
			});
		}};
	startFormComponentTest(field, "text");

	String doc = getTester().getLastResponse().getDocument();

	TagTester head = TagTester.createTagByName(doc, "head");
	assertNotNull(head);

	List<TagTester> scripts = TagTester.createTagsByAttribute(head.getValue(), "type", "text/javascript", false);
	assertEquals(5, scripts.size());
	for (int i = 0; i < 5; i++) {
		assertEquals("script", scripts.get(i).getName());
	}
	assertThat(scripts.get(0).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/bootstrap-datepicker(.*)\\.js"));
	assertThat(scripts.get(1).getAttribute("src"), matchesPattern("(.*)" + BootstrapDatePickerBehaviour.class.getName() + "/bootstrap-datepicker-extension(.*)\\.js"));
	assertThat(scripts.get(2).getAttribute("src"), matchesPattern("(.*)" + JQueryResourceReference.class.getName() + "(.*)/jquery(.*)\\.js"));
	assertThat(scripts.get(3).getAttribute("src"), matchesPattern("(.*)" + AbstractDefaultAjaxBehavior.class.getName() + "(.*)/wicket-ajax-jquery(.*)\\.js"));

	assertThat(scripts.get(4).getValue(), matchesPattern("(?s)(.*)Wicket.Event.add\\(window, \\\"domready\\\", function\\(event\\) \\{(.*)\\$\\(\"#" +
			field.getMarkupId() + "\"\\).datepicker\\(null, \\[" +
			"\\{dt:new Date\\('2010-12-25'\\), css:'holiday', tooltip:'Christmas'\\}," +
			"\\{dt:new Date\\('2010-01-01'\\), css:'holiday', tooltip:'New Year'\\}" +
			"\\]\\);(.*);\\}\\);(.*)"));
}