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

The following examples show how to use org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior. 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: DomainWizardBuilder.java    From syncope with Apache License 2.0 6 votes vote down vote up
public KeymasterConfParams(final Domain domain) {
    JsonEditorPanel keymasterConfParams = new JsonEditorPanel(
            null, new PropertyModel<>(domain, "keymasterConfParams"), false, pageRef);
    keymasterConfParams.setOutputMarkupPlaceholderTag(true);
    keymasterConfParams.setVisible(false);
    add(keymasterConfParams);

    AjaxCheckBoxPanel defaultKeymasterConfParams = new AjaxCheckBoxPanel(
            "defaultKeymasterConfParams", "defaultKeymasterConfParams", Model.of(true), true);
    defaultKeymasterConfParams.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -6139318907146065915L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            keymasterConfParams.setVisible(
                    !BooleanUtils.toBoolean(defaultKeymasterConfParams.getField().getConvertedInput()));
            target.add(keymasterConfParams);
        }
    });
    add(defaultKeymasterConfParams);
}
 
Example #2
Source File: PollResultsDialog.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
	add(chartDiv.setOutputMarkupId(true));
	chartSimple = getString("1414");
	chartPie = getString("1415");
	add(name, question, count);
	chartType = new DropDownChoice<>("chartType", Model.of(chartSimple), List.of(chartSimple, chartPie));
	add(chartType.add(new AjaxFormComponentUpdatingBehavior("change") {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			redraw(target, false);
		}
	}));
	super.onInitialize();
}
 
Example #3
Source File: PagingNavigatorPanel.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	dataView.setItemsPerPage(entitiesPerPage);
	final Form<Void> f = new Form<>("pagingForm");
	f.add(new OmPagingNavigator("navigator", dataView).setOutputMarkupId(true))
		.add(new DropDownChoice<>("entitiesPerPage", new PropertyModel<Integer>(this, "entitiesPerPage"), numbers)
			.add(new AjaxFormComponentUpdatingBehavior("change") {
				private static final long serialVersionUID = 1L;

				@Override
				protected void onUpdate(AjaxRequestTarget target) {
					long newPage = dataView.getCurrentPage() * dataView.getItemsPerPage() / entitiesPerPage;
					dataView.setItemsPerPage(entitiesPerPage);
					dataView.setCurrentPage(newPage);
					target.add(f);
					PagingNavigatorPanel.this.onEvent(target);
				}
			}));
	add(f.setOutputMarkupId(true));
}
 
Example #4
Source File: CafeAddress.java    From tutorials with MIT License 6 votes vote down vote up
public CafeAddress(final PageParameters parameters) {
    super(parameters);
    initCafes();

    ArrayList<String> cafeNames = new ArrayList<>(cafeNamesAndAddresses.keySet());
    selectedCafe = cafeNames.get(0);
    address = new Address(cafeNamesAndAddresses.get(selectedCafe).getAddress());

    final Label addressLabel = new Label("address", new PropertyModel<String>(this.address, "address"));
    addressLabel.setOutputMarkupId(true);

    final DropDownChoice<String> cafeDropdown = new DropDownChoice<>("cafes", new PropertyModel<>(this, "selectedCafe"), cafeNames);
    cafeDropdown.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            String name = (String) cafeDropdown.getDefaultModel().getObject();
            address.setAddress(cafeNamesAndAddresses.get(name).getAddress());
            target.add(addressLabel);
        }
    });

    add(addressLabel);
    add(cafeDropdown);

}
 
Example #5
Source File: FeatureEditor.java    From webanno with Apache License 2.0 6 votes vote down vote up
public void addFeatureUpdateBehavior()
{
    FormComponent focusComponent = getFocusComponent();
    focusComponent.add(new AjaxFormComponentUpdatingBehavior("change")
    {
        private static final long serialVersionUID = -8944946839865527412L;
        
        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes aAttributes)
        {
            super.updateAjaxAttributes(aAttributes);
            addDelay(aAttributes, 250);
        }
        
        @Override
        protected void onUpdate(AjaxRequestTarget aTarget)
        {
            send(focusComponent, BUBBLE,
                    new FeatureEditorValueChangedEvent(FeatureEditor.this, aTarget));
        }
    });
}
 
Example #6
Source File: SkillSelectAutoCompleteFormComponent.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param id
 * @param model
 */
