use of org.apache.wicket.Page in project wicket by apache.
the class AutoFormLabelPickupTest method localeChangesAreDetectedWithDefaultLabels.
@Test
public void localeChangesAreDetectedWithDefaultLabels() throws Exception {
Session.get().setLocale(Locale.GERMAN);
tester.startPage(new PickUpLabelPage(null));
assertEquals("propertiesDefaultLabel DE", ((FormComponent) tester.getComponentFromLastRenderedPage("form:inputWithDefaultLabel")).getLabel().getObject());
tester.assertContains("propertiesDefaultLabel DE");
// change locale to see whether it picks it up
Session.get().setLocale(Locale.FRENCH);
Page page = tester.getLastRenderedPage();
// make sure everything is detached after we just talked to that label model
page.detach();
// just re-render the same page instance with the new locale
tester.startPage(page);
assertEquals("propertiesDefaultLabel FR", ((FormComponent) tester.getComponentFromLastRenderedPage("form:inputWithDefaultLabel")).getLabel().getObject());
tester.assertContains("propertiesDefaultLabel FR");
}
use of org.apache.wicket.Page in project wicket by apache.
the class AutoFormLabelPickupTest method localeChangesAreDetectedWithExplicitMessageKeys.
@Test
public void localeChangesAreDetectedWithExplicitMessageKeys() throws Exception {
Session.get().setLocale(Locale.GERMAN);
tester.startPage(new PickUpLabelPage(null));
assertEquals("label from properties DE", ((FormComponent) tester.getComponentFromLastRenderedPage("form:inputPropertiesLabel")).getLabel().getObject());
tester.assertContains("label from properties DE");
// change locale to see whether it picks it up
Session.get().setLocale(Locale.FRENCH);
Page page = tester.getLastRenderedPage();
// make sure everything is detached after we just talked to that label model
page.detach();
// just re-render the same page instance with the new locale
tester.startPage(page);
assertEquals("label from properties FR", ((FormComponent) tester.getComponentFromLastRenderedPage("form:inputPropertiesLabel")).getLabel().getObject());
tester.assertContains("label from properties FR");
}
use of org.apache.wicket.Page in project wicket by apache.
the class PageSizeDebugPanel method getDataModel.
@Override
protected IModel<String> getDataModel() {
return new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
Page enclosingPage = getPage();
long pageSize = WicketObjects.sizeof(enclosingPage);
Bytes pageSizeInBytes = (pageSize > -1 ? Bytes.bytes(pageSize) : null);
String pageSizeAsString = pageSizeInBytes != null ? pageSizeInBytes.toString() : "unknown";
return "Page: " + pageSizeAsString;
}
};
}
use of org.apache.wicket.Page in project wicket by apache.
the class AjaxLinkClickTest method testBasicAjaxLinkClick.
/**
* Test that an AjaxLink's onClick method is actually invoked.
*/
@Test
public void testBasicAjaxLinkClick() {
// Create a link, which we test is actually invoked
final AjaxLink<Void> ajaxLink = new AjaxLink<Void>("ajaxLink") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
linkClicked = true;
ajaxRequestTarget = target;
}
};
Page page = new MockPageWithLink();
page.add(ajaxLink);
tester.startPage(page);
tester.clickLink("ajaxLink");
assertTrue(linkClicked);
assertNotNull(ajaxRequestTarget);
}
use of org.apache.wicket.Page in project wicket by apache.
the class AjaxLinkClickTest method testFallbackLinkWithAjaxDisabled.
/**
* Test that when AJAX is disabled, the AjaxFallbackLink is invoked with null as
* AjaxRequestTarget.
*/
@Test
public void testFallbackLinkWithAjaxDisabled() {
final Page page = new MockPageWithLink();
// Create a link, which we test is actually invoked
page.add(new AjaxFallbackLink<Void>("ajaxLink") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(Optional<AjaxRequestTarget> targetOptional) {
linkClicked = true;
targetOptional.ifPresent(target -> ajaxRequestTarget = target);
}
});
tester.startPage(page);
// Click the link with ajax disabled
tester.clickLink("ajaxLink", false);
assertTrue(linkClicked);
assertNull(ajaxRequestTarget);
}
Aggregations