use of org.apache.wicket.behavior.AbstractAjaxBehavior in project wicket by apache.
the class AjaxLinkTest method page_2.
/**
* @throws Exception
*/
@Test
public void page_2() throws Exception {
executeTest(AjaxPage2.class, "AjaxPage2_ExpectedResult.html");
Page page = tester.getLastRenderedPage();
Component ajaxLink = page.get("pageLayout:pageLayout_body:ajaxLink");
AbstractAjaxBehavior behavior = (AbstractAjaxBehavior) ajaxLink.getBehaviors().get(0);
executeBehavior(behavior, "AjaxPage2-1_ExpectedResult.html");
}
use of org.apache.wicket.behavior.AbstractAjaxBehavior in project webanno by webanno.
the class AjaxDownloadLink method commonInit.
void commonInit() {
downloadBehavior = new AbstractAjaxBehavior() {
private static final long serialVersionUID = 3472918725573624819L;
@Override
public void onRequest() {
IResourceStream is = AjaxDownloadLink.this.getModelObject();
if (is != null) {
// If no filename has been set explicitly, try to get it from the resource
String name = filename != null ? filename.getObject() : null;
if (name == null) {
if (is instanceof FileResourceStream) {
name = ((FileResourceStream) is).getFile().getName();
} else if (is instanceof FileSystemResourceStream) {
name = ((FileSystemResourceStream) is).getPath().getFileName().toString();
}
}
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(AjaxDownloadLink.this.getModelObject(), name);
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getComponent().getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
}
};
add(downloadBehavior);
}
use of org.apache.wicket.behavior.AbstractAjaxBehavior in project wicket by apache.
the class BaseWicketTester method urlFor.
/**
* @param link
* @return Url
*/
public Url urlFor(final AjaxLink<?> link) {
AbstractAjaxBehavior behavior = WicketTesterHelper.findAjaxEventBehavior(link, "click");
Url url = Url.parse(behavior.getCallbackUrl().toString(), Charset.forName(request.getCharacterEncoding()));
return transform(url);
}
use of org.apache.wicket.behavior.AbstractAjaxBehavior in project wicket by apache.
the class AjaxLinkTest method renderHomePage_2.
/**
* @throws Exception
*/
@Test
public void renderHomePage_2() throws Exception {
executeTest(AjaxLinkWithBorderPage.class, "AjaxLinkWithBorderPageExpectedResult.html");
Page page = tester.getLastRenderedPage();
Component ajaxLink = page.get("border:border_body:ajaxLink");
AbstractAjaxBehavior behavior = (AbstractAjaxBehavior) ajaxLink.getBehaviors().get(0);
executeBehavior(behavior, "AjaxLinkWithBorderPage-1ExpectedResult.html");
}
use of org.apache.wicket.behavior.AbstractAjaxBehavior in project wicket by apache.
the class AjaxLinkTest method fromAjaxRequestToNormalPage.
/**
* Tests setting the request target to a normal page request from an ajax request.
*/
@Test
public void fromAjaxRequestToNormalPage() {
tester.startPage(AjaxLinkPageToNormalPage.class);
tester.assertRenderedPage(AjaxLinkPageToNormalPage.class);
Page page = tester.getLastRenderedPage();
Component ajaxLink = page.get("ajaxLink");
AbstractAjaxBehavior behavior = (AbstractAjaxBehavior) ajaxLink.getBehaviors().get(0);
tester.executeBehavior(behavior);
tester.assertRenderedPage(NormalPage.class);
}
Aggregations