public SkillSelectAutoCompleteFormComponent(final String id, final IModel<SkillDO> model)
{
  super(id, model);
  getSettings().withLabelValue(true).withMatchContains(true).withMinChars(2).withAutoSubmit(false).withWidth(400);

  // Prevents a submit with an empty autocomplete textfield by pressing enter
  add(AttributeModifier.append("onkeypress", "if ( event.which == 13 ) { return false; }"));

  add(AttributeModifier.append("class", "mm_delayBlur"));

  add(new AjaxFormComponentUpdatingBehavior("onChange") {
    private static final long serialVersionUID = 5394951486514219126L;

    @Override
    protected void onUpdate(final AjaxRequestTarget target)
    {
      // AjaxRequestTarget needs this.
    }
  });
}
 
Example #7
Source File: ConceptFeatureEditor.java    From inception with Apache License 2.0 6 votes vote down vote up
@Override
public void addFeatureUpdateBehavior()
{
    focusComponent.add(new AjaxFormComponentUpdatingBehavior("change")
    {
        private static final long serialVersionUID = -8944946839865527412L;
        
        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes aAttributes)
        {
            super.updateAjaxAttributes(aAttributes);
            aAttributes.getDynamicExtraParameters()
                    .add(focusComponent.getIdentifierDynamicAttributeScript());
            addDelay(aAttributes, 250);
        }
        
        @Override
        protected void onUpdate(AjaxRequestTarget aTarget)
        {
            aTarget.add(description);
            send(focusComponent, BUBBLE,
                    new FeatureEditorValueChangedEvent(ConceptFeatureEditor.this, aTarget));
        }
    });
}
 
Example #8
Source File: SelectToAddChoice.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	setOutputMarkupId(true);
	
	add(new AjaxFormComponentUpdatingBehavior("change") {

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			if (selection != null) {
				onSelect(target, selection);
				selection = null;
			}
			String script = String.format("setTimeout(function(){$('#%s').select2('data', null);}, 0);", getMarkupId());
			target.appendJavaScript(script);
		}
				
	});
}
 
Example #9
Source File: ParameterRuntimePanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
private AjaxFormComponentUpdatingBehavior createAjax(final QueryParameter parameter, final IModel model, final DateTextField dateField) {
     return new AjaxFormComponentUpdatingBehavior("onchange") {

         @SuppressWarnings("unchecked")
@Override
         protected void onUpdate(AjaxRequestTarget target) {
         	// @todo wicket 1.5 does not update model for DateField and DateTimeField
             // https://issues.apache.org/jira/browse/WICKET-4496	
             // use this as an workaround	
	model.setObject(dateField.getDefaultModelObject());
	
             populateDependentParameters(parameter, target, false);
         }

     };
 }
 
Example #10
Source File: ParameterRuntimePanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
private AjaxFormComponentUpdatingBehavior createAjax(final QueryParameter parameter, final IModel model, final Component component, final String time) {
     return new AjaxFormComponentUpdatingBehavior("onchange") {

         @SuppressWarnings("unchecked")
@Override
         protected void onUpdate(AjaxRequestTarget target) {
         	// @todo wicket 1.5 does not update model for DateField and DateTimeField
             // https://issues.apache.org/jira/browse/WICKET-4496	
             // use this as an workaround	
         	if ((model == null) || (model.getObject() == null)) {
         		return;
         	}
         	Date date = (Date)model.getObject();
         	if ("hours".equals(time)) {
         		date = DateUtil.setHours(date, (Integer)component.getDefaultModelObject());
         	} else if ("minutes".equals(time)) {
         		date = DateUtil.setMinutes(date, (Integer)component.getDefaultModelObject());
         	}            	
	model.setObject(date);
	
             populateDependentParameters(parameter, target, false);
         }

     };
 }
 
Example #11
Source File: BooleanPropertyEditor.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(input = new CheckBox("input", Model.of(getModelObject())));
	
	input.add(new AjaxFormComponentUpdatingBehavior("change"){

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
	input.setLabel(Model.of(getDescriptor().getDisplayName()));
}
 
Example #12
Source File: ModalInstancePage.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public ModalInstancePage(String id, TopicModel<Topic> topicModel, TopicTypeModel topicTypeModel, FieldsViewModel fieldsViewModel) {
  super(id);
  this.topicModel = topicModel;
  this.topicTypeModel = topicTypeModel;
  this.fieldsViewModel = fieldsViewModel;
  
  // page is read-only if topic type is read-only
  this.isReadOnly = ((topicTypeModel != null && topicTypeModel.getTopicType().isReadOnly()) || (Objects.equals(getRequest().getParameter("ro"), "true")));

  this.popupContent = new WebMarkupContainer("popupContent");
  popupContent.setOutputMarkupId(true);
  add(popupContent);
  
  popupContent.add(createInstancePanel("instancePanel"));
  
  Button closeOkButton = new Button("closeOK");
  closeOkButton.add(new AjaxFormComponentUpdatingBehavior("onclick") {
    @Override
    protected void onUpdate(AjaxRequestTarget target) {
      onCloseOk(target);
    }
  });
  popupContent.add(closeOkButton);
}
 
Example #13
Source File: DomainWizardBuilder.java    From syncope with Apache License 2.0 6 votes vote down vote up
public Content(final Domain domain) {
    XMLEditorPanel content = new XMLEditorPanel(
            null, new PropertyModel<>(domain, "content"), false, pageRef);
    content.setOutputMarkupPlaceholderTag(true);
    content.setVisible(false);
    add(content);

    AjaxCheckBoxPanel defaultContent = new AjaxCheckBoxPanel(
            "defaultContent", "defaultContent", Model.of(true), true);
    defaultContent.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            content.setVisible(!BooleanUtils.toBoolean(defaultContent.getField().getConvertedInput()));
            target.add(content);
        }
    });
    add(defaultContent);
}
 
