List of usage examples for org.apache.wicket.ajax AjaxRequestTarget getPage
@Override Page getPage();
From source file:com.axway.ats.testexplorer.TestExplorerApplication.java
License:Apache License
@Override protected void init() { Locale.setDefault(Locale.US); getApplicationSettings().setPageExpiredErrorPage(PageExpiredErrorPage.class); getApplicationSettings().setInternalErrorPage(InternalErrorPage.class); // show internal error page rather than default developer page //TODO: use this line in PRODUCTION mode, by default in development mode is used ExceptionSettings.SHOW_EXCEPTION_PAGE // getExceptionSettings().setUnexpectedExceptionDisplay( ExceptionSettings.SHOW_INTERNAL_ERROR_PAGE ); mountPage("/runs", RunsPage.class); mountPage("/suites", SuitesPage.class); mountPage("/scenarios", ScenariosPage.class); mountPage("/testcases", TestcasesPage.class); mountPage("/testcase", TestcasePage.class); mountPage("/charts", ChartsBasePage.class); mountPage("/compare", ComparePage.class); mountPage("/compareStatistics", CompareTestcaseSystemStatisticsPage.class); mountPage("/runMessages", RunMessagePage.class); mountPage("/suiteMessages", SuiteMessagePage.class); mountPage("/machines", MachinesPage.class); mountPage("/runCopy", RunCopyPage.class); mountPage("/testcasesCopy", TestcasesCopyPage.class); mountPage("/reportSelect", SelectTestcaseReportPage.class); mountPage("/pageExpired", PageExpiredErrorPage.class); mountPage("/error", InternalErrorPage.class); mountPage("/dashboardhome", RunsByTypeDashboardHomePage.class); mountPage("/dashboardrun", RunsByTypeDashboardRunPage.class); mountPage("/dashboardsuite", RunsByTypeDashboardSuitePage.class); mountPage("/groups", TestcasesByGroupsPage.class); try {/*from w w w . ja va 2 s .co m*/ configProperties = new Properties(); configProperties.load(this.getClass().getClassLoader().getResourceAsStream("ats.config.properties")); } catch (IOException e) { LOG.error("Can't load config.properties file", e); } getAjaxRequestTargetListeners().add(new AjaxRequestTarget.IListener() { @Override public void onBeforeRespond(Map<String, Component> map, final AjaxRequestTarget target) { // if( !Session.get().getFeedbackMessages().isEmpty() ) { target.getPage().visitChildren(IFeedback.class, new IVisitor<Component, Void>() { public void component(final Component component, final IVisit<Void> visit) { if (component.getOutputMarkupId()) { target.appendJavaScript( "$('#" + component.getMarkupId() + "').effect('bounce', { times:5 }, 200);"); target.add(component); //visit.stop(); } visit.dontGoDeeper(); } }); } @Override public void onAfterRespond(Map<String, Component> map, IJavaScriptResponse response) { // Do nothing. } @Override public void updateAjaxAttributes(AbstractDefaultAjaxBehavior behavior, AjaxRequestAttributes attributes) { // TODO Auto-generated method stub } }); // load any available Test Explorer plugins TestExplorerPluginsRepo.getInstance(); }
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
/** * Common handler for errors during an Ajax submit */// w w w. ja v a 2 s . c om private void handleError(final AjaxRequestTarget target) { // Update feedback panel and components with errors target.addChildren(getPage(), FeedbackPanel.class); target.getPage().visitChildren(FormComponent.class, new IVisitor<Component, Void>() { @Override public void component(Component component, IVisit<Void> arg1) { if (component.hasErrorMessage()) { target.add(component); } } }); }
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
/** * Update the edit form/*from w w w . j ava 2 s. c om*/ */ private void updateForm(AjaxRequestTarget target) { // Refresh the drop down choice target.add(currentMessageIdDropdown); target.add(target.getPage() .get("config-contents:tabs:panel:upload-form:edit-form:table-container:usePersistance")); target.add( target.getPage().get("config-contents:tabs:panel:upload-form:edit-form:table-container:queueMode")); target.add(target.getPage() .get("config-contents:tabs:panel:upload-form:edit-form:table-container:messageType")); // Refresh the form editor.reloadModel(); MarkupContainer listEditorContainer = (MarkupContainer) target.getPage() .get("config-contents:tabs:panel:upload-form:edit-form:table-container:list-editor"); target.add(listEditorContainer); }
From source file:com.googlecode.wicket.jquery.ui.interaction.draggable.DraggableBehavior.java
License:Apache License
@Override public void onAjax(AjaxRequestTarget target, JQueryEvent event) { if (event instanceof DragStartEvent) { this.onDragStart(target); // register to all DroppableBehavior(s) // target.getPage().visitChildren(this.newDroppableBehaviorVisitor()); }//from w w w . j a v a2 s . c om else if (event instanceof DragStopEvent) { this.onDragStop(target); } }
From source file:com.googlecode.wicket.kendo.ui.interaction.draggable.DraggableBehavior.java
License:Apache License
@Override public void onAjax(AjaxRequestTarget target, JQueryEvent event) { if (event instanceof DraggableEvent) { DraggableEvent e = (DraggableEvent) event; if (e instanceof DragStartEvent) { // register to all DroppableBehavior(s) // Visits.visit(target.getPage(), this.newDroppableBehaviorVisitor()); this.listener.onDragStart(target, e.getTop(), e.getLeft()); }/*from ww w . j ava 2s. c o m*/ else if (e instanceof DragStopEvent) { this.listener.onDragStop(target, e.getTop(), e.getLeft()); } else if (e instanceof DragCancelEvent) { this.listener.onDragCancel(target, e.getTop(), e.getLeft()); } } }
From source file:com.kenai.wicketgae.web.CustomWebRequestCycle.java
License:Apache License
/** Manages to update the feedback panel on each request. */ @Override//from w w w . j a va 2 s.co m protected void onRequestTargetSet(final IRequestTarget requestTarget) { if (requestTarget instanceof AjaxRequestTarget) { final AjaxRequestTarget ajaxRequestTarget = (AjaxRequestTarget) requestTarget; final Page page = ajaxRequestTarget.getPage(); if (page != null && page instanceof MainPage) { ((MainPage) page).updateFeedbackPanel(ajaxRequestTarget); ajaxRequestTarget.appendJavascript("fadeInFeedback()"); } } }
From source file:com.servoy.j2db.server.headlessclient.dataui.AbstractServoyLastVersionAjaxBehavior.java
License:Open Source License
@Override protected final void respond(AjaxRequestTarget target) { if (String.valueOf(target.getPage().getCurrentVersionNumber()) .equals(RequestCycle.get().getRequest().getParameter(PVS))) { execute(target);/*from w w w .j a va 2 s .c o m*/ } }
From source file:it.av.eatt.web.page.FriendsPage.java
License:Apache License
/** * Constructor that is invoked when page is invoked without a session. * /* w ww. j a v a2s .c om*/ * @throws JackWicketException */ public FriendsPage() throws JackWicketException { super(); allRelations = userRelationService.getAllRelations(getLoggedInUser()); final Label noYetFriends = new Label("noYetFriends", getString("noYetFriends")) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible(allRelations.size() == 0); } }; noYetFriends.setOutputMarkupId(true); noYetFriends.setOutputMarkupPlaceholderTag(true); add(noYetFriends); final WebMarkupContainer friendsListContainer = new WebMarkupContainer("friendsListContainer"); friendsListContainer.setOutputMarkupId(true); add(friendsListContainer); friendsList = new PropertyListView<EaterRelation>("friendsList", allRelations) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<EaterRelation> item) { boolean isPendingFriendRequest = item.getModelObject().getStatus() .equals(EaterRelation.STATUS_PENDING) && item.getModelObject().getToUser().equals(getLoggedInUser()); item.add(new Label(EaterRelation.TO_USER + ".firstname")); item.add(new Label(EaterRelation.TO_USER + ".lastname")); item.add(new Label(EaterRelation.TYPE)); item.add(new Label(EaterRelation.STATUS)); // item.add(new Label(EaterRelation.TO_USER + ".userRelation")); item.add(new AjaxLink<EaterRelation>("remove", new Model<EaterRelation>(item.getModelObject())) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { try { ((FriendsPage) getPage()).userRelationService.remove(getModelObject()); allRelations = userRelationService.getAllRelations(getLoggedInUser()); ((FriendsPage) target.getPage()).friendsList.setModelObject(allRelations); noYetFriends.setVisible(allRelations.size() == 0); target.addComponent((noYetFriends)); target.addComponent((friendsListContainer)); // info(new StringResourceModel("info.userRelationRemoved", this, null).getString()); } catch (JackWicketException e) { error(new StringResourceModel("genericErrorMessage", this, null).getString()); } target.addComponent(((FriendsPage) target.getPage()).getFeedbackPanel()); } }); item.add(new AjaxLink<EaterRelation>("acceptFriend", new Model<EaterRelation>(item.getModelObject())) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { try { ((FriendsPage) getPage()).userRelationService .performFriendRequestConfirm(getModelObject()); allRelations = userRelationService.getAllRelations(getLoggedInUser()); ((FriendsPage) target.getPage()).friendsList.setModelObject(allRelations); noYetFriends.setVisible(allRelations.size() == 0); target.addComponent((noYetFriends)); target.addComponent((friendsListContainer)); // info(new StringResourceModel("info.userRelationRemoved", this, null).getString()); } catch (JackWicketException e) { error(new StringResourceModel("genericErrorMessage", this, null).getString()); } target.addComponent(((FriendsPage) target.getPage()).getFeedbackPanel()); } }.setVisible(isPendingFriendRequest)); item.add(new AjaxLink<EaterRelation>("ignoreFriendRequest", new Model<EaterRelation>(item.getModelObject())) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { try { ((FriendsPage) getPage()).userRelationService .performFriendRequestIgnore(getModelObject()); allRelations = userRelationService.getAllRelations(getLoggedInUser()); ((FriendsPage) target.getPage()).friendsList.setModelObject(allRelations); noYetFriends.setVisible(allRelations.size() == 0); target.addComponent((noYetFriends)); target.addComponent((friendsListContainer)); // info(new StringResourceModel("info.userRelationRemoved", this, null).getString()); } catch (JackWicketException e) { error(new StringResourceModel("genericErrorMessage", this, null).getString()); } target.addComponent(((FriendsPage) target.getPage()).getFeedbackPanel()); } }.setVisible(isPendingFriendRequest)); } }; friendsListContainer.add(friendsList); }
From source file:it.av.youeat.web.page.FriendsPage.java
License:Apache License
/** * Constructor that is invoked when page is invoked without a session. * //from w ww . j av a2 s . c o m */ public FriendsPage() { super(); add(getFeedbackPanel()); final Label noYetFriends = new Label("noYetFriends", getString("noYetFriends")) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible(eaterRelationService.getAllRelations(getLoggedInUser()).size() == 0); } }; noYetFriends.setOutputMarkupId(true); noYetFriends.setOutputMarkupPlaceholderTag(true); add(noYetFriends); final ModalWindow sendMessageMW = SendMessageModalWindow.getNewModalWindow("sendMessagePanel"); add(sendMessageMW); final WebMarkupContainer friendsListContainer = new WebMarkupContainer("friendsListContainer"); friendsListContainer.setOutputMarkupId(true); add(friendsListContainer); friendsList = new PropertyListView<EaterRelation>("friendsList", new RelationsModel()) { @Override protected void populateItem(final ListItem<EaterRelation> item) { // if the dialog contains unread message, use a different CSS style if (item.getModelObject().getStatus().equals(EaterRelation.STATUS_PENDING)) { item.add(new AttributeAppender("class", new Model<String>("rowMessageUnread"), " ")); } boolean isPendingFriendRequest = item.getModelObject().getStatus() .equals(EaterRelation.STATUS_PENDING) && item.getModelObject().getToUser().equals(getLoggedInUser()); BookmarkablePageLink linkToUser = new BookmarkablePageLink("linkToUser", EaterViewPage.class, new PageParameters( YoueatHttpParams.YOUEAT_ID + "=" + item.getModelObject().getToUser().getId())); item.add(linkToUser); final Eater eaterToshow; if (getLoggedInUser().equals(item.getModelObject().getToUser())) { eaterToshow = item.getModelObject().getFromUser(); } else { eaterToshow = item.getModelObject().getToUser(); } linkToUser.add(new Label(EaterRelation.TO_USER + ".firstname", eaterToshow.getFirstname())); linkToUser.add(new Label(EaterRelation.TO_USER + ".lastname", eaterToshow.getLastname())); item.add(ImagesAvatar.getAvatar("avatar", eaterToshow, this.getPage(), true)); item.add(new Label(EaterRelation.TYPE)); item.add(new Label(EaterRelation.STATUS)); // item.add(new Label(EaterRelation.TO_USER + ".userRelation")); item.add(new AjaxFallbackLink<EaterRelation>("remove", new Model<EaterRelation>(item.getModelObject())) { @Override public void onClick(AjaxRequestTarget target) { try { ((FriendsPage) getPage()).eaterRelationService.remove(getModelObject()); noYetFriends.setVisible(friendsList.getModelObject().size() == 0); info(getString("info.userRelationRemoved")); } catch (YoueatException e) { error(new StringResourceModel("genericErrorMessage", this, null).getString()); } if (target != null) { target.addComponent(getFeedbackPanel()); target.addComponent((noYetFriends)); target.addComponent((friendsListContainer)); target.addComponent(((FriendsPage) target.getPage()).getFeedbackPanel()); } } }.setVisible(!isPendingFriendRequest)); item.add(new AjaxFallbackLink<EaterRelation>("acceptFriend", new Model<EaterRelation>(item.getModelObject())) { @Override public void onClick(AjaxRequestTarget target) { try { ((FriendsPage) getPage()).eaterRelationService .performFriendRequestConfirm(getModelObject()); noYetFriends.setVisible(friendsList.getModelObject().size() == 0); // info(new StringResourceModel("info.userRelationRemoved", this, null).getString()); } catch (YoueatException e) { error(new StringResourceModel("genericErrorMessage", this, null).getString()); } if (target != null) { target.addComponent((noYetFriends)); target.addComponent((friendsListContainer)); target.addComponent(((FriendsPage) target.getPage()).getFeedbackPanel()); } } }.setVisible(isPendingFriendRequest)); item.add(new AjaxFallbackLink<EaterRelation>("ignoreFriendRequest", new Model<EaterRelation>(item.getModelObject())) { @Override public void onClick(AjaxRequestTarget target) { try { ((FriendsPage) getPage()).eaterRelationService .performFriendRequestIgnore(getModelObject()); noYetFriends.setVisible(friendsList.getModelObject().size() == 0); // info(new StringResourceModel("info.userRelationRemoved", this, null).getString()); } catch (YoueatException e) { error(new StringResourceModel("genericErrorMessage", this, null).getString()); } if (target != null) { target.addComponent((noYetFriends)); target.addComponent((friendsListContainer)); target.addComponent(((FriendsPage) target.getPage()).getFeedbackPanel()); } } }.setVisible(isPendingFriendRequest)); item.add(new SendMessageButton("sendMessage", getLoggedInUser(), eaterToshow, item.getModelObject(), sendMessageMW)); } }; friendsListContainer.add(friendsList); add(new AjaxFallbackLink<String>("goSearchFriendPage") { @Override public void onClick(AjaxRequestTarget target) { setResponsePage(SearchFriendPage.class); } }); // Activities try { activities = activityService.findByEaterFriendAndEater(getLoggedInUser(), activityPagingUser.getFirstResult(), activityPagingUser.getMaxResults()); } catch (YoueatException e) { activities = new ArrayList<ActivityEaterRelation>(); error(new StringResourceModel("error.errorGettingListActivities", this, null).getString()); } activitiesListContainer = new WebMarkupContainer("activitiesListContainer"); activitiesListContainer.setOutputMarkupId(true); add(activitiesListContainer); activitiesList = new ActivitiesRelationListView("activitiesList", activities); activitiesList.setOutputMarkupId(true); activitiesListContainer.add(activitiesList); AjaxFallbackLink<String> moreActivitiesLink = new AjaxFallbackLink<String>("moreActivitiesLink") { @Override public void onClick(AjaxRequestTarget target) { activityPagingUser.addNewPage(); try { activities.addAll(activityService.findByEaterFriendAndEater(getLoggedInUser(), activityPagingUser.getFirstResult(), activityPagingUser.getMaxResults())); if (target != null) { target.addComponent(activitiesListContainer); } } catch (YoueatException e) { error(new StringResourceModel("error.errorGettingListActivities", this, null).getString()); } } }; activitiesListContainer.add(moreActivitiesLink); }
From source file:it.av.youeat.web.page.MessageListPage.java
License:Apache License
public MessageListPage() { super();// w w w . ja v a 2 s . com add(getFeedbackPanel()); final Label noYetMessages = new Label("noYetMessages", getString("noMessages")) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible(getLastMessages().size() == 0); } }; noYetMessages.setOutputMarkupId(true); noYetMessages.setOutputMarkupPlaceholderTag(true); add(noYetMessages); final WebMarkupContainer messagesListContainer = new WebMarkupContainer("messagesListContainer"); messagesListContainer.setOutputMarkupPlaceholderTag(true); add(messagesListContainer); messageList = new PropertyListView<Message>("messagesList", new MessagesModel()) { @Override protected void populateItem(final ListItem<Message> item) { // if the dialog contains unread message, use a different CSS style if (!(item.getModelObject().getSender().equals(getLoggedInUser())) && item.getModelObject().getReadTime() == null) { item.add(new AttributeAppender("class", new Model<String>("rowMessageUnread"), " ")); } Eater sender = item.getModelObject().getSender(); Eater recipient = item.getModelObject().getDialog().checkCounterpart(sender); item.add(ImagesAvatar.getAvatar("avatar", sender, this.getPage(), true)); item.add(new BookmarkablePageLink("linkToUser", EaterViewPage.class, EaterUtil.createParamsForEater(sender)).add(new Label(Message.SENDER_FIELD))); BookmarkablePageLink recipientLink = new BookmarkablePageLink("linkToRecipientUser", EaterViewPage.class, EaterUtil.createParamsForEater(recipient)); recipientLink.add(new Label("recipient", recipient.toString())); //visible only on Sent page recipientLink.setVisible(!inBox); item.add(recipientLink); item.add(new Label(Message.SENTTIME_FIELD)); item.add(new OpenMessage("openMessageTitle", new Model<Message>(item.getModelObject()), item) .add(new Label(Message.TITLE_FIELD))); String messageBodyShort = StringUtils.abbreviate( templateUtil.resolveTemplateEater(item.getModelObject(), false, null, getWebPage()), 150); item.add(new OpenMessage("openMessage", new Model<Message>(item.getModelObject()), item) .add(new Label(Message.BODY_FIELD, messageBodyShort))); item.add(new AjaxFallbackLink<Message>("remove", new Model<Message>(item.getModelObject())) { @Override public void onClick(AjaxRequestTarget target) { try { ((MessageListPage) getPage()).dialogService.delete(getModelObject().getDialog(), getLoggedInUser()); noYetMessages.setVisible(getLastMessages().size() == 0); info(getString("info.userRelationRemoved")); } catch (YoueatException e) { error(new StringResourceModel("genericErrorMessage", this, null).getString()); } if (target != null) { target.addComponent(getFeedbackPanel()); target.addComponent((noYetMessages)); target.addComponent((messagesListContainer)); target.addComponent(((MessageListPage) target.getPage()).getFeedbackPanel()); } } }); item.add(new OpenMessage("open", new Model<Message>(item.getModelObject()), item)); } }; messagesListContainer.add(messageList); add(new BookmarkablePageLink("goSearchFriendPage", SearchFriendPage.class)); long numberUnreadMsgs = messageService.countUnreadMessages(getLoggedInUser()); final WebMarkupContainer separator = new WebMarkupContainer("separator"); separator.setVisible(numberUnreadMsgs > 0); final Label unreadMsgs = new Label("unreadMessages", new Model<Long>(numberUnreadMsgs)); unreadMsgs.setOutputMarkupPlaceholderTag(true); unreadMsgs.setVisible(numberUnreadMsgs > 0); AjaxFallbackLink<String> inboxButton = new AjaxFallbackLink<String>("inbox") { @Override public void onClick(AjaxRequestTarget target) { inBox = true; noYetMessages.setVisible(getLastMessages().size() == 0); if (target != null) { target.addComponent((messagesListContainer)); target.addComponent((noYetMessages)); } } }; add(inboxButton); add(new Label("numberMessages", Integer.toString(messageList.getModel().getObject().size()))); add(unreadMsgs); add(separator); add(new AjaxFallbackLink<String>("sentitems") { @Override public void onClick(AjaxRequestTarget target) { inBox = false; noYetMessages.setVisible(getLastMessages().size() == 0); if (target != null) { target.addComponent((messagesListContainer)); target.addComponent((noYetMessages)); } } }); long numberSentMsgs = dialogService.countCreatedDialogs(getLoggedInUser()); add(new Label("numberSentMessages", Long.toString(numberSentMsgs))); }