当前位置: 首页>>代码示例>>Java>>正文


Java TextField.setValue方法代码示例

本文整理汇总了Java中com.vaadin.ui.TextField.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java TextField.setValue方法的具体用法?Java TextField.setValue怎么用?Java TextField.setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vaadin.ui.TextField的用法示例。


在下文中一共展示了TextField.setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testValid

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Test
public void testValid() {
	TextField text = new TextField();

	binder.bind(text, d -> d.getText() == null ? "" : d.getText(), (e, f) -> e.setText("".equals(f) ? null : f),
			"text");

	MyEntity t = new MyEntity();

	t.setText("bla");
	binder.setBean(t);

	assertTrue(binder.isValid());

	text.setValue("");
	assertNull(t.getText());
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:18,代码来源:BasicBinderStringTest.java

示例2: testNullRepresentation

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Test
public void testNullRepresentation() {
	TextField field = new TextField();

	// Bind with null representation
	Binder<MyEntity> binder = new BeanValidationBinder<>(MyEntity.class);
	binder.forField(field).withNullRepresentation("").bind("text");

	MyEntity bean = new MyEntity();

	assertTrue(validator.validate(bean).isEmpty());
	assertTrue(binder.validate().isOk());

	binder.setBean(bean);

	field.setValue("test");
	assertEquals("test", bean.getText());

	field.setValue("");
	assertNull(bean.getText());

	assertTrue(validator.validate(bean).isEmpty());
	assertTrue(binder.validate().isOk());
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:25,代码来源:BeanValidationBinderStringTest.java

示例3: testNullRepresentationSizeMin1

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Test
public void testNullRepresentationSizeMin1() {
	TextField field = new TextField();

	// Bind with null representation
	Binder<MyEntitySizeMin1> binder = new BeanValidationBinder<>(MyEntitySizeMin1.class);
	binder.forField(field).withNullRepresentation("").bind("text");

	MyEntitySizeMin1 bean = new MyEntitySizeMin1();

	assertTrue(validator.validate(bean).isEmpty());
	assertTrue(binder.validate().isOk());

	binder.setBean(bean);

	field.setValue("test");
	assertEquals("test", bean.getText());

	field.setValue("");
	assertNull(bean.getText());

	assertTrue(validator.validate(bean).isEmpty());
	assertTrue(binder.validate().isOk());
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:25,代码来源:BeanValidationBinderStringTest.java

示例4: updateDataRootGrid

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void updateDataRootGrid() {
  int header = getDataRootFirstRow();
  int nRows = dataRoots.getValue().intValue() + header;
  // removes rows
  for (int r = dataRootGrid.getRows(); r > nRows; r--) {
    dataRootGrid.removeRow(r - 1);
  }
  // set new row limit
  dataRootGrid.setRows(nRows);
  // add new rows
  for (int r = header; r < nRows; r++) {
    if (dataRootGrid.getComponent(0, r) == null) {
      TextField id = new TextField();
      id.setPlaceholder("ID");
      id.setValue("dataroot-" + (r - header + 1));
      TextField path = new TextField();
      path.setPlaceholder("Location");
      path.setValue(new File(baseLocation.getValue(), "data/dataroot-" + (r - header + 1)).getAbsolutePath());
      path.setEnabled(false);
      id.addValueChangeListener(event -> path.setValue(new File(baseLocation.getValue(), "data/" + event.getValue()).getAbsolutePath()));
      path.setWidth(100, Unit.PERCENTAGE);
      dataRootGrid.addComponent(id, 0, r, 1, r);
      dataRootGrid.addComponent(path, DATAROOT_PATH_COLUMN, r);
    }
  }
}
 
开发者ID:Terracotta-OSS,项目名称:tinypounder,代码行数:27,代码来源:TinyPounderMainUI.java

示例5: platformBackupWanted

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void platformBackupWanted(boolean wanted) {
  int row = getBackupRow();
  if (wanted) {
    dataRootGrid.insertRow(row);
    TextField id = new TextField();
    id.setPlaceholder("ID");
    id.setValue("BACKUP");
    id.setReadOnly(true);
    TextField path = new TextField();
    path.setPlaceholder("Location");
    path.setValue(new File(baseLocation.getValue(), "data/backup").getAbsolutePath());
    path.setEnabled(false);
    path.setWidth(100, Unit.PERCENTAGE);
    dataRootGrid.addComponent(id, 0, row, 1, row);
    dataRootGrid.addComponent(path, DATAROOT_PATH_COLUMN, row);
  } else {
    dataRootGrid.removeRow(row);
  }
}
 
开发者ID:Terracotta-OSS,项目名称:tinypounder,代码行数:20,代码来源:TinyPounderMainUI.java

示例6: platformPersistenceWanted

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void platformPersistenceWanted(boolean wanted) {
  int row = getPersistenceRow();
  if (wanted) {
    dataRootGrid.insertRow(row);
    TextField id = new TextField();
    id.setPlaceholder("ID");
    id.setValue("PLATFORM");
    id.setReadOnly(true);
    TextField path = new TextField();
    path.setPlaceholder("Location");
    path.setValue(new File(baseLocation.getValue(), "data/platform").getAbsolutePath());
    path.setEnabled(false);
    path.setWidth(100, Unit.PERCENTAGE);
    dataRootGrid.addComponent(id, 0, row, 1, row);
    dataRootGrid.addComponent(path, DATAROOT_PATH_COLUMN, row);
  } else {
    dataRootGrid.removeRow(row);
  }
}
 
开发者ID:Terracotta-OSS,项目名称:tinypounder,代码行数:20,代码来源:TinyPounderMainUI.java

示例7: addFileNameLayout

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private void addFileNameLayout(final Item newItem, final String baseSoftwareModuleNameVersion,
        final String customFileName, final String itemId) {
    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    final TextField fileNameTextField = createTextField(
            baseSoftwareModuleNameVersion + "/" + customFileName + "/customFileName");
    fileNameTextField.setData(baseSoftwareModuleNameVersion + "/" + customFileName);
    fileNameTextField.setValue(customFileName);

    newItem.getItemProperty(FILE_NAME).setValue(fileNameTextField.getValue());

    final Label warningIconLabel = getWarningLabel();
    warningIconLabel.setId(baseSoftwareModuleNameVersion + "/" + customFileName + "/icon");
    setWarningIcon(warningIconLabel, fileNameTextField.getValue(), itemId);
    newItem.getItemProperty(WARNING_ICON).setValue(warningIconLabel);

    horizontalLayout.addComponent(fileNameTextField);
    horizontalLayout.setComponentAlignment(fileNameTextField, Alignment.MIDDLE_LEFT);
    horizontalLayout.addComponent(warningIconLabel);
    horizontalLayout.setComponentAlignment(warningIconLabel, Alignment.MIDDLE_RIGHT);
    newItem.getItemProperty(FILE_NAME_LAYOUT).setValue(horizontalLayout);

    fileNameTextField.addTextChangeListener(event -> onFileNameChange(event, warningIconLabel, newItem));
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:24,代码来源:UploadConfirmationWindow.java

示例8: getSecurityTokenLayout

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
private HorizontalLayout getSecurityTokenLayout(final String securityToken) {
    final HorizontalLayout securityTokenLayout = new HorizontalLayout();

    final Label securityTableLbl = new Label(
            SPUIComponentProvider.getBoldHTMLText(getI18n().getMessage("label.target.security.token")),
            ContentMode.HTML);
    securityTableLbl.addStyleName(SPUIDefinitions.TEXT_STYLE);
    securityTableLbl.addStyleName("label-style");

    final TextField securityTokentxt = new TextField();
    securityTokentxt.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    securityTokentxt.addStyleName(ValoTheme.TEXTFIELD_TINY);
    securityTokentxt.addStyleName("targetDtls-securityToken");
    securityTokentxt.addStyleName(SPUIDefinitions.TEXT_STYLE);
    securityTokentxt.setCaption(null);
    securityTokentxt.setNullRepresentation("");
    securityTokentxt.setValue(securityToken);
    securityTokentxt.setReadOnly(true);

    securityTokenLayout.addComponent(securityTableLbl);
    securityTokenLayout.addComponent(securityTokentxt);
    return securityTokenLayout;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:24,代码来源:TargetDetails.java

示例9: getPropertyField

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Override
public Field getPropertyField(FormProperty formProperty) {
  final TextField textField = new TextField(getPropertyLabel(formProperty));
  textField.setRequired(formProperty.isRequired());
  textField.setEnabled(formProperty.isWritable());
  textField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
  
  if (formProperty.getValue() != null) {
    textField.setValue(formProperty.getValue());
  }

  // Add validation of numeric value
  textField.addValidator(new LongValidator("Value must be a long"));
  textField.setImmediate(true);

  return textField;
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:18,代码来源:LongFormPropertyRenderer.java

示例10: initContent

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Override
protected void initContent(VerticalLayout layout) throws Exception {
	setCaption(operation.getDescription().getCaption());
	{
		TextField label = new TextField();
		label.setEnabled(false);
		label.setValue(nodePaths());
		label.setWidth("100%");
		layout.addComponent(label);
	}
	editor = operation.createEditor(editorProperties, this);
	if (editor != null)	{
		layout.addComponent(editor);
		layout.setExpandRatio(editor, 1);
	}
}
 
开发者ID:mhus,项目名称:cherry-web,代码行数:17,代码来源:ActionDialog.java

示例11: initUi

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Override
public void initUi() {
	
	title = new TextField("Title");
	title.setValue(data.getString("title", ""));
	title.setWidth("100%");
	addComponent(title);
	
	textUi = new CherryRichTextArea();
	text = textUi.createEditor();
	textUi.setComponentEditor(text);
	
	try {
		textUi.setValue(data.getString("text", ""));
	} catch (MException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	text.setSizeFull();
	addComponent(text);

}
 
开发者ID:mhus,项目名称:cherry-web,代码行数:23,代码来源:SimpleEditor.java

示例12: testValid

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Test
public void testValid() {
	TextField number = new TextField();

	BasicBinder<MyEntity> binder = new BasicBinder<>();
	binder.bind(number, d -> d.getNumber() == null ? "" : Integer.toString(d.getNumber()),
			(e, f) -> e.setNumber("".equals(f) ? null : Integer.parseInt(f)), "number");
	/*
	 * binder.forField(number) .withNullRepresentation("") .withConverter(new
	 * StringToIntegerConverter("Must be a number")) .bind("number");
	 */
	MyEntity t = new MyEntity();

	// valid
	t.setNumber(1);
	binder.setBean(t);

	assertTrue(binder.isValid());

	// invalid
	t.setNumber(0);
	binder.setBean(t);
	assertFalse(binder.isValid());

	t.setNumber(null);
	binder.setBean(t);
	assertFalse(binder.isValid());

	assertEquals("", number.getValue());
	number.setValue("1");
	assertEquals(new Integer(1), t.getNumber());
	number.setValue("");

	assertEquals(null, t.getNumber());
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:36,代码来源:BasicBinderNumberTest.java

示例13: testValid2

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Test
public void testValid2() {
	TextField number = new TextField();

	BasicBinder<MyEntity> binder = new BasicBinder<>();
	binder.bind(number, d -> d.getNumber(), (e, f) -> e.setNumber(f), "number",
			new NullConverter<String>("").chain(new StringToIntegerConverter("Conversion failed")));

	MyEntity t = new MyEntity();

	// valid
	t.setNumber(1);
	binder.setBean(t);

	assertTrue(binder.isValid());

	// invalid
	t.setNumber(0);
	binder.setBean(t);
	assertFalse(binder.isValid());

	t.setNumber(null);
	binder.setBean(t);
	assertFalse(binder.isValid());
	assertEquals("", number.getValue());

	number.setValue("1");
	assertEquals(new Integer(1), t.getNumber());
	number.setValue("");

	assertEquals(null, t.getNumber());

}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:34,代码来源:BasicBinderNumberTest.java

示例14: testSizeMin1

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Test
public void testSizeMin1() {
	TextField field = new TextField();

	// Bind with null representation
	Binder<MyEntitySizeMin1> binder = new BeanValidationBinder<>(MyEntitySizeMin1.class);
	binder.forField(field).bind("text");

	field.setValue("reset");

	MyEntitySizeMin1 bean = new MyEntitySizeMin1();

	// Why doesn't this fail when there is no null representation?
	// https://github.com/vaadin/framework/issues/9453
	binder.setBean(bean);

	System.out.println("Field value: " + field.getValue());

	assertTrue(validator.validate(bean).isEmpty());

	field.setValue("test");
	assertEquals("test", bean.getText());

	assertTrue(validator.validate(bean).isEmpty());
	assertTrue(binder.validate().isOk());

	field.setValue("");
	assertFalse(binder.validate().isOk());

	// Since validation fails the value is still "test" and not "" (also kind of
	// hinted at in https://github.com/vaadin/framework/issues/9453)
	// See Binder.BinderImpl.writeFieldValue()

	// assertEquals("", bean.getText());
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:36,代码来源:BeanValidationBinderStringTest.java

示例15: testValid

import com.vaadin.ui.TextField; //导入方法依赖的package包/类
@Test
public void testValid() {
	TextField text = new TextField();

	ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
	Validator validator = factory.getValidator();

	Binder<MyEntity> binder = new BeanValidationBinder<>(MyEntity.class);
	binder.forField(text).withNullRepresentation("").bind("text");

	MyEntity t = new MyEntity();

	// valid
	t.setText("bla");
	binder.setBean(t);

	assertTrue(validator.validate(t).isEmpty());
	assertTrue(binder.validate().isOk());

	text.setValue("");
	assertNull(t.getText());

	/*
	 * // invalid t.setText(""); binder.setBean(t);
	 * assertFalse(validator.validate(t).isEmpty());
	 * assertFalse(binder.validate().isOk());
	 * 
	 * t.setText(null); binder.setBean(t);
	 * assertTrue(validator.validate(t).isEmpty());
	 * assertTrue(binder.validate().isOk());
	 */
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:33,代码来源:BeanValidationBinderStringTest.java


注:本文中的com.vaadin.ui.TextField.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。