Example #14
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 #15
Source File: AceEditorPanel.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
public AceEditorPanel(final String id, final IModel<String> model)
{
  super(id, model);
  editor = new WebMarkupContainer("editor");
  editor.setOutputMarkupId(true);
  textArea = new TextArea<String>("textArea", model);
  textArea.setOutputMarkupId(true);
  textArea.add(new AjaxFormComponentUpdatingBehavior("timerchange") { // event is thrown through JS
    @Override
    protected void onUpdate(AjaxRequestTarget target) {
      // java model is updated now
      onIdleModelUpdate();
    }
  });
  add(textArea);
  add(editor);
}
 
Example #16
Source File: SearchAnnotationSidebar.java    From inception with Apache License 2.0 6 votes vote down vote up
private DropDownChoice<AnnotationLayer> createLayerDropDownChoice(String aId,
    List<AnnotationLayer> aChoices)
{
    DropDownChoice<AnnotationLayer> layerChoice = new BootstrapSelect<>(aId, aChoices,
            new ChoiceRenderer<>("uiName"));

    layerChoice.add(new AjaxFormComponentUpdatingBehavior("change")
    {
        private static final long serialVersionUID = -6095969211884063787L;

        @Override protected void onUpdate(AjaxRequestTarget aTarget)
        {
            //update the choices for the feature selection dropdown
            groupingFeature.setChoices(annotationService
                .listAnnotationFeature(searchOptions.getObject().getGroupingLayer()));
            lowLevelPagingCheckBox.setModelObject(false);
            aTarget.add(groupingFeature, lowLevelPagingCheckBox);
        }
    });
    layerChoice.setNullValid(true);
    return layerChoice;
}
 
Example #17
Source File: AssociationTransformFunctionBoxPanel.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public AssociationTransformFunctionBoxPanel(String id, final TopicModel<Topic> topicModel) {
  super(id);
  add(new Label("title", new ResourceModel("transform.association.instances")));   
  
  Button addButton = new Button("button", new ResourceModel("transform"));
  addButton.add(new AjaxFormComponentUpdatingBehavior("onclick") {
    @Override
    protected void onUpdate(AjaxRequestTarget target) {
      Topic instance = topicModel.getTopic();
      Map<String,String> pageParametersMap = new HashMap<String,String>();
      pageParametersMap.put("topicMapId", instance.getTopicMap().getId());
      pageParametersMap.put("topicId", instance.getId());
      setResponsePage(AssociationTransformPage.class, new PageParameters(pageParametersMap));
    }          
  });
  add(addButton);
}
 
Example #18
Source File: TaskSelectAutoCompleteFormComponent.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param id
 */
public TaskSelectAutoCompleteFormComponent(final String id)
{
  super(id, null);
  setModel(new PropertyModel<TaskDO>(this, "taskDo"));
  getSettings().withLabelValue(true).withMatchContains(true).withMinChars(2).withAutoSubmit(false);
  add(AttributeModifier.append("onkeypress", "if ( event.which == 13 ) { return false; }"));
  add(AttributeModifier.append("class", "mm_delayBlur"));
  add(new AjaxFormComponentUpdatingBehavior("onChange") {
    private static final long serialVersionUID = 3681828654557441560L;

    @Override
    protected void onUpdate(final AjaxRequestTarget target)
    {
      // just update the model
    }
  });
}
 
