List of usage examples for org.apache.wicket.ajax.attributes AjaxRequestAttributes setChannel
public AjaxRequestAttributes setChannel(final AjaxChannel channel)
From source file:nl.mpi.lamus.web.components.AutoDisablingAjaxButton.java
License:Open Source License
/** * @see IndicatingAjaxButton#updateAjaxAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) *///from w w w . j a v a 2 s . c om @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setChannel(new AjaxChannel("autodisable", AjaxChannel.Type.ACTIVE)); }
From source file:org.hippoecm.frontend.dialog.AbstractDialog.java
License:Apache License
public AbstractDialog(IModel<T> model) { super("form", model); container = new Container(IDialogService.DIALOG_WICKET_ID); container.add(this); feedback = newFeedbackPanel("feedback"); IFeedbackMessageFilter filter = feedback.getFilter(); if (filter == null) { // make sure the feedback filters out messages unrelated to this dialog feedback.setFilter(new ContainerFeedbackMessageFilter(this)); } else if (!(filter instanceof ContainerFeedbackMessageFilter)) { log.warn(/*from w ww. jav a2 s . c o m*/ "The dialog '{}' uses a feedback panel with a filter that does not extend ContainerFeedbackMessageFilter." + "As a result, this dialog may show unrelated feedback messages.", getClass()); } feedback.setOutputMarkupId(true); add(feedback); buttons = new LinkedList<>(); ListView<ButtonWrapper> buttonsView = new ListView<ButtonWrapper>("buttons", buttons) { @Override protected void populateItem(ListItem<ButtonWrapper> item) { final Button button = item.getModelObject().getButton(); if (StringUtils.isNotEmpty(buttonCssClass)) { button.add(CssClass.append(buttonCssClass)); } item.add(button); } }; buttonsView.setReuseItems(true); buttonsView.setOutputMarkupId(true); add(buttonsView); ok = new ButtonWrapper(new ResourceModel("ok")) { @Override protected void onSubmit() { handleSubmit(); } @Override protected void onUpdateAjaxAttributes(final AjaxRequestAttributes attributes) { attributes.setChannel(ajaxChannel); } }; ok.setKeyType(KeyType.Enter); buttons.add(ok); cancel = new ButtonWrapper(new ResourceModel("cancel")) { @Override protected void onSubmit() { cancelled = true; onCancel(); closeDialog(); } @Override protected Button decorate(final Button button) { button.add(new AjaxEventBehavior("onclick") { @Override protected void onComponentTag(final ComponentTag tag) { super.onComponentTag(tag); tag.put("type", "button"); } @Override protected void onEvent(final AjaxRequestTarget target) { onSubmit(); } }); button.setDefaultFormProcessing(false); return super.decorate(button); } }; cancel.setKeyType(KeyType.Escape); buttons.add(cancel); if (isFullscreenEnabled()) { final AjaxButton goFullscreen = new AjaxButton(DialogConstants.BUTTON, new AbstractReadOnlyModel<String>() { @Override public String getObject() { return getString(fullscreen ? "exit-fullscreen" : "fullscreen"); } }) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { target.appendJavaScript(getFullscreenScript()); target.add(this); //update button label fullscreen = !fullscreen; } }; addButton(goFullscreen); } if (addAjaxIndicator()) { add(indicator = new AjaxIndicatorAppender() { @Override protected CharSequence getIndicatorUrl() { return RequestCycle.get() .urlFor(new ResourceReferenceRequestHandler(DialogConstants.AJAX_LOADER_GIF)); } }); } }
From source file:org.hippoecm.frontend.widgets.NameUriField.java
License:Apache License
private FormComponent<String> createNameComponent() { final FormComponent<String> newNameComponent = new TextField<>("name", nameModel); newNameComponent.setRequired(true);/*from w w w.jav a 2 s . co m*/ newNameComponent.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(final AjaxRequestTarget target) { if (!urlIsEditable) { // the value of the url field is controlled by the name value, redraw when name changes target.add(urlComponent); } } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setChannel(ajaxChannel); attributes .setThrottlingSettings(new ThrottlingSettings(getPath(), NAME_COMPONENT_THROTTLE_DURATION)); } }); newNameComponent.setOutputMarkupId(true); return newNameComponent; }
From source file:org.sakaiproject.sitestats.tool.wicket.components.AjaxLazyLoadFragment.java
License:Educational Community License
/** * @param id/*from w ww. j a v a2s. co m*/ */ public AjaxLazyLoadFragment(final String id) { super(id); setOutputMarkupId(true); final AbstractDefaultAjaxBehavior behavior = new AbstractDefaultAjaxBehavior() { @Override protected void respond(AjaxRequestTarget target) { Fragment fragment = getLazyLoadFragment("content"); AjaxLazyLoadFragment.this.replace(fragment.setRenderBodyOnly(true)); target.add(AjaxLazyLoadFragment.this); setState((byte) 2); } @Override public void renderHead(Component component, IHeaderResponse response) { response.render(OnDomReadyHeaderItem.forScript(getCallbackScript().toString())); super.renderHead(component, response); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setChannel(new AjaxChannel(getId())); } @Override public boolean isEnabled(Component component) { return state < 2; } }; add(behavior); }
From source file:org.sakaiproject.sitestats.tool.wicket.components.AjaxLazyLoadImage.java
License:Educational Community License
private void init() { setOutputMarkupId(true);/*from w ww.j a va 2s . co m*/ // render chart by ajax, uppon request chartRenderAjaxBehavior = new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void respond(AjaxRequestTarget target) { //System.out.println("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); }
From source file:org.sakaiproject.sitestats.tool.wicket.components.AjaxLazyLoadImage.java
License:Educational Community License
public void setAutoDetermineChartSizeByAjax(final String jquerySelectorForContainer) { autoDetermineChartSizeByAjax = true; AbstractDefaultAjaxBehavior determineChartSizeBehavior = new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override//from w w w.j av a 2 s . c o m protected void respond(AjaxRequestTarget target) { // parse desired image size Request req = RequestCycle.get().getRequest(); selectedWidth = req.getQueryParameters().getParameterValue("width").toInt(400); selectedHeight = req.getQueryParameters().getParameterValue("height").toInt(200); if (selectedHeight < 200) { selectedHeight = 200; } // render chart image renderImage(target, true); } @Override public void renderHead(Component component, IHeaderResponse response) { super.renderHead(component, response); response.render(OnDomReadyHeaderItem.forScript(getCallbackScript(component))); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setChannel(new AjaxChannel(getId())); String dynamicExtraParams = "return { 'height': jQuery('" + jquerySelectorForContainer + "').height(), 'width': jQuery('" + jquerySelectorForContainer + "').width() }"; attributes.getDynamicExtraParameters().add(dynamicExtraParams); } }; add(determineChartSizeBehavior); }
From source file:org.sakaiproject.sitestats.tool.wicket.components.dropdown.SakaiSpinningSelectOnChangeBehavior.java
License:Educational Community License
@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); }
From source file:org.sakaiproject.sitestats.tool.wicket.components.SakaiAjaxButton.java
License:Educational Community License
@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); }