本文整理汇总了Java中org.apache.wicket.behavior.AbstractAjaxBehavior类的典型用法代码示例。如果您正苦于以下问题:Java AbstractAjaxBehavior类的具体用法?Java AbstractAjaxBehavior怎么用?Java AbstractAjaxBehavior使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractAjaxBehavior类属于org.apache.wicket.behavior包,在下文中一共展示了AbstractAjaxBehavior类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareRequest
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
/**
* Prepares request that triggers AJAX behavior and contains parameter with given name and value.
*
* @param tester the wicket tester which triggers behavior
* @param behavior the behavior that should be triggered
* @param parameterName the name of parameter
* @param parameterValue the value of parameter
* @return mock HTTP request that triggers given behavior
*/
protected MockHttpServletRequest prepareRequest(WicketTester tester, AbstractAjaxBehavior behavior,
String parameterName, String parameterValue) {
MockHttpServletRequest request = new MockHttpServletRequest(tester.getApplication(), tester.getHttpSession(), tester.getServletContext());
Url url = Url.parse(behavior.getCallbackUrl().toString(), Charset.forName(request.getCharacterEncoding()));
// make url suitable for wicket tester use. usually this involves stripping any leading ..
// segments to make the url absolute
for (Iterator<String> segments = url.getSegments().iterator(); segments.hasNext();) {
String segment = segments.next();
if (segment.equals("..") || segment.equals(".")) {
segments.remove();
}
}
request.addHeader("Wicket-Ajax", "true");
request.addHeader("Wicket-Ajax-BaseURL", url.toString());
request.setUrl(url);
request.setParameter(parameterName, parameterValue);
return request;
}
示例2: testFormPageRendering
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
@WithUserDetails("vinicius.nunes")
@Test
public void testFormPageRendering() {
tester = new SingularWicketTester(singularApplication);
FooTemplatePage page = tester.startPage(FooTemplatePage.class);
MetronicMenu m = (MetronicMenu) new AssertionsWComponent(page).getSubComponents(MetronicMenu.class).first().getTarget();
for (Behavior b : m.getBehaviors()) {
if (b instanceof AbstractAjaxBehavior) {
tester.executeBehavior((AbstractAjaxBehavior) b);
}
}
tester.assertRenderedPage(FooTemplatePage.class);
}
示例3: checkMenuItem
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
private void checkMenuItem(int idx1, int idx2, Class<? extends BasePanel> clazz) throws OmException {
testArea(adminUsername, p -> {
Menu menu = (Menu)p.get(PATH_MENU);
Assert.assertNotNull(menu);
tester.getRequest().setParameter("hash", menu.getItemList().get(idx1).getItems().get(idx2).getId());
tester.executeBehavior((AbstractAjaxBehavior)menu.getBehaviorById(0));
tester.assertComponent(PATH_CHILD, clazz);
});
}
示例4: testEventCreate
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
@Test
public void testEventCreate() throws OmException {
testArea(regularUsername, p -> {
Menu menu = (Menu)p.get(PATH_MENU);
Assert.assertNotNull(menu);
tester.getRequest().setParameter("hash", menu.getItemList().get(0).getItems().get(1).getId());
tester.executeBehavior((AbstractAjaxBehavior)menu.getBehaviorById(0));
tester.assertComponent(PATH_CHILD, CalendarPanel.class);
CalendarPanel cal = (CalendarPanel)p.get(PATH_CHILD);
tester.executeAllTimerBehaviors(cal);
User u = userDao.getByLogin(regularUsername, User.Type.user, null);
//test create month
tester.getRequest().setParameter("allDay", String.valueOf(false));
tester.getRequest().setParameter("startDate", LocalDateTime.of(2017, 11, 13, 13, 13).toString());
tester.getRequest().setParameter("endDate", LocalDateTime.of(2017, 11, 13, 13, 13).toString());
tester.getRequest().setParameter("viewName", CalendarView.month.name());
tester.executeBehavior((AbstractAjaxBehavior)cal.get("form:calendar").getBehaviorById(0)); //select-event
FormTester appTester = tester.newFormTester(PATH_APPOINTMENT_DLG_FRM);
//check inviteeType:groupContainer:groups is invisible for regular user
String title = String.format("title%s", UUID.randomUUID());
appTester.setValue("title", title);
ButtonAjaxBehavior save = getButtonBehavior(PATH_APPOINTMENT_DLG, "save");
tester.executeBehavior(save);
List<Appointment> appts = appointmentDao.searchByTitle(u.getId(), title);
assertEquals("Appointment should be created", 1, appts.size());
assertEquals("Appointment should be created", title, appts.get(0).getTitle());
});
}
示例5: checkArea
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
private void checkArea(AreaKeys area, String type, Class<? extends BasePanel> clazz, Consumer<MainPage> consumer, String... users) throws OmException {
for (String user : users) {
log.debug("Positive test:: area: {}, type: {} for user: {}", area, type, user);
testArea(user, p -> {
tester.getRequest().setParameter(area.name(), type);
tester.executeBehavior((AbstractAjaxBehavior)p.getBehaviorById(1));
tester.assertComponent(PATH_CHILD, clazz);
if (consumer != null) {
consumer.accept(p);
}
});
}
}
示例6: checkUnauthArea
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
private void checkUnauthArea(AreaKeys area, String type, String... users) throws OmException {
for (String user : users) {
log.debug("Positive test:: area: {}, type: {} for user: {}", area, type, user);
testArea(user, p -> {
tester.getRequest().setParameter(area.name(), type);
try {
tester.executeBehavior((AbstractAjaxBehavior)p.getBehaviorById(1));
fail("Not authorized");
} catch (UnauthorizedInstantiationException e) {
assertTrue("Exception is expected", true);
}
});
}
}
示例7: testRoomsProfileMessages
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
@Test
public void testRoomsProfileMessages() throws OmException {
checkArea(AreaKeys.profile, TYPE_MESSAGES, SettingsPanel.class, p -> {
TabbedPanel tp = (TabbedPanel)p.get("main-container:main:contents:child:tabs");
tester.executeBehavior((AbstractAjaxBehavior)tp.getBehaviorById(0)); //create behavior
for (int i = 0; i <= tp.getLastTabIndex(); ++i) {
tester.getRequest().setParameter("index", String.valueOf(i));
tester.executeBehavior((AbstractAjaxBehavior)tp.getBehaviorById(1)); // activate
//add visibility check
}
}, regularUsername);
}
示例8: testRoom
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
private void testRoom(Long id) throws OmException {
checkArea(AreaKeys.room, String.valueOf(id), RoomPanel.class, p -> {
RoomPanel rp = (RoomPanel)p.get(PATH_CHILD);
tester.executeBehavior((AbstractAjaxBehavior)rp.getBehaviorById(0)); //room enter
AbstractWbPanel wb = (AbstractWbPanel)rp.get("roomContainer:wb-area:whiteboard");
tester.executeBehavior((AbstractAjaxBehavior)wb.getBehaviorById(0)); //wb load
}, regularUsername);
}
示例9: testArea
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
protected void testArea(String user, Consumer<MainPage> consumer) throws OmException {
Assert.assertTrue(((WebSession)tester.getSession()).signIn(user, userpass, User.Type.user, null));;
MainPage page = tester.startPage(MainPage.class);
tester.assertRenderedPage(MainPage.class);
tester.executeBehavior((AbstractAjaxBehavior)page.getBehaviorById(0));
tester.executeBehavior((AbstractAjaxBehavior)page.get("main-container").getBehaviorById(0));
WebSocketTester webSocketTester = new WebSocketTester(tester, page);
webSocketTester.sendMessage("socketConnected");
consumer.accept(page);
tester.getSession().invalidateNow();
webSocketTester.destroy();
}
示例10: BratVisualizer
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
public BratVisualizer(String id, IModel<?> aModel)
{
super(id, aModel);
vis = new WebMarkupContainer("vis");
vis.setOutputMarkupId(true);
// Provides collection-level information like type definitions, styles, etc.
collProvider = new AbstractAjaxBehavior()
{
private static final long serialVersionUID = 1L;
@Override
public void onRequest()
{
getRequestCycle().scheduleRequestHandlerAfterCurrent(
new TextRequestHandler("application/json", "UTF-8", getCollectionData()));
}
};
// Provides the actual document contents
docProvider = new AbstractAjaxBehavior()
{
private static final long serialVersionUID = 1L;
@Override
public void onRequest()
{
getRequestCycle().scheduleRequestHandlerAfterCurrent(
new TextRequestHandler("application/json", "UTF-8", getDocumentData()));
}
};
add(vis);
add(collProvider, docProvider);
}
示例11: commonInit
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
void commonInit()
{
downloadBehavior = new AbstractAjaxBehavior()
{
private static final long serialVersionUID = 3472918725573624819L;
@Override
public void onRequest()
{
String name = filename != null ? filename.getObject() : null;
// If no filename has been set explicitly, try to get it from the resource
IResourceStream is = AjaxDownloadLink.this.getModelObject();
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);
}
示例12: DocumentCreate
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
public DocumentCreate(PageParameters parameters) {
super(parameters);
List<JsonNode> templates = documentService.getAllTemplates();
// create map (template title) -> (template id)
Map<String, String> templateMap = templates.stream()
.collect(Collectors.toMap(t -> t.get("title").asText(), t -> t.get("_id").asText()));
// get first template on the first render
String tmp = parameters.get("templateId").toString();
String templateId = (tmp == null) ?
templates.get(0).get("_id").textValue() : tmp;
// get current template revision
// new documents might be created only with newest revision of template
String templateRev = documentService.getCurrentRevision(templateId);
DocumentMetadata metadata = new DocumentMetadata();
metadata.setSchemaId(templateId);
metadata.setSchemaRev(templateRev);
createTemplateList(templateMap);
AbstractAjaxBehavior ajaxSaveBehaviour = new DocumentEditorBehavior(new Document(metadata), this);
add(ajaxSaveBehaviour);
DocumentEditorData editorData =
new DocumentEditorData(documentService.getDocumentById(templateId),
EditorUseCase.CREATE);
add(new DocumentEditor("container", editorData));
}
示例13: prepareEditor
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
private void prepareEditor(Map diffMap) {
JsonNode json;
if (docRev == null) {
json = documentService.getDocumentById(docId);
} else {
json = documentService.getDocumentByIdAndRev(docId, docRev);
}
String doc = convert.jsonNodeToString(json);
byte[] data = documentService.getDataFromJson(json);
byte[] attachments = documentService.getAttachmentsFromJson(json);
DocumentMetadata metadata = documentService.getMetadataFromJson(json);
Workflow workflow = workflowService.getWorkflowFromJson(json);
JsonNode schema = documentService.getDocumentByIdAndRev(metadata.getSchemaId(), metadata.getSchemaRev());
AbstractAjaxBehavior ajaxSaveBehaviour = new DocumentEditorBehavior(new Document(data, attachments, metadata, workflow), this);
add(ajaxSaveBehaviour);
DocumentEditorData editorData = new DocumentEditorData(schema, EditorUseCase.UPDATE);
editorData.setDocument(json.get("data"));
editorData.setDiffMap(diffMap);
StateEnum state = workflow.getState().getCurrentState();
boolean readonly = !((state == StateEnum.OPEN) || (state == StateEnum.IN_PROGRESS));
HttpServletRequest req = (HttpServletRequest) getRequest().getContainerRequest();
// if not current version or user doesn't have writer rights, disable editing
if (docRev != null && !docRev.equals(documentService.getCurrentRevision(docId)) ||
!authControler.isUserAuthorized(req, "writer"))
readonly = true;
editorData.setReadonly(readonly);
createDeleteButton(doc, readonly);
add(new DocumentEditor("container", editorData));
}
示例14: closeCallBack
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
protected void closeCallBack(final Component modal) {
modal.getBehaviors().stream().
filter(behavior -> (behavior instanceof AbstractAjaxBehavior)).
forEachOrdered(behavior -> {
TESTER.executeBehavior((AbstractAjaxBehavior) behavior);
});
}
示例15: testInstall
import org.apache.wicket.behavior.AbstractAjaxBehavior; //导入依赖的package包/类
@Test
public void testInstall() {
InstallWizardPage page = tester.startPage(InstallWizardPage.class);
tester.assertRenderedPage(InstallWizardPage.class);
InstallWizard wiz = (InstallWizard)page.get(WIZARD_PATH);
assertNull("Model should be null", wiz.getWizardModel().getActiveStep());
tester.executeBehavior((AbstractAjaxBehavior)page.getBehaviorById(0)); //welcome step
assertNotNull("Model should NOT be null", wiz.getWizardModel().getActiveStep());
ButtonAjaxBehavior prev = getButtonBehavior(tester, WIZARD_PATH, "PREV");
//check enabled, add check for other buttons on other steps
assertFalse("Prev button should be disabled", prev.getButton().isEnabled());
ButtonAjaxBehavior next = getButtonBehavior(tester, WIZARD_PATH, "NEXT");
ButtonAjaxBehavior finish = getButtonBehavior(tester, WIZARD_PATH, SUBMIT);
tester.executeBehavior(next); //DB step
FormTester wizardTester = tester.newFormTester("wizard:form");
wizardTester.select("view:form:dbType", 1);
checkErrors(tester, 0);
tester.executeBehavior(next); //user step
checkErrors(tester, 0);
wizardTester.setValue("view:username", adminUsername);
wizardTester.setValue("view:password", userpass);
wizardTester.setValue("view:email", email);
String[] tzIds = TimeZone.getAvailableIDs();
wizardTester.select("view:timeZone", rnd.nextInt(tzIds.length));
wizardTester.setValue("view:group", group);
tester.executeBehavior(next); //cfg+smtp step
checkErrors(tester, 0);
wizardTester.setValue("view:smtpPort", "25");
wizardTester.select("view:defaultLangId", 0);
tester.executeBehavior(next); //converters step
checkErrors(tester, 0);
wizardTester.setValue("view:docDpi", "150");
wizardTester.setValue("view:docQuality", "90");
tester.executeBehavior(next); //crypt step
// not checking errors
if (countErrors(tester) > 0) {
tester.cleanupFeedbackMessages();
wizardTester.setValue("view:docDpi", "150");
wizardTester.setValue("view:docQuality", "90");
tester.executeBehavior(next); //skip errors
}
wizardTester.setValue("view:cryptClassName", SCryptImplementation.class.getName());
tester.executeBehavior(next); //install step
checkErrors(tester, 0);
tester.executeBehavior(finish);
checkErrors(tester, 0);
}