Example #19
Source File: DynamicParameterRuntimePanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected void createItem(final ListItem<QueryParameter> item) {
    super.createItem(item);

    // add dynamic label and checkbox only for scheduler
    final QueryParameter parameter = item.getModelObject();
    boolean hasDefaultSource = (parameter.getDefaultSource() != null) && (parameter.getDefaultSource().trim().length() > 0);
    boolean hasSource = (parameter.getSource() != null) && (parameter.getSource().trim().length() > 0);

    final IModel dynamicModel = new PropertyModel(runtimeModel.getParameters(), parameter.getName() + ".dynamic");

    enableItem(item, dynamicModel, null);

    final CheckBox dynamicChkBox = new CheckBox("dynamicChkBox", dynamicModel);
    dynamicChkBox.setVisible(!runNow && (hasDefaultSource || hasSource));
    dynamicChkBox.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        protected void onUpdate(AjaxRequestTarget target) {
            enableItem(item, dynamicModel, target);
        }
    });
    item.add(dynamicChkBox.setOutputMarkupId(true));

    Label dynamicLabel = new Label("dynamicLabel", getString("DynamicParameterRuntimePanel.dynamic"));
    dynamicLabel.setVisible(!runNow && (hasDefaultSource || hasSource));
    item.add(dynamicLabel.setOutputMarkupId(true));

}
 
Example #20
Source File: ParameterRuntimePanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private AjaxFormComponentUpdatingBehavior createAjax(final QueryParameter parameter) {
    return new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            populateDependentParameters(parameter, target, false);
        }

    };
}
 
Example #21
Source File: NullableBooleanPropertyEditor.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	String stringValue;
	if (getModelObject() != null) {
		if (getModelObject())
			stringValue = "yes";
		else
			stringValue = "no";
	} else {
		stringValue = null;
	}
	input = new DropDownChoice<String>("input", Model.of(stringValue), Lists.newArrayList("yes", "no"));
	input.setLabel(Model.of(getDescriptor().getDisplayName()));
	
	input.setNullValid(true);
	
	add(input);

	input.add(new AjaxFormComponentUpdatingBehavior("change"){

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
}
 
Example #22
Source File: NextRuntimePanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
  public void addWicketComponents() {    	        	    	
  	
      final DropDownChoice<String> exportChoice = new DropDownChoice<String>("exportType", new PropertyModel<String>(runtimeModel, "exportType"), typeList,
      		new ChoiceRenderer<String>() {
			@Override
			public Object getDisplayValue(String name) {
				if (name.equals(ReportConstants.ETL_FORMAT)) {
					return getString("Analysis.source");
				} else {
					return name;
				}
			}
});
      exportChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {
          @Override
          protected void onUpdate(AjaxRequestTarget target) {
              String format = (String) getFormComponent().getConvertedInput();
              if (ReportConstants.ETL_FORMAT.equals(format)) {
			System.out.println("***** ETL selected");
			//analysisPanel.setVisible(true);
		} else {
			System.out.println("***** " + format);
			//analysisPanel.setVisible(false);
		}
              //target.add(analysisPanel);
          }
      });
	
      exportChoice.setRequired(true);
      add(exportChoice);
      
      if (report.isAlarmType() || report.isIndicatorType() || report.isDisplayType()) {
      	exportChoice.setEnabled(false);
      } else {
      	exportChoice.setRequired(true);
      }
      
      
  }
 
Example #23
Source File: BranchSingleChoiceEditor.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
   	
	Map<String, String> choices = new LinkedHashMap<>();
	if (Project.get() != null) {
		for (RefInfo ref: Project.get().getBranchRefInfos()) {
			String branch = GitUtils.ref2branch(ref.getRef().getName());
			choices.put(branch, branch);
		}
	}
	
	String selection = getModelObject();
	if (!choices.containsKey(selection))
		selection = null;

   	input = new BranchSingleChoice("input", Model.of(selection), Model.ofMap(choices)) {
   		
		@Override
		protected void onInitialize() {
			super.onInitialize();
			getSettings().configurePlaceholder(descriptor);
		}
		
   	};
   	
       // add this to control allowClear flag of select2
   	input.setRequired(descriptor.isPropertyRequired());
       input.setLabel(Model.of(getDescriptor().getDisplayName()));
	input.add(new AjaxFormComponentUpdatingBehavior("change"){

		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
	
       add(input);
}
 
Example #24
Source File: TeamCalFilterDialog.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void addTeamCalsChoiceFieldset()
{
  final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.selectCalendar")).setLabelSide(false);
  // TEAMCAL CHOICE FIELD
  final TeamCalChoiceProvider teamProvider = new TeamCalChoiceProvider();
  teamCalsChoice = new Select2MultiChoice<TeamCalDO>(fs.getSelect2MultiChoiceId(), new PropertyModel<Collection<TeamCalDO>>(
      TeamCalFilterDialog.this, "selectedCalendars"), teamProvider);
  teamCalsChoice.setOutputMarkupId(true);
  teamCalsChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {
    private static final long serialVersionUID = 1L;

    @Override
    protected void onUpdate(final AjaxRequestTarget target)
    {
      final TemplateEntry activeTemplateEntry = filter.getActiveTemplateEntry();
      final Set<Integer> oldCalIds = activeTemplateEntry.getCalendarIds();
      final List<Integer> newIds = new LinkedList<Integer>();
      // add new keys
      for (final TeamCalDO calendar : selectedCalendars) {
        if (oldCalIds.contains(calendar.getId()) == false) {
          activeTemplateEntry.addNewCalendarProperties(filter, calendar.getId());
        }
        newIds.add(calendar.getId());
      }
      // delete removed keys
      for (final Integer key : oldCalIds) {
        if (newIds.contains(key) == false) {
          activeTemplateEntry.removeCalendarProperties(key);
        }
      }
      updateComponents(target);
    }
  });
  fs.add(teamCalsChoice);
}
 
