Java Code Examples for org.apache.wicket.ajax.AjaxRequestTarget

The following examples show how to use org.apache.wicket.ajax.AjaxRequestTarget. These examples are extracted from open source projects. 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
protected WebMarkupContainer newSortableHeader(final String borderId, final S property, final ISortStateLocator<S> locator)
{
	return new AjaxFallbackOrderByBorder<S>(borderId, property, locator, getAjaxCallListener())
	{
		private static final long serialVersionUID = 1L;

		@Override
		protected void onAjaxClick(final AjaxRequestTarget target)
		{
			target.add(getTable());
		}

		@Override
		protected void onSortChanged()
		{
			super.onSortChanged();
			getTable().setOffset(0);
		}
	};
}
 
Example 2
Source Project: inception   Source File: RecommenderEditorPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void actionSave(AjaxRequestTarget aTarget)
{
    Recommender recommender = recommenderModel.getObject();
    recommender.setProject(recommender.getLayer().getProject());

    recommendationService.createOrUpdateRecommender(recommender);

    // Not clearing the selection / editor panel here because saving the recommender may
    // cause additional UI elements to appear (e.g. options to upload pre-trained models
    // which cannot be uploaded/saved before the recommender has been persisted).
    
    // Reload whole panel because master panel also needs to be reloaded.
    aTarget.add(findParent(ProjectRecommendersPanel.class));

    success(getString("save.success"));
    aTarget.addChildren(getPage(), IFeedback.class);
}
 
Example 3
Source Project: webanno   Source File: LambdaAjaxFormSubmittingBehavior.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onSubmit(AjaxRequestTarget aTarget)
{
    try {
        action.accept(aTarget);
    }
    catch (Exception e) {
        if (exceptionHandler != null) {
            exceptionHandler.accept(aTarget, e);
        }
        else {
            Component component = getComponent();
            LoggerFactory.getLogger(component.getPage().getClass())
                    .error("Error: " + e.getMessage(), e);
            component.error("Error: " + e.getMessage());
            aTarget.addChildren(component.getPage(), IFeedback.class);
        }
    }
}
 
Example 4
Source Project: nextreports-server   Source File: AnalysisPanel.java    License: Apache License 2.0 6 votes vote down vote up
private AjaxLink<Analysis> getPaginateLink() {
 	return new ToolbarLink<Analysis>("paginate", "PaginatePanel.title", 200) {

@Override
protected FormContentPanel<Analysis> createPanel() {
	return new PaginatePanel(AnalysisPanel.this.getModel()) {
          	
              private static final long serialVersionUID = 1L;

              @Override
              public void onOk(AjaxRequestTarget target) {	                		                	         		                	
              	ModalWindow.closeCurrent(target);	   
              	changeDataProvider(AnalysisPanel.this.getModel(), target);	                	
              }
          };
}			
 	};
 }
 
Example 5
Source Project: inception   Source File: StatementEditor.java    License: Apache License 2.0 6 votes vote down vote up
private void actionMakeExplicit(AjaxRequestTarget aTarget) {
    try {
        // add the statement as-is to the knowledge base
        kbService.upsertStatement(kbModel.getObject(), statement.getObject());

        // to update the statement in the UI, one could either reload all statements of the
        // corresponding instance or (much easier) just set the inferred attribute of the
        // KBStatement to false, so that's what's done here
        statement.getObject().setInferred(false);
        aTarget.add(this);
        send(getPage(), Broadcast.BREADTH,
                new AjaxStatementChangedEvent(aTarget, statement.getObject()));
        
    }
    catch (RepositoryException e) {
        error("Unable to make statement explicit " + e.getLocalizedMessage());
        LOG.error("Unable to make statement explicit.", e);
        aTarget.addChildren(getPage(), IFeedback.class);
    }
}
 
Example 6
Source Project: Orienteer   Source File: DefaultRestorePasswordPage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates restore panel
 * @param id component id
 * @return restore password panel
 */
