List of usage examples for org.apache.wicket.ajax AjaxRequestTarget addListener
void addListener(AjaxRequestTarget.IListener listener);
From source file:com.aplombee.QuickViewBase.java
License:Apache License
/** * * less complex/preferred/clear solution would have been checking if listener is already added in AjaxRequestTarget but * since there is no getter for IListeners,there is no way to know listener is added ,it might be added in later versions * see WICKET-4800//w w w . ja v a 2 s. co m * * @return Synchronizer */ public Synchronizer getSynchronizer() { AjaxRequestTarget target = getAjaxRequestTarget(); if (target == null) { return null; } Synchronizer listener = (Synchronizer) getRequestCycle().getMetaData(synchronizerKey); if (listener == null) { listener = new Synchronizer(_getParent()); getRequestCycle().setMetaData(synchronizerKey, listener); target.addListener(listener); } return listener; }
From source file:com.servoy.j2db.server.headlessclient.WebClientsApplication.java
License:Open Source License
@Override public AjaxRequestTarget newAjaxRequestTarget(Page page) { AjaxRequestTarget target = new CloseableAjaxRequestTarget(page); target.addListener(new AjaxEnclosureListener()); return target; }
From source file:it.av.es.web.BasePageSimple.java
License:Apache License
/** * Construct./* w ww . ja va 2 s . co m*/ */ public BasePageSimple() { HtmlUtil.fixInitialHtml(this); titlePage = new Label("pageTitle", ":: EasyTrack - Eurocargo ::"); add(titlePage); WebMarkupContainer googleCode = new WebMarkupContainer("googleCode"); add(googleCode); googleCode.setVisible( getApplication().getConfigurationType().compareTo(RuntimeConfigurationType.DEPLOYMENT) >= 0); feedbackPanel = new CustomFeedbackPanel("feedBackPanel"); feedbackPanel.add(new AbstractDefaultAjaxBehavior() { // @Override // public void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target) { // } // // @Override // public void onAfterRespond(Map<String, Component> map, IJavaScriptResponse response) { // response.addJavaScript("jQuery('#" + electionContainer.getMarkupId() + "').fadeTo(300, 0.5, function() {})"); // response.addJavaScript("jQuery('#" + electionContainer.getMarkupId() + "').fadeTo(300, 1.0, function() {})"); // } // @Override protected void respond(AjaxRequestTarget target) { target.appendJavaScript( "jQuery('#" + feedbackPanel.getMarkupId() + "').fadeTo(300, 0.5, function() {})"); // register the onSuccess listener that will execute Handlebars logic target.addListener(new IListener() { @Override public void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target) { System.out.println(""); } @Override public void onAfterRespond(Map<String, Component> map, IJavaScriptResponse response) { response.addJavaScript( "jQuery('#" + feedbackPanel.getMarkupId() + "').fadeTo(300, 0.5, function() {})"); response.addJavaScript( "jQuery('#" + feedbackPanel.getMarkupId() + "').fadeTo(300, 1.0, function() {})"); } }); } }); ; feedbackPanel.setOutputMarkupId(true); feedbackPanel.setOutputMarkupPlaceholderTag(true); add(feedbackPanel); session = ((SecuritySession) getSession()); loggedInUser = session.getLoggedInUser(); if (new CookieUtils().load(CookieUtil.LANGUAGE) != null) { getSession().setLocale(new Locale(new CookieUtils().load(CookieUtil.LANGUAGE))); } else { if (loggedInUser != null) { ((WebResponse) RequestCycle.get().getResponse()) .addCookie((new Cookie(CookieUtil.LANGUAGE, loggedInUser.getLanguage().getLanguage()))); getSession().setLocale(new Locale(loggedInUser.getLanguage().getLanguage())); } } //BookmarkablePageLink goAccount = new BookmarkablePageLink<String>("goAccount", UserAccountPage.class, goAccountParameters); // Label name = new Label("loggedInUser", loggedInUser != null ? loggedInUser.getFirstname() + " " +loggedInUser.getLastname() : ""); // add(name); add(new BookmarkablePageLink<String>("goUserManagerPage", UserManagerPage.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(UserManagerPage.class))); } }); add(new BookmarkablePageLink<String>("goProjectManagerPage", ProjectManagerPage.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(ProjectManagerPage.class))); } }); // add(new BookmarkablePageLink<String>("goProductManagerPage", ProductManagerPage.class) { // @Override // protected void onBeforeRender() { // super.onBeforeRender(); // setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() // .isInstantiationAuthorized(ProductManagerPage.class))); // } // }); add(new BookmarkablePageLink<String>("goOrderManagerPage", OrderManagerPage.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(OrderManagerPage.class))); } }); add(new BookmarkablePageLink<String>("goPlaceNewOrderPage", PlaceNewOrderPage.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(PlaceNewOrderPage.class))); } }); add(new BookmarkablePageLink<String>("goCustomerManagerPage", CustomerManagerPage.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(CustomerManagerPage.class))); } }); add(new BookmarkablePageLink<String>("goCustomerNewPage", CustomerPage.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(CustomerPage.class))); } }); add(new BookmarkablePageLink<String>("goSignOut", SignOut.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible((getApplication().getSecuritySettings().getAuthorizationStrategy() .isInstantiationAuthorized(SignOut.class))); } }); add(new BookmarkablePageLink<String>("goUserAccountPage", UserAccountPage.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible(loggedInUser != null && (getApplication().getSecuritySettings() .getAuthorizationStrategy().isInstantiationAuthorized(UserAccountPage.class))); if (loggedInUser != null) { add(AttributeModifier.replace("value", loggedInUser.getFirstname() + " " + loggedInUser.getLastname())); } } }); add(new BookmarkablePageLink<String>("goGroupManagerPage", GroupManagerPage.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible(loggedInUser != null && (getApplication().getSecuritySettings() .getAuthorizationStrategy().isInstantiationAuthorized(GroupManagerPage.class))); } }); add(new BookmarkablePageLink<String>("goGroupMembersManagerPage", GroupMembersManagerPage.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible(loggedInUser != null && (getApplication().getSecuritySettings() .getAuthorizationStrategy().isInstantiationAuthorized(GroupMembersManagerPage.class))); } }); add(new BookmarkablePageLink<String>("goProductFamilyManagerPage", ProductFamilyManagerPage.class) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible(loggedInUser != null && (getApplication().getSecuritySettings() .getAuthorizationStrategy().isInstantiationAuthorized(ProductFamilyManagerPage.class))); } }); // BookmarkablePageLink goInfo = new BookmarkablePageLink("goInfo", AboutPage.class); // add(goInfo); // // BookmarkablePageLink goPrivacy = new BookmarkablePageLink("goPrivacy", PrivacyPage.class); // add(goPrivacy); }
From source file:org.hippoecm.frontend.plugins.yui.layout.UnitBehavior.java
License:Apache License
@Override public void bind(final Component component) { super.bind(component); // re-render complete wireframe during the render phase AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class); if (target != null) { target.addListener(new IListener() { public void onBeforeRespond(Map map, AjaxRequestTarget target) { if (target.getPage() != component.findParent(Page.class)) { return; }/*from w ww. j ava 2s . co m*/ IWireframe wireframe = WireframeUtils.getParentWireframe(component); if (wireframe != null) { wireframe.render(target); } else { log.warn("Unable to find parent wireframe-behavior"); } } public void onAfterRespond(Map map, AjaxRequestTarget.IJavaScriptResponse response) { } }); } }
From source file:org.obiba.onyx.quartz.core.wicket.layout.impl.standard.DefaultPageLayout.java
License:Open Source License
/** * Set the focus to the first input of the first question. * @param target//from w w w . ja v a 2 s . c o m */ private void setFocus(final AjaxRequestTarget target) { if (target == null) return; // must do that after rendering, otherwise there is nothing populated in the views. target.addListener(new AjaxRequestTarget.IListener() { public void onAfterRespond(Map<String, Component> map, IJavascriptResponse response) { DefaultPageLayout.this.visitChildren(new IVisitor<Component>() { public Object component(Component component) { if (component instanceof Radio || component instanceof CheckBox || component instanceof DropDownChoice<?>) { target.focusComponent(component); return STOP_TRAVERSAL; } return null; } }); } public void onBeforeRespond(Map<String, Component> map, AjaxRequestTarget target1) { } }); }
From source file:org.wicketstuff.dojo11.AbstractRequireDojoBehavior.java
License:Apache License
/** * this method is used to interpret dojoWidgets rendered via XMLHTTPRequest * FIXME : in TargetRefresherMPanager differency AbstractRequire and DojoWidgetBehavior *///www. ja va2 s . c o m protected void onComponentRendered() { // if a Dojo Widget is rerender needs to run some javascript to refresh // it. TargetRefresherManager contains top level dojo widgets AjaxRequestTarget target = AjaxRequestTarget.get(); if (target != null) { //and register listener DojoTargetRefresherManager mgr = DojoTargetRefresherManager.get(); mgr.addComponent(getComponent()); target.addListener(mgr); onComponentReRendered(target); } }
From source file:org.wicketstuff.push.dojo.AbstractRequireDojoBehavior.java
License:Apache License
/** * this method is used to interpret dojoWidgets rendered via XMLHTTPRequest * FIXME : in TargetRefresherMPanager differency AbstractRequire and * DojoWidgetBehavior/*from w w w .ja v a 2 s .c o m*/ */ @Override protected void onComponentRendered() { // if a Dojo Widget is rerender needs to run some javascript to refresh // it. TargetRefresherManager contains top level dojo widgets AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class); if (target != null) { // and register listener target.addListener(TargetRefresherManager.getInstance()); TargetRefresherManager.getInstance().addComponent(getComponent()); onComponentReRendered(target); } }