Example #25
Source File: BirtManagementPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected void populateItem(ListItem<BirtReportParameterDefinition> item) {
	String name = item.getModelObject().getName();
	item.add(new Label("parameterName",name));
	String defaultValue = item.getModelObject().getDefaultValue();
	Object value = reportPanel.getParameter(name);
	if (Strings.isNullOrEmpty((String) value)){
		reportPanel.setParameter(name, defaultValue);
	}
	item.add(new TextField<>("parameterInput",new PropertyModel<>(reportPanel,"config.parameters["+name+"]"))
			.add(new AjaxFormComponentUpdatingBehavior("change"){

				/**
				 * 
				 */
				private static final long serialVersionUID = 1L;

				@Override
				protected void onUpdate(AjaxRequestTarget target) {
					try {
						reportPanel.setCurrentPage(0);
						reportPanel.updateReportCache();
				        target.add(reportPanel);
				        target.add(pager);
					} catch (EngineException e) {
						String message = e.getMessage();
						error("Cannot update report cache:"+message);
						LOG.error("Can't update report cache", e);
					}
				}
				
	}));
}
 
Example #26
Source File: FeatureEditorListPanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
private TextField<String> createFocusResetHelper()
{
    TextField<String> textfield = new TextField<>("focusResetHelper");
    textfield.setModel(Model.of());
    textfield.setOutputMarkupId(true);
    textfield.add(new AjaxFormComponentUpdatingBehavior("focus")
    {
        private static final long serialVersionUID = -3030093250599939537L;

        @Override
        protected void onUpdate(AjaxRequestTarget aTarget)
        {
            List<FeatureEditor> editors = new ArrayList<>();
            featureEditorPanelContent.getItems().next()
                    .visitChildren(FeatureEditor.class, (e, visit) -> {
                        editors.add((FeatureEditor) e);
                        visit.dontGoDeeper();
                    });
            
            if (!editors.isEmpty()) {
                aTarget.focusComponent(editors.get(editors.size() - 1).getFocusComponent());
            }
        }
    });
    
    return textfield;
}
 
Example #27
Source File: FeatureEditorListPanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
private void addRefreshFeaturePanelBehavior(final FeatureEditor aFrag)
{
    aFrag.getFocusComponent().add(new AjaxFormComponentUpdatingBehavior("change")
    {
        private static final long serialVersionUID = 5179816588460867471L;
    
        @Override
        protected void onUpdate(AjaxRequestTarget aTarget)
        {
            owner.refresh(aTarget);
        }
    });
}
 
Example #28
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 #29
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 #30
Source File: ResourceStatusModal.java    From syncope with Apache License 2.0 5 votes vote down vote up
public ResourceStatusModal(
        final BaseModal<?> baseModal,
        final PageReference pageReference,
        final ResourceTO resource) {

    super(baseModal, pageReference, resource, null, false);

    List<String> availableAnyTypes = resource.getProvisions().stream().
            map(ProvisionTO::getAnyType).
            sorted(AnyTypeRestClient.KEY_COMPARATOR).
            collect(Collectors.toList());

    AjaxDropDownChoicePanel<String> anyTypes =
            new AjaxDropDownChoicePanel<>("anyTypes", "anyTypes", typeModel, false);
    anyTypes.setChoices(availableAnyTypes);
    anyTypes.hideLabel();
    add(anyTypes);

    anyTypes.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            ResourceStatusDirectoryPanel.class.cast(directoryPanel).
                    updateResultTable(typeModel.getObject(), target);
        }
    });
}