List of usage examples for org.apache.wicket.ajax.attributes AjaxRequestAttributes getAjaxCallListeners
public List<IAjaxCallListener> getAjaxCallListeners()
From source file:au.com.scds.isis.viewer.wicket.ui.components.entity.properties.MyEntityPropertiesForm.java
License:Apache License
private void addButtons(MarkupContainer markupContainer) { // edit button editButton = new AjaxButtonWithOnError(ID_EDIT_BUTTON, new ResourceModel("editLabel")) { private static final long serialVersionUID = 1L; @Override/*from ww w . j a v a2s . c o m*/ public void validate() { // same logic as in cancelButton; should this be factored out? try { getEntityModel().load(ConcurrencyChecking.CHECK); } catch (ConcurrencyException ex) { getMessageBroker().addMessage("Object changed by " + ex.getOid().getVersion().getUser() + ", automatically reloading"); getEntityModel().load(ConcurrencyChecking.NO_CHECK); } super.validate(); } @Override public void onSubmit(final AjaxRequestTarget target, final Form<?> form) { getEntityModel().resetPropertyModels(); toEditMode(target); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new org.apache.wicket.ajax.attributes.AjaxCallListener() { private static final long serialVersionUID = 1L; @Override public CharSequence getSuccessHandler(Component component) { // scroll to the top of the entity panel return "$('html, body').animate({" + " scrollTop: $('.entityIconAndTitlePanel').offset().top" + " }, 1000);"; } }); } }; editButton.add(new Label("editLabel", editButton.getModel())); markupContainer.add(editButton); // ok button okButton = new AjaxButtonForValidate(ID_OK_BUTTON, new ResourceModel("okLabel")); markupContainer.add(okButton); // cancel button cancelButton = new AjaxButtonForCancel(ID_CANCEL_BUTTON, new ResourceModel("cancelLabel")) { private static final long serialVersionUID = 1L; @Override public void validate() { // same logic as in editButton; should this be factored out? try { getEntityModel().load(ConcurrencyChecking.CHECK); } catch (ConcurrencyException ex) { getMessageBroker().addMessage("Object changed by " + ex.getOid().getVersion().getUser() + ", automatically reloading"); getEntityModel().load(ConcurrencyChecking.NO_CHECK); } super.validate(); } @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { Session.get().getFeedbackMessages().clear(); getForm().clearInput(); getForm().visitFormComponentsPostOrder(new IVisitor<FormComponent<?>, Void>() { @Override public void component(FormComponent<?> formComponent, IVisit<Void> visit) { if (formComponent instanceof CancelHintRequired) { final CancelHintRequired cancelHintRequired = (CancelHintRequired) formComponent; cancelHintRequired.onCancel(); } } }); try { getEntityModel().resetPropertyModels(); } catch (RuntimeException ex) { throw ex; } toViewMode(target); } }; markupContainer.add(cancelButton); okButton.setOutputMarkupPlaceholderTag(true); editButton.setOutputMarkupPlaceholderTag(true); cancelButton.setOutputMarkupPlaceholderTag(true); // flush any JGrowl messages (typically concurrency exceptions) if they // are added. okButton.add(new JGrowlBehaviour()); editButton.add(new JGrowlBehaviour()); cancelButton.add(new JGrowlBehaviour()); }
From source file:ca.travelagency.components.formdetail.DeleteLink.java
License:Apache License
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); String message = getLocalizer().getString("deleteConfirm.message", DeleteLink.this); ConfirmDialog confirmDialog = new ConfirmDialog(message); attributes.getAjaxCallListeners().add(confirmDialog); }
From source file:ca.travelagency.components.formdetail.SaveButtonDetail.java
License:Apache License
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new BlockUIDecorator()); }
From source file:ca.travelagency.invoice.items.ItemRowPanel.java
License:Apache License
private IndicatingAjaxLink<Void> makeMoveLink(final String id, final ItemsPanel itemsPanel) { IndicatingAjaxLink<Void> link = new IndicatingAjaxLink<Void>(id) { private static final long serialVersionUID = 1L; @Override//from ww w. jav a2 s . c o m public void onClick(AjaxRequestTarget target) { if (MOVE_UP.equals(id)) { itemsPanel.moveUp(target, getInvoiceItem()); } else { itemsPanel.moveDown(target, getInvoiceItem()); } } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new BlockUIDecorator()); } }; ContextRelativeResource contextRelativeResource = new ContextRelativeResource( "images/" + (MOVE_UP.equals(id) ? "move_up.png" : "move_down.png")); link.add(new Image(MOVE_LABEL, contextRelativeResource)); return link; }
From source file:com.aplombee.navigator.AjaxComponentScrollEventBehavior.java
License:Apache License
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new ParentScrollListener()); }
From source file:com.aplombee.navigator.AjaxComponentScrollEventBehaviorTest.java
License:Apache License
@Test(groups = { "wicketTests" }) public void updateAjaxAttributes() { AjaxComponentScrollEventBehavior behavior = new AjaxComponentScrollEventBehavior() { @Override//from w ww . j a v a 2s . c o m protected void onScroll(AjaxRequestTarget target) { } }; AjaxRequestAttributes attributes = new AjaxRequestAttributes(); behavior.updateAjaxAttributes(attributes); boolean isAdded = false; for (IAjaxCallListener listener : attributes.getAjaxCallListeners()) { if (listener instanceof AjaxComponentScrollEventBehavior.ParentScrollListener) { isAdded = true; } } Assert.assertTrue(isAdded); }
From source file:com.aplombee.navigator.AjaxPageScrollEventBehavior.java
License:Apache License
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new PageScrollListener()); }
From source file:com.aplombee.navigator.AjaxPageScrollEventBehaviorTest.java
License:Apache License
@Test(groups = { "wicketTests" }) public void updateAjaxAttributes() { AjaxPageScrollEventBehavior behavior = new AjaxPageScrollEventBehavior() { @Override//from www . j av a 2 s .co m protected void onScroll(AjaxRequestTarget target) { } }; AjaxRequestAttributes attributes = new AjaxRequestAttributes(); behavior.updateAjaxAttributes(attributes); boolean isAdded = false; for (IAjaxCallListener listener : attributes.getAjaxCallListeners()) { if (listener instanceof AjaxPageScrollEventBehavior.PageScrollListener) { isAdded = true; } } Assert.assertTrue(isAdded); }
From source file:com.axway.ats.testexplorer.pages.model.ColumnsDialog.java
License:Apache License
@SuppressWarnings({ "rawtypes" }) public ColumnsDialog(String id, final DataGrid grid, List<TableColumn> columnDefinitions) { super(id);/*from w w w .j a v a 2 s . com*/ setOutputMarkupId(true); this.dbColumnDefinitions = columnDefinitions; DataView<TableColumn> table = new DataView<TableColumn>("headers", new ListDataProvider<TableColumn>(dbColumnDefinitions), 100) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<TableColumn> item) { final TableColumn column = item.getModelObject(); item.add(new CheckBox("visible", new PropertyModel<Boolean>(column, "visible"))); item.add(new Label("columnName", new PropertyModel<String>(column, "columnName"))); item.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { TableColumn tableColumn = (TableColumn) this.getComponent().getDefaultModelObject(); tableColumn.setVisible(!tableColumn.isVisible()); if (tableColumn.isVisible()) { item.add(AttributeModifier.replace("class", "selected")); } else { item.add(AttributeModifier.replace("class", "notSelected")); } grid.getColumnState().setColumnVisibility(tableColumn.getColumnId(), tableColumn.isVisible()); target.add(grid); target.add(this.getComponent()); open(target); } }); item.setOutputMarkupId(true); if (column.isVisible()) { item.add(AttributeModifier.replace("class", "selected")); } else { item.add(AttributeModifier.replace("class", "notSelected")); } } }; add(table); final Form<Void> columnDefinitionsForm = new Form<Void>("columnDefinitionsForm"); add(columnDefinitionsForm); AjaxSubmitLink saveButton = new AjaxSubmitLink("saveButton", columnDefinitionsForm) { private static final long serialVersionUID = 1L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); AjaxCallListener ajaxCallListener = new AjaxCallListener(); ajaxCallListener.onPrecondition("getTableColumnDefinitions(); "); attributes.getAjaxCallListeners().add(ajaxCallListener); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { String columnDefinitionsString = form.getRequest().getPostParameters() .getParameterValue("columnDefinitions").toString(); List<TableColumn> jsColDefinitions = asList(columnDefinitionsString); orderTableColumns(dbColumnDefinitions, jsColDefinitions); try { saveColumnDefinitionsToDb(jsColDefinitions); modifyDBColumnDefinitionList(jsColDefinitions); } catch (DatabaseAccessException dae) { throw new RuntimeException("Unable to save table Column definitions in db: " + ((TestExplorerSession) Session.get()).getDbName(), dae); } catch (SQLException sqle) { throw new RuntimeException("Unable to save table Column definitions in db: " + ((TestExplorerSession) Session.get()).getDbName(), sqle); } close(target); } }; add(AttributeModifier.append("class", "runsTableColDialogDivWrapper")); columnDefinitionsForm.add(saveButton); add(new Behavior() { private static final long serialVersionUID = 1L; @Override public void renderHead(Component component, IHeaderResponse response) { if (autoAddToHeader()) { String script = "jQuery.fn.center=function(){" + "this.css(\"position\",\"absolute\");" + "this.css(\"top\",(jQuery(window).height()-this.height())/2+jQuery(window).scrollTop()+\"px\");" + "this.css(\"left\",(jQuery(window).width()-this.width())/2+jQuery(window).scrollLeft()+\"px\");" + "return this};"; String css = "#settingsoverlay,.settingsoverlay,#settingsoverlay_high," + ".settingsoverlay_high{filter:Alpha(Opacity=40);" + "-moz-opacity:.4;opacity:.4;background-color:#444;display:none;position:absolute;" + "left:0;top:0;width:100%;height:100%;text-align:center;z-index:5000;}" + "#settingsoverlay_high,.settingsoverlay_high{z-index:6000;}" + "#settingsoverlaycontent,#settingsoverlaycontent_high{display:none;z-index:5500;" + "text-align:center;}.settingsoverlaycontent," + ".settingsoverlaycontent_high{display:none;z-index:5500;text-align:left;}" + "#settingsoverlaycontent_high,.settingsoverlaycontent_high{z-index:6500;}" + "#settingsoverlaycontent .modalborder," + "#settingsoverlaycontent_high .modalborder{padding:15px;width:300px;" + "border:1px solid #444;background-color:white;" + "-webkit-box-shadow:0 0 10px rgba(0,0,0,0.8);-moz-box-shadow:0 0 10px rgba(0,0,0,0.8);" + "box-shadow:0 0 10px rgba(0,0,0,0.8);" + "filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=5,OffY=5,Color='gray');" + "-ms-filter:\"progid:DXImageTransform.Microsoft.dropshadow(OffX=5,OffY=5,Color='gray')\";}"; response.render(JavaScriptHeaderItem.forScript(script, null)); response.render(CssHeaderItem.forCSS(css, null)); if (isSupportIE6()) { response.render(JavaScriptHeaderItem .forReference(new PackageResourceReference(getClass(), "jquery.bgiframe.js"))); } } response.render(OnDomReadyHeaderItem.forScript(getJS())); } private String getJS() { StringBuilder sb = new StringBuilder(); sb.append("if (jQuery('#").append(getDivId()) .append("').length == 0) { jQuery(document.body).append('") .append(getDiv().replace("'", "\\'")).append("'); }"); return sb.toString(); } private String getDivId() { return getMarkupId() + "_ovl"; } private String getDiv() { if (isClickBkgToClose()) { return ("<div id=\"" + getDivId() + "\" class=\"settingsoverlayCD\" onclick=\"" + getCloseString() + "\"></div>"); } else { return ("<div id=\"" + getDivId() + "\" class=\"settingsoverlayCD\"></div>"); } } }); }
From source file:com.axway.ats.testexplorer.pages.model.PagingToolbar.java
License:Apache License
private void addColumnsDialog(final List<TableColumn> dbColumnDefinitions) { final MainDataGrid grid = getDataGrid(); Form<Object> form = new Form<Object>("columnsForm"); add(form);/*from w ww . ja v a 2 s . com*/ final ColumnsDialog dialog = new ColumnsDialog("modal", grid, dbColumnDefinitions); dialog.setClickBkgToClose(true); form.add(dialog); AjaxButton openChColumnsDialogButton = new AjaxButton("chColsButton", new Model<String>("Change columns")) { private static final long serialVersionUID = 1L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); AjaxCallListener ajaxCallListener = new AjaxCallListener(); ajaxCallListener.onPrecondition("getTableColumnDefinitions(); "); attributes.getAjaxCallListeners().add(ajaxCallListener); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { // get column definitions from the JavaScript String columnDefinitionString = form.getRequest().getPostParameters() .getParameterValue("columnDefinitions").toString(); // as List List<TableColumn> jsColumnDefinitions = dialog.asList(columnDefinitionString); for (TableColumn colDefinition : dbColumnDefinitions) { if (jsColumnDefinitions.contains(colDefinition)) { // add column id jsColumnDefinitions.get(jsColumnDefinitions.indexOf(colDefinition)) .setColumnId(colDefinition.getColumnId()); } } //update column indexes according to the JavaScript result ColumnsState cs = grid.getColumnState(); int index; if (cs.getEntry("check") != null) { index = 1; } else { index = 0; } for (TableColumn col : jsColumnDefinitions) { cs.setColumnIndex(col.getColumnId(), index++); cs.setColumnWidth(col.getColumnId(), col.getInitialWidth()); } grid.setColumnState(cs); //reload grid target.add(grid); //open column selection dialog dialog.open(target); } }; form.add(openChColumnsDialogButton); }