List of usage examples for org.apache.wicket.extensions.ajax.markup.html AjaxIndicatorAppender AjaxIndicatorAppender
public AjaxIndicatorAppender()
From source file:com.aipo.mobycket.wicket.markup.html.form.IndicatingAjaxButton.java
License:Apache License
public AjaxIndicatorAppender getWicketAjaxIndicatorAppender() { return new AjaxIndicatorAppender() { private static final long serialVersionUID = 2238212593688080513L; @Override//ww w . jav a 2 s. co m public void onRendered(Component component) { final Response r = component.getResponse(); r.write("<span style=\"display:none;"); if (isIndicatingCenter) { r.write("text-align:center;"); } r.write("\" class=\""); r.write(getSpanClass()); r.write("\" "); r.write("id=\""); r.write(getMarkupId()); r.write("\">"); if (isIndicatingCenter) { r.write("<br/>"); } r.write("<img src=\""); r.write(getIndicatorUrl()); r.write("\" alt=\"\" align=\"absmiddle\"/>"); if (indicatingMessage != null) { r.write(indicatingMessage); } r.write("</span>"); } @Override protected CharSequence getIndicatorUrl() { return indicaterUrl; } }; }
From source file:com.chitek.ignition.drivers.generictcp.meta.config.ui.MessageConfigUI.java
License:Apache License
private DropDownChoice<Integer> getCurrentMessageIdDropdown() { IChoiceRenderer<Integer> messageConfigRender = new IChoiceRenderer<Integer>() { @Override// w w w. jav a 2s .c om public Object getDisplayValue(Integer object) { return String.format("%d - %s", object, getConfig().getMessageConfig(object).getMessageAlias()); } @Override public String getIdValue(Integer object, int index) { return object.toString(); } }; IModel<List<Integer>> messageListModel = new LoadableDetachableModel<List<Integer>>() { @Override protected List<Integer> load() { List<MessageConfig> messages = getConfig().getMessageList(); List<Integer> list = new ArrayList<Integer>(messages.size()); for (MessageConfig messageConfig : messages) { list.add(messageConfig.getMessageId()); } return list; } }; DropDownChoice<Integer> dropDown = new DropDownChoice<Integer>("currentMessage", new PropertyModel<Integer>(this, "currentMessageId"), messageListModel, messageConfigRender); dropDown.add(new AjaxFormSubmitBehavior("onchange") { @Override protected void onSubmit(final AjaxRequestTarget target) { // Reset feedback messages target.addChildren(getPage(), FeedbackPanel.class); // Change the current message currentMessage = getConfig().getMessageConfig(currentMessageId); currentMessage.calcOffsets(getConfig().getMessageIdType().getByteSize()); // Refresh the form updateForm(target); } @Override protected void onError(final AjaxRequestTarget target) { // Add the drop down to revert the changed selection target.add(getComponent()); handleError(target); }; }); dropDown.add(new AjaxIndicatorAppender()); dropDown.setOutputMarkupId(true); return dropDown; }
From source file:org.apache.isis.viewer.wicket.ui.components.widgets.linkandlabel.ActionLink.java
License:Apache License
ActionLink(String id, ActionModel model, ObjectAction action) { super(id, model); final boolean useIndicatorForNoArgAction = getSettings().isUseIndicatorForNoArgAction(); this.indicatorAppenderIfAny = useIndicatorForNoArgAction ? new AjaxIndicatorAppender() : null; if (this.indicatorAppenderIfAny != null) { this.add(this.indicatorAppenderIfAny); }/*from w w w . jav a 2s. c o m*/ // trivial optimization; also store the objectAction if it is available (saves looking it up) objectAction = action; // this returns non-null if the action is no-arg and returns a URL or a Blob or a Clob. // Otherwise can use default handling // TODO: the method looks at the actual compile-time return type; // TODO: cannot see a way to check at runtime what is returned. // TODO: see https://issues.apache.org/jira/browse/ISIS-1264 for further detail. ajaxDeferredBehaviourIfAny = determineDeferredBehaviour(); if (ajaxDeferredBehaviourIfAny != null) { this.add(ajaxDeferredBehaviourIfAny); } }
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 ww w. j a v a2 s .co 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.dialog.AbstractWizard.java
License:Apache License
public AbstractWizard() { super("content", false); setOutputMarkupId(true);/*from w w w. j a v a 2 s. co m*/ 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.plugins.yui.ajax.AjaxIndicatorBehavior.java
License:Apache License
public AjaxIndicatorBehavior() { ajaxIndicator = new AjaxIndicatorAppender() { @Override/* w ww .j a va 2 s.co m*/ public void afterRender(final Component component) { final Response r = component.getResponse(); r.write("<div class=\""); r.write(getSpanClass()); r.write("\" "); r.write("id=\""); r.write(getMarkupId()); r.write("\">"); r.write("<div class=\"ajax-loader\"></div>"); r.write("</div>"); } }; }
From source file:org.onexus.website.api.widgets.selector.SelectorWidget.java
License:Apache License
public SelectorWidget(String componentId, IModel<SelectorWidgetStatus> statusModel) { super(componentId, statusModel); Form form = new Form("form"); DropDownChoice<EntityChoice> dropDown = new DropDownChoice<EntityChoice>("select", new PropertyModel<EntityChoice>(this, "selection"), getChoices()) { @Override/*from www . j ava 2s . co m*/ protected CharSequence getDefaultChoice(String selectedValue) { String option = SelectorWidget.this.getConfig().getTitle(); if (Strings.isEmpty(option)) { option = "Choose one..."; } // The <option> tag buffer final AppendingStringBuffer buffer = new AppendingStringBuffer(64 + option.length()); // Add option tag buffer.append("\n<option"); // If null is selected, indicate that if ("".equals(selectedValue)) { buffer.append(" selected=\"selected\""); } // Add body of option tag buffer.append(" value=\"\">").append(option).append("</option>"); return buffer; } }; dropDown.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { Boolean selection = getConfig().getSelection(); if (selection == null || !selection) { sendEvent(EventFiltersUpdate.EVENT); } else { EntityChoice choice = getSelection(); if (choice != null) { BrowserPageStatus pageStatus = findParentStatus(BrowserPageStatus.class); pageStatus.addEntitySelection( new SingleEntitySelection(getConfig().getCollection(), getSelection().getId())); setSelection(null); sendEvent(EventAddFilter.EVENT); } } } }); dropDown.setNullValid(true); add(new AjaxIndicatorAppender()); form.add(dropDown); add(form); }