org.apache.wicket.ajax.form.AjaxFormSubmitBehavior Java Examples

The following examples show how to use org.apache.wicket.ajax.form.AjaxFormSubmitBehavior. 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: LinkEqualsFilterPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
private Select2Choice<OClass> createClassChoiceComponent(String id, IModel<OClass> classModel) {
    Select2Choice<OClass> choice = new Select2Choice<OClass>(id, classModel, new OClassTextChoiceProvider()) {

        @Override
        protected void onInitialize() {
            super.onInitialize();
            OProperty property = LinkEqualsFilterPanel.this.getEntityModel().getObject();
            if (property != null && property.getLinkedClass() != null) {
                setModelObject(property.getLinkedClass());
                setEnabled(false);
            }
        }
    };
    choice.getSettings()
            .setWidth("100%")
            .setCloseOnSelect(true)
            .setTheme(BOOTSTRAP_SELECT2_THEME)
            .setContainerCssClass("link-filter-class-choice");
    choice.add(new AjaxFormSubmitBehavior("change") {});
    choice.setOutputMarkupId(true);
    return choice;
}
 
Example #2
Source File: CollectionLinkFilterPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
private Select2MultiChoice<String> createClassChooseComponent(String id, IModel<Collection<String>> classNamesModel) {
    Select2MultiChoice<String> choice = new Select2MultiChoice<String>(id, classNamesModel,
            OClassCollectionTextChoiceProvider.INSTANCE) {
        @Override
        protected void onInitialize() {
            super.onInitialize();
            OProperty property = CollectionLinkFilterPanel.this.getEntityModel().getObject();
            if (property != null && property.getLinkedClass() != null) {
                setModelObject(Arrays.asList(property.getLinkedClass().getName()));
                setEnabled(false);
            }
        }
    };
    choice.getSettings()
            .setWidth("100%")
            .setCloseOnSelect(true)
            .setTheme(BOOTSTRAP_SELECT2_THEME)
            .setContainerCssClass("link-filter-class-choice");
    choice.add(new AjaxFormSubmitBehavior("change") {});
    return choice;
}
 
Example #3
Source File: ClassInCollectionFilterPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
public FormComponent<Collection<String>> createFilterComponent(IModel<?> model) {
    IModel<OClass> entityModel = getEntityModel();
    IModel<List<OClass>> classesModel = new SubClassesModel(entityModel, true, false);

    return new Select2MultiChoice<String>(getFilterId(), getModel(), new OClassCollectionTextChoiceProvider(classesModel)) {
        @Override
        protected void onInitialize() {
            super.onInitialize();
            getSettings()
                    .setWidth("100%")
                    .setCloseOnSelect(true)
                    .setTheme(BOOTSTRAP_SELECT2_THEME);
            add(new AjaxFormSubmitBehavior("change") {});
        }
    };
}
 
Example #4
Source File: InstanceOfClassFilterPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
public FormComponent<OClass> createFilterComponent(IModel<?> model) {
    IModel<OClass> entityModel = getEntityModel();
    IModel<List<OClass>> loadModel = new SubClassesModel(entityModel, true, false);

    return new Select2Choice<OClass>(getFilterId(), getModel(), new OClassTextChoiceProvider(loadModel)) {

        @Override
        protected void onInitialize() {
            super.onInitialize();
            getSettings().setWidth("100%")
                    .setCloseOnSelect(true)
                    .setTheme(OClassMetaPanel.BOOTSTRAP_SELECT2_THEME);
            add(new AjaxFormSubmitBehavior("change") {});
            setOutputMarkupPlaceholderTag(true);
        }
    };
}
 
Example #5
Source File: FilterPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: AbstractFilterPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
public AbstractFilterPanel(String id, IModel<T> model, String filterId,
                           IModel<V> entityModel,
                           IVisualizer visualizer,
                           IFilterCriteriaManager manager, IModel<Boolean> join) {
    super(id, model);
    this.filterId = filterId;
    this.entityModel = entityModel;
    this.visualizer = visualizer;
    this.joinModel = join;
    this.manager = manager;
    setOutputMarkupPlaceholderTag(true);
    add(new Label("title", getTitle()));
    CheckBox checkBox = new CheckBox("join", join);
    checkBox.add(new AjaxFormSubmitBehavior("change") {});
    checkBox.setOutputMarkupId(true);
    add(checkBox);
    add(new Label("joinTitle", new ResourceModel("widget.document.filter.join"))
            .setOutputMarkupPlaceholderTag(true));
}
 
