org.apache.wicket.ajax.AjaxRequestTarget Java Examples

The following examples show how to use org.apache.wicket.ajax.AjaxRequestTarget. 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: QualifierFeatureEditor.java    From inception with 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 #2
Source File: CloneActionLink.java    From nextreports-server with 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 #3
Source File: DefaultRestorePasswordPage.java    From Orienteer with 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 #4
Source File: InstallWizardPage.java    From openmeetings with 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 #5
Source File: StatementEditor.java    From inception with 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 File: AnalysisPanel.java    From nextreports-server with 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 #7
Source File: LambdaAjaxFormSubmittingBehavior.java    From webanno with 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 #8
Source File: CodeCommentPanel.java    From onedev with 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 #9
Source File: RecommenderEditorPanel.java    From inception with 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 #10
Source File: ColorPickerPanel.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @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 #11
Source File: ConfirmableAjaxBorder.java    From openmeetings with 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 #12
Source File: InfinitePagingDataTableHeadersToolbar.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
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 #13
Source File: AjaxOntopolyDropDownChoice.java    From ontopia with Apache License 2.0 5 votes vote down vote up
public AjaxOntopolyDropDownChoice(String id, IModel<T> model, IModel<List<T>> choices, IChoiceRenderer<? super T> renderer) {
  super(id, model, choices, renderer);

  setOutputMarkupId(true);

  add(new AjaxFormComponentUpdatingBehavior("onchange") {
    @Override
    protected void onUpdate(AjaxRequestTarget target) {
      AjaxOntopolyDropDownChoice.this.onUpdate(target);
    }
  });
}
 
Example #14
Source File: OpenModalWindowEvent.java    From Orienteer with 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 #15
Source File: ReportletDirectoryPanel.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(final IEvent<?> event) {
    super.onEvent(event);
    if (event.getPayload() instanceof ExitEvent && modal != null) {
        final AjaxRequestTarget target = ExitEvent.class.cast(event.getPayload()).getTarget();
        baseModal.show(false);
        baseModal.close(target);
    }
}
 
Example #16
Source File: Captcha.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	add(captchaText.setLabel(new ResourceModel("captcha.text")).add(new IValidator<String>() {
		private static final long serialVersionUID = 1L;

		@Override
		public void validate(IValidatable<String> validatable) {
			if (!randomText.equals(validatable.getValue())) {
				validatable.error(new ValidationError(getString("bad.captcha.text")));
			}
		}
	}).setOutputMarkupId(true));
	add(new BootstrapAjaxLink<>("refresh", Model.of(""), Buttons.Type.Outline_Info, new ResourceModel("lbl.refresh")) {
		private static final long serialVersionUID = 1L;

		@Override
		public void onClick(AjaxRequestTarget target) {
			captchaImageResource.invalidate();
			target.add(captcha);
		}

		@Override
		protected Icon newIcon(String markupId) {
			return new Icon(markupId, FontAwesome5IconType.sync_s);
		}
	});
}
 
Example #17
Source File: AssignmentStatisticsPanel.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void onInitialize() {
	super.onInitialize();

	final Long assignmentId = ((Model<Long>) getDefaultModel()).getObject();

	final Assignment assignment = this.businessService.getAssignment(assignmentId.longValue());

	AssignmentStatisticsPanel.this.window.setTitle(
			new StringResourceModel("label.statistics.title.assignment", getDefaultModel(), null, assignment.getName()).getString());

	final AssignmentGradeChart chart = new AssignmentGradeChart("gradingSchemaChart", assignmentId, null);
	add(chart);

	final AssignmentStatistics stats = new AssignmentStatistics("stats", getData(assignment));
	add(stats);

	add(new GbAjaxLink<Void>("done") {
		private static final long serialVersionUID = 1L;

		@Override
		public void onClick(final AjaxRequestTarget target) {
			AssignmentStatisticsPanel.this.window.close(target);
		}
	});

}
 
Example #18
Source File: DistributionSettingsPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
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 #19
Source File: DocumentListPanel.java    From webanno with 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 #20
Source File: KeyPressBehavior.java    From the-app with 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 #21
Source File: TagSetEditorPanel.java    From webanno with 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 #22
Source File: PullRequestListPanel.java    From onedev with MIT License 5 votes vote down vote up
private void doQuery(AjaxRequestTarget target) {
	requestsTable.setCurrentPage(0);
	target.add(body);
	querySubmitted = true;
	if (SecurityUtils.getUser() != null && getQuerySaveSupport() != null)
		target.add(saveQueryLink);
}
 
Example #23
Source File: JobReportListViewPanel.java    From onedev with 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 #24
Source File: BeanListPropertyEditor.java    From onedev with 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 #25
Source File: ProjectDependencyListViewPanel.java    From onedev with 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 #26
Source File: OClassTableOMethod.java    From Orienteer with 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 #27
Source File: AjaxOntopolyTextField.java    From ontopia with 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);
    }
  });
}
 
Example #28
Source File: RoomInvitationForm.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public void updateModel(AjaxRequestTarget target) {
	super.updateModel(target);
	Invitation i = getModelObject();
	i.setRoom(roomDao.get(roomId));
	if (i.getRoom() != null) {
		target.add(sipContainer.replace(new Label("room.confno", i.getRoom().getConfno())).setVisible(i.getRoom().isSipEnabled()));
	}
	groups.setModelObject(new ArrayList<Group>());
	groups.setEnabled(false);
	rdi.setModelObject(InviteeType.user);
}
 
Example #29
Source File: SuggestionViewPanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
/**
 * Schedules a rendering call via at the end of the given AJAX cycle. This method can be called
 * multiple times, even for the same annotation editor, but only resulting in a single rendering
 * call.
 */
private final void requestRender(AjaxRequestTarget aTarget, BratVisualizer aVis)
{
    aTarget.registerRespondListener(new AjaxComponentRespondListener(aVis, _target -> {
        // Is a document loaded?
        if (isBlank(aVis.getDocumentData())) {
            return;
        }

        aVis.render(_target);
    }));
}
 
Example #30
Source File: PullRequestChangesPage.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void onAddComment(AjaxRequestTarget target, Mark mark) {
	state.commentId = null;
	state.mark = getPermanentMark(mark);
	pushState(target);
	OneDev.getInstance(WebSocketManager.class).observe(this);
}