Example usage for org.apache.wicket.ajax AjaxChannel AjaxChannel

List of usage examples for org.apache.wicket.ajax AjaxChannel AjaxChannel

Introduction

In this page you can find the example usage for org.apache.wicket.ajax AjaxChannel AjaxChannel.

Prototype

public AjaxChannel(final String name, final Type type) 

Source Link

Document

Construct.

Usage

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  va  2  s.c o m*/
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {

    super.updateAjaxAttributes(attributes);

    attributes.setChannel(new AjaxChannel("autodisable", AjaxChannel.Type.ACTIVE));
}

From source file:org.hippoecm.frontend.plugins.standardworkflow.AddDocumentDialog.java

License:Apache License

public AddDocumentDialog(AddDocumentArguments addDocumentModel, IModel<String> title, String category,
        Set<String> prototypes, boolean translated, final IWorkflowInvoker invoker,
        IModel<StringCodec> nodeNameCodec, ILocaleProvider localeProvider,
        final WorkflowDescriptorModel workflowDescriptorModel) {
    super(invoker, Model.of(addDocumentModel));

    this.title = title;
    this.nodeNameCodecModel = nodeNameCodec;

    final PropertyModel<String> prototypeModel = new PropertyModel<>(addDocumentModel, "prototype");

    add(nameUriContainer = new NameUriField("name-url", this.nodeNameCodecModel));

    // The dialog produces ajax requests in NameUriField and OK/Cancel dialog buttons, which may cause Wicket
    // exceptions when typing very fast. Thus it needs to use a dedicated ajax channel with ACTIVE behavior when
    // some AJAX requests may be sent after dialog is closed.
    final AjaxChannel activeAjaxChannel = new AjaxChannel(getMarkupId(), AjaxChannel.Type.ACTIVE);
    setAjaxChannel(activeAjaxChannel);/*from   w  w  w . ja va 2  s.  c om*/
    nameUriContainer.setAjaxChannel(activeAjaxChannel);

    final IModel<String> documentType = new StringResourceModel("document-type", this, null);
    final Label typeLabel = new Label("typelabel", documentType);
    add(typeLabel);

    if (prototypes.size() > 1) {
        final List<String> prototypesList = new LinkedList<>(prototypes);
        final DropDownChoice<String> folderChoice;
        SortedTypeChoiceRenderer typeChoiceRenderer = new SortedTypeChoiceRenderer(this, prototypesList);
        add(folderChoice = new DropDownChoice<>("prototype", prototypeModel, typeChoiceRenderer,
                typeChoiceRenderer));
        folderChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {
            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                target.add(folderChoice);
            }
        });
        folderChoice.setNullValid(false);
        folderChoice.setRequired(true);
        folderChoice.setLabel(documentType);

        // while not a prototype chosen, disable ok button
        add(new EmptyPanel("notypes").setVisible(false));
    } else if (prototypes.size() == 1) {
        Component component;
        add(component = new EmptyPanel("prototype"));
        component.setVisible(false);
        prototypeModel.setObject(prototypes.iterator().next());
        add(new EmptyPanel("notypes").setVisible(false));
        typeLabel.setVisible(false);
    } else {
        // if the folderWorkflowPlugin.templates.get(category).size() = 0 you cannot add this
        // category currently.
        Component component;
        add(component = new EmptyPanel("prototype"));
        component.setVisible(false);
        prototypeModel.setObject(null);
        add(new Label("notypes",
                "There are no types available for : [" + category + "] First create document types please."));
        nameUriContainer.getNameComponent().setVisible(false);
        typeLabel.setVisible(false);
    }

    languageField = new LanguageField("language", new PropertyModel<>(addDocumentModel, "language"),
            localeProvider);
    if (!translated) {
        languageField.setVisible(false);
    }
    add(languageField);

    add(new AddDocumentValidator(this, nameUriContainer, workflowDescriptorModel));

    add(CssClass.append("add-document-dialog"));

    setSize(DialogConstants.MEDIUM_AUTO);
}

From source file:org.hippoecm.frontend.plugins.standardworkflow.RenameDocumentDialog.java

License:Apache License

public RenameDocumentDialog(final RenameDocumentArguments renameDocumentArguments, final IModel<String> title,
        final IWorkflowInvoker invoker, final IModel<StringCodec> nodeNameCodec,
        final WorkflowDescriptorModel workflowDescriptorModel) {
    super(invoker, Model.of(renameDocumentArguments), title);

    this.nodeNameCodecModel = nodeNameCodec;

    setSize(DialogConstants.MEDIUM_AUTO);

    final String originalUriName = renameDocumentArguments.getUriName();
    final String originalTargetName = renameDocumentArguments.getTargetName();

    add(nameUriContainer = new NameUriField("name-url", nodeNameCodecModel, originalUriName, originalTargetName,
            true));//from   w  w  w .ja v a  2 s .  c  o m

    // The dialog produces ajax requests in NameUriField and OK/Cancel dialog buttons, which may cause Wicket
    // exceptions when typing very fast. Thus it needs to use a dedicated ajax channel with ACTIVE behavior when
    // some AJAX requests may be sent after dialog is closed.
    final AjaxChannel activeAjaxChannel = new AjaxChannel(getMarkupId(), AjaxChannel.Type.ACTIVE);
    setAjaxChannel(activeAjaxChannel);
    nameUriContainer.setAjaxChannel(activeAjaxChannel);

    add(new RenameDocumentValidator(this, nameUriContainer, workflowDescriptorModel));
}

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);
}