org.apache.wicket.ajax.attributes.AjaxRequestAttributes Java Examples
The following examples show how to use
org.apache.wicket.ajax.attributes.AjaxRequestAttributes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SourceViewPanel.java From onedev with MIT License | 7 votes |
@Override public WebMarkupContainer newAdditionalActions(String id) { WebMarkupContainer actions = new Fragment(id, "actionsFrag", this); if (hasOutline()) { actions.add(new CheckBox("outline", Model.of(isOutlineVisibleInitially())).add(new OnChangeAjaxBehavior() { @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setMethod(Method.POST); } @Override protected void onUpdate(AjaxRequestTarget target) { toggleOutline(target); } })); } else { actions.add(new WebMarkupContainer("outline").setVisible(false)); } return actions; }
Example #2
Source File: GbAjaxButton.java From sakai with Educational Community License v2.0 | 6 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new AjaxCallListener() // disable the button right away after clicking it // and mark on it if the window is unloading .onBefore( String.format( "$('#%s').prop('disabled', true);" + "$(window).on('beforeunload', function() {" + "$('#%s').data('unloading', true).prop('disabled', true)});", getMarkupId(), getMarkupId())) // if the page is unloading, keep it disabled, otherwise // add a slight delay in re-enabling it, just in case it succeeded // and there's a delay in closing a parent modal .onComplete( String.format("setTimeout(function() {" + "if (!$('#%s').data('unloading')) $('#%s').prop('disabled',false);" + "}, 1000)", getMarkupId(), getMarkupId()))); }
Example #3
Source File: KeyPressBehavior.java From AppStash with Apache License 2.0 | 6 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); IAjaxCallListener listener = new AjaxCallListener() { @Override public CharSequence getPrecondition(Component component) { //this javascript code evaluates wether an ajaxcall is necessary. //Here only by keyocdes for F9 and F10 return "var keycode = Wicket.Event.keyCode(attrs.event);" + "if ((keycode == 112) || (keycode == 113) || (keycode == 114) || (keycode == 115))" + " return true;" + "else" + " return false;"; } }; attributes.getAjaxCallListeners().add(listener); //Append the pressed keycode to the ajaxrequest attributes.getDynamicExtraParameters() .add("var eventKeycode = Wicket.Event.keyCode(attrs.event);" + "return {keycode: eventKeycode};"); //whithout setting, no keyboard events will reach any inputfield attributes.setPreventDefault(true); }
Example #4
Source File: SearchClausePanel.java From syncope with Apache License 2.0 | 6 votes |
public void enableSearch(final IEventSink resultContainer) { this.resultContainer = resultContainer; this.searchButton.setEnabled(true); this.searchButton.setVisible(true); field.add(PREVENT_DEFAULT_RETURN); field.add(new AjaxEventBehavior(Constants.ON_KEYDOWN) { private static final long serialVersionUID = -7133385027739964990L; @Override protected void onEvent(final AjaxRequestTarget target) { if (resultContainer == null) { send(SearchClausePanel.this, Broadcast.BUBBLE, new SearchEvent(target)); } else { send(resultContainer, Broadcast.EXACT, new SearchEvent(target)); } } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); AJAX_SUBMIT_ON_RETURN.accept(attributes); } }); }
Example #5
Source File: FeatureEditor.java From webanno with Apache License 2.0 | 6 votes |
public void addFeatureUpdateBehavior() { FormComponent focusComponent = getFocusComponent(); focusComponent.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = -8944946839865527412L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes aAttributes) { super.updateAjaxAttributes(aAttributes); addDelay(aAttributes, 250); } @Override protected void onUpdate(AjaxRequestTarget aTarget) { send(focusComponent, BUBBLE, new FeatureEditorValueChangedEvent(FeatureEditor.this, aTarget)); } }); }
Example #6
Source File: RatingFeatureEditor.java From webanno with Apache License 2.0 | 6 votes |
@Override public void addFeatureUpdateBehavior() { // Need to use a AjaxFormChoiceComponentUpdatingBehavior here since we use a RadioGroup // here. FormComponent focusComponent = getFocusComponent(); focusComponent.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = -5058365578109385064L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes aAttributes) { super.updateAjaxAttributes(aAttributes); addDelay(aAttributes, 300); } @Override protected void onUpdate(AjaxRequestTarget aTarget) { send(focusComponent, BUBBLE, new FeatureEditorValueChangedEvent(RatingFeatureEditor.this, aTarget)); } }); }
Example #7
Source File: GbAjaxButton.java From sakai with Educational Community License v2.0 | 6 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new AjaxCallListener() // disable the button right away after clicking it // and mark on it if the window is unloading .onBefore( String.format( "$('#%s').prop('disabled', true);" + "$(window).on('beforeunload', function() {" + "$('#%s').data('unloading', true).prop('disabled', true)});", getMarkupId(), getMarkupId())) // if the page is unloading, keep it disabled, otherwise // add a slight delay in re-enabling it, just in case it succeeded // and there's a delay in closing a parent modal .onComplete( String.format("setTimeout(function() {" + "if (!$('#%s').data('unloading')) $('#%s').prop('disabled',false);" + "}, 1000)", getMarkupId(), getMarkupId()))); }
Example #8
Source File: ConfirmableAjaxBorder.java From openmeetings with Apache License 2.0 | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); add(new AjaxEventBehavior(EVT_CLICK) { private static final long serialVersionUID = 1L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); ConfirmableAjaxBorder.this.updateAjaxAttributes(attributes); } @Override protected void onEvent(AjaxRequestTarget target) { if (isClickable()) { getDialog().show(target); } } }); addToBorder(getDialog()); }
Example #9
Source File: KeyPressBehavior.java From the-app with Apache License 2.0 | 6 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); IAjaxCallListener listener = new AjaxCallListener() { @Override public CharSequence getPrecondition(Component component) { //this javascript code evaluates wether an ajaxcall is necessary. //Here only by keyocdes for F9 and F10 return "var keycode = Wicket.Event.keyCode(attrs.event);" + "if ((keycode == 112) || (keycode == 113) || (keycode == 114) || (keycode == 115))" + " return true;" + "else" + " return false;"; } }; attributes.getAjaxCallListeners().add(listener); //Append the pressed keycode to the ajaxrequest attributes.getDynamicExtraParameters() .add("var eventKeycode = Wicket.Event.keyCode(attrs.event);" + "return {keycode: eventKeycode};"); //whithout setting, no keyboard events will reach any inputfield attributes.setPreventDefault(true); }
Example #10
Source File: AjaxActionTab.java From onedev with MIT License | 6 votes |
@Override public Component render(String componentId) { return new ActionTabLink(componentId, this) { @Override protected WebMarkupContainer newLink(String id, ActionTab tab) { return new AjaxLink<Void>("link") { @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); AjaxActionTab.this.updateAjaxAttributes(attributes); } @Override public void onClick(AjaxRequestTarget target) { selectTab(this); } }; } }; }
Example #11
Source File: ConceptFeatureEditor.java From inception with Apache License 2.0 | 6 votes |
@Override public void addFeatureUpdateBehavior() { focusComponent.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = -8944946839865527412L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes aAttributes) { super.updateAjaxAttributes(aAttributes); aAttributes.getDynamicExtraParameters() .add(focusComponent.getIdentifierDynamicAttributeScript()); addDelay(aAttributes, 250); } @Override protected void onUpdate(AjaxRequestTarget aTarget) { aTarget.add(description); send(focusComponent, BUBBLE, new FeatureEditorValueChangedEvent(ConceptFeatureEditor.this, aTarget)); } }); }
Example #12
Source File: FilterPanel.java From Orienteer with Apache License 2.0 | 6 votes |
private AjaxFormSubmitBehavior newOnEnterPressBehavior(final WebMarkupContainer container) { return new AjaxFormSubmitBehavior("keypress") { @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getAjaxCallListeners().add(new AjaxCallListener() { @Override public CharSequence getPrecondition(Component component) { return "return Wicket.Event.keyCode(attrs.event) === 13;"; } }); } @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); onOkSubmit(target, container); } }; }
Example #13
Source File: StopSortableAjaxBehavior.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); String areasId = getComponent().findParent(PivotPanel.class).get("areas").getMarkupId(); StringBuilder javaScript = new StringBuilder(); javaScript.append("var data = onStopFieldMove(\"" + areasId + "\");"); javaScript.append("return { '" + JSON_DATA + "': data }"); attributes.getDynamicExtraParameters().add(javaScript); }
Example #14
Source File: AjaxSubmitConfirmLink.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); if (StringUtils.isNotEmpty(getMessage()) && showDialog()) { String message = getMessage().replaceAll("'", "\""); StringBuilder precondition = new StringBuilder("if(!confirm('").append(message).append("')) { return false; };"); AjaxCallListener listener = new AjaxCallListener(); listener.onPrecondition(precondition); attributes.getAjaxCallListeners().add(listener); } }
Example #15
Source File: GbGradeTable.java From sakai with Educational Community License v2.0 | 5 votes |
public GbGradeTable(final String id, final IModel model) { super(id); setDefaultModel(model); component = new WebMarkupContainer("gradeTable").setOutputMarkupId(true); component.add(new AjaxEventBehavior("gbgradetable.action") { @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getDynamicExtraParameters() .add("return [{\"name\": \"ajaxParams\", \"value\": JSON.stringify(attrs.event.extraData)}]"); } @Override protected void onEvent(final AjaxRequestTarget target) { try { final ObjectMapper mapper = new ObjectMapper(); final JsonNode params = mapper.readTree(getRequest().getRequestParameters().getParameterValue("ajaxParams").toString()); final ActionResponse response = handleEvent(params.get("action").asText(), params, target); target.appendJavaScript(String.format("GbGradeTable.ajaxComplete(%d, '%s', %s);", params.get("_requestId").intValue(), response.getStatus(), response.toJson())); } catch (IOException e) { throw new RuntimeException(e); } } }); add(component); }
Example #16
Source File: DrawerManager.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 5 votes |
public ListItem(String id, final AbstractDrawer drawer, DrawerManager drawerManager, String css) { super(id); setOutputMarkupId(true); manager = drawerManager; item = new WebMarkupContainer("item"); if (null != css) { item.add(new AttributeAppender("class", Model.of(css), " ")); } add(item); this.drawer = drawer; item.add(drawer); add(new EmptyPanel("next").setOutputMarkupId(true)); item.add(new AjaxEventBehavior("hide-modal") { private static final long serialVersionUID = -6423164614673441582L; @Override protected void onEvent(AjaxRequestTarget target) { manager.eventPop(ListItem.this.drawer, target); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setPreventDefault(true); } }); }
Example #17
Source File: AjaxConfirmLink.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); if (StringUtils.isNotEmpty(getMessage()) && showDialog()) { String message = getMessage().replaceAll("'", "\""); StringBuilder precondition = new StringBuilder("if(!confirm('").append(message).append("')) { hideBusy(); return false; };"); AjaxCallListener listener = new AjaxCallListener(); listener.onPrecondition(precondition); attributes.getAjaxCallListeners().add(listener); } }
Example #18
Source File: WidgetTabs.java From sakai with Educational Community License v2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setChannel(new AjaxChannel(getId())); }
Example #19
Source File: SakaiSpinningSelectOnChangeBehavior.java From sakai with Educational Community License v2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE)); AjaxCallListener listener = new SakaiSpinningSelectAjaxCallListener(getComponent().getMarkupId(), false); attributes.getAjaxCallListeners().add(listener); }
Example #20
Source File: SakaiAjaxButton.java From sakai with Educational Community License v2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE)); AjaxCallListener listener = new SakaiSpinnerAjaxCallListener(getMarkupId(), willRenderOnClick); attributes.getAjaxCallListeners().add(listener); }
Example #21
Source File: AjaxLazyLoadImage.java From sakai with Educational Community License v2.0 | 5 votes |
private void init() { setOutputMarkupId(true); // render chart by ajax, uppon request chartRenderAjaxBehavior = new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void respond(AjaxRequestTarget target) { //log.debug("chartRenderAjaxBehavior.Responding for "+ getId()); renderImage(target, true); } @Override public boolean isEnabled(Component component) { return state < 2; } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setChannel(new AjaxChannel(getId())); } }; add(chartRenderAjaxBehavior); // fields for maximized chart size setDefaultModel(new CompoundPropertyModel(this)); form = new Form("chartForm"); form.add(new HiddenField("maxWidth")); form.add(new HiddenField("maxHeight")); add(form); }
Example #22
Source File: AlarmWidgetView.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); StringBuilder javaScript = new StringBuilder(); javaScript.append("var data = isCanvasEnabled();"); javaScript.append("console.log(data);"); javaScript.append("return { '" + PARAM + "': data }"); attributes.getDynamicExtraParameters().add(javaScript); }
Example #23
Source File: StopSortableAjaxBehavior.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); StringBuilder javaScript = new StringBuilder(); javaScript.append("var data = onStopWidgetMove();"); javaScript.append("return { '" + JSON_DATA + "': data }"); attributes.getDynamicExtraParameters().add(javaScript); }
Example #24
Source File: IndicatorWidgetView.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); StringBuilder javaScript = new StringBuilder(); javaScript.append("var data = isCanvasEnabled();"); javaScript.append("console.log(data);"); javaScript.append("return { '" + PARAM + "': data }"); attributes.getDynamicExtraParameters().add(javaScript); }
Example #25
Source File: ChartRendererPanel.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); StringBuilder javaScript = new StringBuilder(); javaScript.append("var data = isCanvasEnabled();"); javaScript.append("console.log(data);"); javaScript.append("return { '" + PARAM + "': data }"); attributes.getDynamicExtraParameters().add(javaScript); }
Example #26
Source File: DisplayWidgetView.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); StringBuilder javaScript = new StringBuilder(); javaScript.append("var data = isCanvasEnabled();"); javaScript.append("console.log(data);"); javaScript.append("return { '" + PARAM + "': data }"); attributes.getDynamicExtraParameters().add(javaScript); }
Example #27
Source File: GbGradeTable.java From sakai with Educational Community License v2.0 | 5 votes |
public GbGradeTable(final String id, final IModel model) { super(id); setDefaultModel(model); component = new WebMarkupContainer("gradeTable").setOutputMarkupId(true); component.add(new AjaxEventBehavior("gbgradetable.action") { @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getDynamicExtraParameters() .add("return [{\"name\": \"ajaxParams\", \"value\": JSON.stringify(attrs.event.extraData)}]"); } @Override protected void onEvent(final AjaxRequestTarget target) { try { final ObjectMapper mapper = new ObjectMapper(); final JsonNode params = mapper.readTree(getRequest().getRequestParameters().getParameterValue("ajaxParams").toString()); final ActionResponse response = handleEvent(params.get("action").asText(), params, target); target.appendJavaScript(String.format("GbGradeTable.ajaxComplete(%d, '%s', %s);", params.get("_requestId").intValue(), response.getStatus(), response.toJson())); } catch (IOException e) { throw new RuntimeException(e); } } }); add(component); }
Example #28
Source File: OrienteerHeadersToolbar.java From Orienteer with Apache License 2.0 | 5 votes |
/** * Factory method for sortable header components. A sortable header component must have id of * <code>headerId</code> and conform to markup specified in <code>OrienteerHeadersToolbar.html</code> * * @param headerId * header component id * @param property * property this header represents * @param locator * sort state locator * @return created header component */ protected WebMarkupContainer newSortableHeader(final String headerId, final S property, final ISortStateLocator<S> locator) { WebMarkupContainer container = new AjaxFallbackOrderByBorder<S>(headerId, property, locator) { private static final long serialVersionUID = 1L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { } @Override protected void onAjaxClick(final AjaxRequestTarget target) { target.add(getTable()); } @Override protected void onSortChanged() { super.onSortChanged(); getTable().setCurrentPage(0); } @Override public void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.remove("class"); } }; return container; }
Example #29
Source File: ModalDialog.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * @param id */ @SuppressWarnings("serial") public ModalDialog(final String id) { super(id); actionButtons = new MyComponentsRepeater<Component>("actionButtons"); mainContainer = new WebMarkupContainer("mainContainer"); add(mainContainer.setOutputMarkupId(true)); mainContainer.add(mainSubContainer = new WebMarkupContainer("mainSubContainer")); gridContentContainer = new WebMarkupContainer("gridContent"); gridContentContainer.setOutputMarkupId(true); buttonBarContainer = new WebMarkupContainer("buttonBar"); buttonBarContainer.setOutputMarkupId(true); closeBehavior = new AjaxEventBehavior("hidden.bs.modal") { @Override protected void onEvent(final AjaxRequestTarget target) { handleCloseEvent(target); } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE); } }; }
Example #30
Source File: AjaxLazyLoadImage.java From sakai with Educational Community License v2.0 | 5 votes |
private void init() { setOutputMarkupId(true); // render chart by ajax, uppon request chartRenderAjaxBehavior = new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void respond(AjaxRequestTarget target) { //log.debug("chartRenderAjaxBehavior.Responding for "+ getId()); renderImage(target, true); } @Override public boolean isEnabled(Component component) { return state < 2; } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setChannel(new AjaxChannel(getId())); } }; add(chartRenderAjaxBehavior); // fields for maximized chart size setDefaultModel(new CompoundPropertyModel(this)); form = new Form("chartForm"); form.add(new HiddenField("maxWidth")); form.add(new HiddenField("maxHeight")); add(form); }