protected GenericPanel<OrienteerUser> createRestorePasswordPanel(String id) {
    return new DefaultRestorePasswordPanel(id, getModel()) {
        @Override
        protected void onConfigure() {
            super.onConfigure();
            setVisible(DBClosure.sudo(db -> getModelObject()) != null);
        }

        @Override
        protected void onRestore(AjaxRequestTarget target, IModel<OrienteerUser> model) {
            model.setObject(null);
            target.add(container);
        }
    };
}
 
Example 7
Source Project: onedev   Source File: CodeCommentPanel.java    License: MIT License 6 votes vote down vote up
private WebMarkupContainer newAddReplyContainer() {
	WebMarkupContainer addReplyContainer = new Fragment("addReply", "addReplyFrag", this) {

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(SecurityUtils.getUser() != null);
		}
		
	};
	addReplyContainer.setOutputMarkupId(true);
	addReplyContainer.add(new AjaxLink<Void>("reply") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			onAddReply(target);
		}
		
	});
	return addReplyContainer;
}
 
Example 8
Source Project: openmeetings   Source File: ConfirmableAjaxBorder.java    License: Apache License 2.0 6 votes vote down vote up
@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
/**
 * @see org.apache.wicket.Component#onInitialize()
 */
@Override
protected void onInitialize()
{
  super.onInitialize();
  final Form<Void> colorForm = new Form<Void>("colorForm");
  add(colorForm);
  final TextField<String> colorField = new TextField<String>("color", new PropertyModel<String>(this, "selectedColor"));
  colorField.add(new AjaxFormComponentUpdatingBehavior("onChange") {
    private static final long serialVersionUID = 1L;

    /**
     * @see org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache.wicket.ajax.AjaxRequestTarget)
     */
    @Override
    protected void onUpdate(final AjaxRequestTarget target)
    {
      onColorUpdate(selectedColor);
    }
  });
  colorForm.add(colorField);
  // colorpicker js
  final JavaScriptTemplate jsTemplate = new JavaScriptTemplate(new PackageTextTemplate(ColorPickerPanel.class, "ColorPicker.js.template"));
  final String javaScript = jsTemplate.asString(new MicroMap<String, String>("markupId", colorField.getMarkupId()));
  add(new Label("template", javaScript).setEscapeModelStrings(false));
}
 
Example 10
Source Project: openmeetings   Source File: InstallWizardPage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	final InstallWizard wizard = new InstallWizard("wizard", getString("install.wizard.installation"));
	add(wizard.setEnabled(false));
	// This code is required to detect time zone offset
	add(new AjaxClientInfoBehavior() {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onClientInfo(AjaxRequestTarget target, WebClientInfo clientInfo) {
			super.onClientInfo(target, clientInfo);
			wizard.initTzDropDown();
			target.add(wizard.setEnabled(true));
		}
	});
}
 