Example #7
Source File: CSVPullWizardBuilder.java    From syncope with Apache License 2.0 5 votes vote down vote up
public Details(final CSVPullSpec spec) {
    FileInputConfig csvFile = new FileInputConfig().
            showUpload(false).showRemove(false).showPreview(false).
            browseClass("btn btn-success").browseIcon("<i class=\"fas fa-folder-open\"></i> &nbsp;");
    String language = SyncopeConsoleSession.get().getLocale().getLanguage();
    if (!Locale.ENGLISH.getLanguage().equals(language)) {
        csvFile.withLocale(language);
    }
    BootstrapFileInputField csvUpload =
            new BootstrapFileInputField("csvUpload", new ListModel<>(new ArrayList<>()), csvFile);
    csvUpload.add(new AjaxFormSubmitBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = 5538299138211283825L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target) {
            FileUpload uploadedFile = csvUpload.getFileUpload();
            if (uploadedFile != null) {
                if (maxUploadSize != null && uploadedFile.getSize() > maxUploadSize.bytes()) {
                    SyncopeConsoleSession.get().error(getString("tooLargeFile").
                            replace("${maxUploadSizeB}", String.valueOf(maxUploadSize.bytes())).
                            replace("${maxUploadSizeMB}", String.valueOf(maxUploadSize.bytes() / 1000000L)));
                    ((BasePage) getPageReference().getPage()).getNotificationPanel().refresh(target);
                } else {
                    csv.setObject(uploadedFile.getBytes());
                }
            }
        }
    });
    add(csvUpload.setRequired(true).setOutputMarkupId(true));

    add(new CSVConfPanel("csvconf", spec));
}
 
Example #8
Source File: LinkEqualsFilterPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private Select2Choice<ODocument> createDocumentChoiceComponent(String id, IModel<OClass> classModel) {
    Select2Choice<ODocument> choice = new Select2Choice<>(id, getModel(), new ODocumentChoiceProvider(classModel));
    choice.getSettings()
            .setWidth("100%")
            .setCloseOnSelect(true)
            .setTheme(BOOTSTRAP_SELECT2_THEME)
            .setContainerCssClass("link-filter-document-choice");
    choice.add(new AjaxFormSubmitBehavior("change") {});
    choice.setOutputMarkupId(true);
    return choice;
}
 
Example #9
Source File: BooleanFilterPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public BooleanFilterPanel(String id, final IModel<Boolean> valueModel) {
    super(id, valueModel);
    List<Boolean> list = Lists.newArrayList();
    list.add(Boolean.TRUE);
    list.add(Boolean.FALSE);
    final DropDownChoice<Boolean> choice = new DropDownChoice<>("booleanChoice", valueModel, list);
    choice.add(new AjaxFormSubmitBehavior("change") {});
    choice.setNullValid(true);
    add(choice);
    this.choiceComponent = choice;
}
 
Example #10
Source File: CollectionLinkFilterPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private Select2MultiChoice<ODocument> createODocumentChooseComponent(String id, IModel<Collection<String>> classNamesModel,
                                                                     IModel<Collection<ODocument>> documentsModel) {
    Select2MultiChoice<ODocument> choice = new Select2MultiChoice<>(id, documentsModel,
            new ODocumentTextChoiceProvider(classNamesModel));
    choice.getSettings()
            .setWidth("100%")
            .setCloseOnSelect(true)
            .setTheme(BOOTSTRAP_SELECT2_THEME)
            .setContainerCssClass("link-filter-class-choice");
    choice.add(new AjaxFormSubmitBehavior("change") {});
    return choice;
}
 
Example #11
Source File: EmbeddedDocumentPanel.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
public EmbeddedDocumentPanel(String id, IModel<ODocument> model, IModel<OClass> rootClassModel, IModel<DisplayMode> modeModel) {
	super(id, model);
	this.rootClassModel = rootClassModel;
	this.subClassesModel = new SubClassesModel(rootClassModel, true, false);
	this.modeModel = modeModel;
	this.inputDocumentModel = new ODocumentModel(prepareEmbeddedDocument());
	
	embeddedClassChoice = new DropDownChoice<>("docClass", 
			new OClassModel(new PropertyModel<String>(inputDocumentModel, "@className")), 
			subClassesModel,
			OClassChoiceRenderer.INSTANCE);
	OClass rootClass = rootClassModel.getObject();
	embeddedClassChoice.setVisibilityAllowed(rootClass!=null && !rootClass.getSubclasses().isEmpty());
	embeddedClassChoice.add(new AjaxFormSubmitBehavior("change"){
		@Override
		protected void onSubmit(AjaxRequestTarget target) {
			embeddedClassChoice.convertInput();
			if(target!=null) target.add(propertyTable);
		}
		
		@Override
		public boolean getDefaultProcessing() {
			return false;
		}
	});
	add(embeddedClassChoice);
	IModel<List<OProperty>> propertiesModel = new LoadableDetachableModel<List<OProperty>>() {
		@SuppressWarnings("unchecked")
		@Override
		protected List<OProperty> load() {
			IOClassIntrospector oClassIntrospector = OrienteerWebApplication.get().getOClassIntrospector();
			OClass classFormToShow = embeddedClassChoice.getConvertedInput();
			if(classFormToShow==null) classFormToShow = embeddedClassChoice.getModelObject();
			return oClassIntrospector.listProperties(classFormToShow, new Predicate<OProperty>() {
				@Override
				public boolean apply(OProperty input) {
					return !((Boolean)CustomAttribute.HIDDEN.getValue(input));
				}
			});
		}
	};
	propertyTable = new OrienteerStructureTable<ODocument, OProperty>("table", inputDocumentModel, propertiesModel) {

		@Override
		protected Component getValueComponent(String id, IModel rowModel) {
			return new ODocumentMetaPanel<>(id, EmbeddedDocumentPanel.this.modeModel, getModel(), rowModel);
		}
	};
	propertyTable.setOutputMarkupId(true);
	add(propertyTable);
}