Example 11
Source Project: nextreports-server   Source File: CloneActionLink.java    License: Apache License 2.0 6 votes vote down vote up
public void executeAction(AjaxRequestTarget target) {
    Entity entity = getActionContext().getEntity();
    try {                        
    	
    	Entity clonedEntity = ObjectCloner.silenceDeepCopy(entity);        	
        String cloneName = clonedEntity.getName() + "_clone";            
        clonedEntity.setName(cloneName);                        
        String id = storageService.addEntity(clonedEntity);
        
        SchedulerJob job =  (SchedulerJob)storageService.getEntityById(id);

        EntityBrowserPanel panel = findParent(EntityBrowserPanel.class);
        ScheduleWizard wizard = new ScheduleWizard("work", job);
        wizard.add(AttributeModifier.append("class", "wizardScheduler"));
        panel.forwardWorkspace(wizard  , target);
        
        //setResponsePage(new ScheduleWizardPage(job));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 12
Source Project: inception   Source File: QualifierFeatureEditor.java    License: Apache License 2.0 6 votes vote down vote up
private void actionDel(AjaxRequestTarget aTarget)
{
    List<LinkWithRoleModel> links = (List<LinkWithRoleModel>) QualifierFeatureEditor.this
        .getModelObject().value;
    AnnotatorState state = QualifierFeatureEditor.this.stateModel.getObject();

    links.remove(state.getArmedSlot());
    state.clearArmedSlot();
    selectedRole = null;

    aTarget.add(content);

    // Auto-commit if working on existing annotation
    if (state.getSelection().getAnnotation().isSet()) {
        try {
            actionHandler.actionCreateOrUpdate(aTarget, actionHandler.getEditorCas());
        }
        catch (Exception e) {
            handleException(this, aTarget, e);
        }
    }
}
 
Example 13
Source Project: webanno   Source File: OpenDocumentDialogPanel.java    License: Apache License 2.0 5 votes vote down vote up
private OverviewListChoice<DecoratedObject<SourceDocument>> createDocListChoice()
{
    docListChoice = new OverviewListChoice<>("documents", Model.of(), listDocuments());
    docListChoice.setChoiceRenderer(new ChoiceRenderer<DecoratedObject<SourceDocument>>()
    {
        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(DecoratedObject<SourceDocument> aDoc)
        {
            return defaultIfEmpty(aDoc.getLabel(), aDoc.get().getName());
        }
    });
    docListChoice.setOutputMarkupId(true);
    docListChoice.add(new OnChangeAjaxBehavior()
    {
        private static final long serialVersionUID = -8232688660762056913L;

        @Override
        protected void onUpdate(AjaxRequestTarget aTarget)
        {
            aTarget.add(buttonsContainer);
        }
    }).add(AjaxEventBehavior.onEvent("dblclick", _target -> actionOpenDocument(_target, null)));

    if (!docListChoice.getChoices().isEmpty()) {
        docListChoice.setModelObject(docListChoice.getChoices().get(0));
    }
    
    return docListChoice;
}
 
Example 14
Source Project: onedev   Source File: BlobDiffPanel.java    License: MIT License 5 votes vote down vote up
@Override
public void onCommentAdded(AjaxRequestTarget target, CodeComment comment) {
	Component content = get(CONTENT_ID);
	if (content instanceof SourceAware) {
		SourceAware sourceAware = (SourceAware) content;
		sourceAware.onCommentAdded(target, comment);
	}
}
 
Example 15
Source Project: onedev   Source File: AjaxActionTab.java    License: MIT License 5 votes vote down vote up
@Override
protected final void onSelect(Component tabLink) {
	AjaxRequestTarget target = Preconditions.checkNotNull(RequestCycle.get().find(AjaxRequestTarget.class));
	Tabbable tabbable = tabLink.findParent(Tabbable.class);
	if (tabbable == null) {
		Tabbable.TabsFragment tabs = Preconditions.checkNotNull(tabLink.findParent(Tabbable.TabsFragment.class));
		tabs.getDropdown().close();
		tabbable = tabs.getTabbable();
	}
	target.add(tabbable);
	onSelect(target, tabLink);
}
 
Example 16
Source Project: Orienteer   Source File: OpenModalWindowEvent.java    License: Apache License 2.0 5 votes vote down vote up
public OpenModalWindowEvent(AjaxRequestTarget target,
                            IModel<String> titleModel,
                            SerializableFunction<String, Component> contentGenerator
) {
    super(target);
    Args.notNull(titleModel, "titleModel");
    Args.notNull(contentGenerator, "contentGenerator");
    this.titleModel = titleModel;
    this.contentGenerator = contentGenerator;
}
 
Example 17
@Override
protected void respond(AjaxRequestTarget target) {
	String value = getComponent().getRequest().getRequestParameters().getParameterValue(X_VALUE_PARAM_NAME).toString();		
	if (value != null) { // defensive
		onClickChart(target, value);			
	}		
}
 
Example 18
Source Project: inception   Source File: PropertyPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void actionDelete(AjaxRequestTarget aTarget) {
    kbService.deleteProperty(kbModel.getObject(), kbObjectModel.getObject());
    kbObjectModel.setObject(null);

    // send deselection event
    send(getPage(), Broadcast.BREADTH, new AjaxPropertySelectionEvent(aTarget, null, true));
}
 
Example 19
public LinkPanel(String id, final IModel labelModel) {
	super(id);
	AjaxLink link = new AjaxLink("link") {
		@Override
		public void onClick(AjaxRequestTarget target) {
			clicked(target);
		}
	};
	link.add(new Label("linkLabel", labelModel));
	add(link);
}
 
Example 20
Source Project: Orienteer   Source File: AddTabDialog.java    License: Apache License 2.0 5 votes vote down vote up
public AddTabDialog(String id) {
	super(id);
	Form<T> form = new Form<T>("addTabForm");
	form.add(tabName = new TextField<String>("tabName", Model.of("")));
	form.add(new AjaxButton("addTab") {
		@Override
		protected void onSubmit(AjaxRequestTarget target) {
			onCreateTab(tabName.getModelObject(), Optional.of(target));
			tabName.setModelObject("");
		}
	});
	add(form);
}
 
Example 21
Source Project: the-app   Source File: KeyPressBehavior.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onEvent(AjaxRequestTarget target) {
    //Extract the keycode parameter from RequestCycle
    final Request request = RequestCycle.get().getRequest();
    final String jsKeycode = request.getRequestParameters()
            .getParameterValue("keycode").toString("");

    switch (jsKeycode) {
        case "112":
            selectorBean.standard();
            target.getPage().setResponsePage(currentPage);
            break;
        case "113":
            selectorBean.next();
            target.getPage().setResponsePage(currentPage);
            break;
        case "114":
            tooglesBean.toogleHighlightingFeature();
            target.getPage().setResponsePage(currentPage);
            break;
        case "115":
            tooglesBean.toogleTopSellerFeature();
            target.getPage().setResponsePage(currentPage);
            break;
        default:
    }
}
 
Example 22
Source Project: AppStash   Source File: LoginPanel.java    License: Apache License 2.0 5 votes vote down vote up
protected void submitLoginForm(AjaxRequestTarget target, LoginInfo loginInfo) {
    boolean authenticate = authenticate(loginInfo);
    if (!authenticate) {
        error(getString("authentication.failed"));
        target.add(feedback);
    } else {
        getAuthenticationService().getAuthenticatedUserInfo();
        Session.get().info(getString("authentication.success"));
        send(this, Broadcast.BREADTH, new LoginEvent(LoginPanel.this, target));
        setResponsePage(Application.get().getHomePage());
    }
}
 
Example 23
protected void afterChange(Form form, AjaxRequestTarget target) {
	Settings settings = (Settings) form.getModelObject();
	JavaMailSenderImpl mailSender = (JavaMailSenderImpl) NextServerApplication.get().getSpringBean("mailSender");
   		
	if (!oldMailIp.equals(settings.getMailServer().getIp()) || 
    	!oldMailPort.equals(settings.getMailServer().getPort())) {    		
            mailSender.setHost(settings.getMailServer().getIp());
            mailSender.setPort(settings.getMailServer().getPort());
    }
   	    	
  		mailSender.setPassword(settings.getMailServer().getPassword());
  		mailSender.setUsername(settings.getMailServer().getUsername());
	mailSender.getJavaMailProperties().put("mail.smtp.starttls.enable", settings.getMailServer().getEnableTls());
}
 
Example 24
Source Project: webanno   Source File: DocumentListPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void actionDelete(AjaxRequestTarget aTarget, Form<Void> aForm)
{
    if (selectedDocuments.getObject() == null || selectedDocuments.getObject().isEmpty()) {
        error("No documents selected");
        aTarget.addChildren(getPage(), IFeedback.class);
        return;
    }
    
    confirmationDialog.setContentModel(new StringResourceModel("DeleteDialog.text", this)
            .setParameters(selectedDocuments.getObject().size()));
    confirmationDialog.show(aTarget);
    
    confirmationDialog.setConfirmAction((_target) -> {
        for (SourceDocument sourceDocument : selectedDocuments.getObject()) {
            try {
                documentService.removeSourceDocument(sourceDocument);
            }
            catch (IOException e) {
                LOG.error("Unable to delete document", e);
                error("Unable to delete document: " + e.getMessage());
                _target.addChildren(getPage(), IFeedback.class);
            }
        }
        selectedDocuments.getObject().clear();
        _target.add(getPage());
    });
}
 
Example 25
Source Project: webanno   Source File: TagSetEditorPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void actionCancel(AjaxRequestTarget aTarget) {
    selectedTagSet.setObject(null);
    selectedTag.setObject(null);
    
    // Reload whole page because master panel also needs to be reloaded.
    aTarget.add(getPage());
}
 
Example 26
Source Project: onedev   Source File: JobReportListViewPanel.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, SideFloating.Placement.RIGHT) {

				@Override
				protected String getTitle() {
					JobReport report = reports.get(index);
					return "Report (type: " + EditableUtils.getDisplayName(report.getClass()) + ")";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "job-report def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					return BeanContext.view(id, reports.get(index));
				}

			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 27
Source Project: onedev   Source File: BeanListPropertyEditor.java    License: MIT License 5 votes vote down vote up
private WebMarkupContainer addRow(Serializable element) {
	WebMarkupContainer row = new WebMarkupContainer(rows.newChildId());
	row.setOutputMarkupId(true);
	rows.add(row);
	
	RepeatingView columns = new RepeatingView("properties");
	row.add(columns);
	
	for (PropertyContext<Serializable> propertyContext: propertyContexts) {
		WebMarkupContainer column = new WebMarkupContainer(columns.newChildId());
		column.add(AttributeAppender.append("class", "property-" + propertyContext.getPropertyName()));
		columns.add(column);
		
		Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(element);
		PropertyEditor<?> propertyEditor = propertyContext.renderForEdit("propertyEditor", Model.of(propertyValue));
		column.add(propertyEditor);
		column.add(new FencedFeedbackPanel("feedback", propertyEditor));
	}
	
	row.add(new AjaxButton("deleteElement") {

		@Override
		protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
			super.onSubmit(target, form);
			markFormDirty(target);
			target.appendJavaScript($(row).chain("remove").get());
			rows.remove(row);
			target.add(noElements);
			onPropertyUpdating(target);
		}

	}.setDefaultFormProcessing(false));
	
	return row;
}
 
Example 28
Source Project: onedev   Source File: ProjectDependencyListViewPanel.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	AjaxLink<Void> link = new AjaxLink<Void>("link") {

		@Override
		public void onClick(AjaxRequestTarget target) {
			new SideFloating(target, Placement.RIGHT) {

				@Override
				protected String getTitle() {
					return "Project Dependency";
				}

				@Override
				protected void onInitialize() {
					super.onInitialize();
					add(AttributeAppender.append("class", "project-dependency def-detail"));
				}

				@Override
				protected Component newBody(String id) {
					return BeanContext.view(id, dependencies.get(index));
				}
					
			};
		}
		
	};
	link.add(newLabel("label"));
	add(link);
}
 
Example 29
Source Project: Orienteer   Source File: OClassTableOMethod.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Command<?> createCommand(String id) {
	//displays only if getTableObject assigned and it is "OrienteerDataTable"
	if (displayComponent == null && getContext().getRelatedComponent()!=null && getContext().getRelatedComponent() instanceof OrienteerDataTable){
		String titleKey = getConfig().getTitleKey();
		if (titleKey.isEmpty()){
			titleKey = getConfig().getMethodId();
		}			
		OrienteerDataTable<ODocument, ?> table=(OrienteerDataTable<ODocument, ?>) getContext().getRelatedComponent();
		displayComponent = new AbstractCheckBoxEnabledCommand<ODocument>(getTitleModel(),table){
			private static final long serialVersionUID = 1L;
			
			@Override
			protected void onInitialize() {
				super.onInitialize();
				applyVisualSettings(this);
			}

			@Override
			protected void performMultiAction(AjaxRequestTarget target, List<ODocument> objects) {
				for (ODocument curDoc : objects) {
					invoke(curDoc);
				}
				if (getConfig().isResetSelection()){
					resetSelection();
				}
			}
		};
		applyBehaviors(displayComponent);
	}
	
	return displayComponent;
}
 
Example 30
Source Project: ontopia   Source File: AjaxOntopolyTextField.java    License: Apache License 2.0 5 votes vote down vote up
public AjaxOntopolyTextField(String id, IModel<String> model) {
  super(id, model);
  
  setOutputMarkupId(true);

  add(new AjaxFormComponentUpdatingBehavior("onchange") {
    @Override
    protected void onUpdate(AjaxRequestTarget target) {
      AjaxOntopolyTextField.this.onUpdate(target);
    }
  });
}