@Override
public PropertyEditor getPropertyEditor() {
return new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (text instanceof String) {
try {
entry.setMessage(!text.equals("") ? text : null);
} catch (IOException ex) {
History.LOG.log(Level.WARNING, null, ex);
}
return;
}
throw new java.lang.IllegalArgumentException(text);
}
@Override
public String getAsText() {
return te.getDisplayValue();
}
};
}
java类java.beans.PropertyEditorSupport的实例源码
RevisionNode.java 文件源码
项目:incubator-netbeans
阅读 23
收藏 0
点赞 0
评论 0
PortletRequestDataBinderTests.java 文件源码
项目:spring4-understanding
阅读 35
收藏 0
点赞 0
评论 0
@Test
public void nestedBindWithPropertyEditor() {
PortletRequestDataBinder binder = new PortletRequestDataBinder(bean);
binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(new TestBean(text));
}
});
request.addParameter("spouse", "test");
request.addParameter("spouse.age", "32");
binder.bind(request);
assertNotNull(bean.getSpouse());
assertEquals("test", bean.getSpouse().getName());
assertEquals(32, bean.getSpouse().getAge());
}
DataBinderTests.java 文件源码
项目:spring4-understanding
阅读 26
收藏 0
点赞 0
评论 0
@Test
public void testBindingWithNestedObjectCreation() throws Exception {
TestBean tb = new TestBean();
DataBinder binder = new DataBinder(tb, "person");
binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(new TestBean());
}
});
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("spouse", "someValue");
pvs.add("spouse.name", "test");
binder.bind(pvs);
assertNotNull(tb.getSpouse());
assertEquals("test", tb.getSpouse().getName());
}
DataBinderTests.java 文件源码
项目:spring4-understanding
阅读 35
收藏 0
点赞 0
评论 0
@Test
public void testCustomEditorForPrimitiveProperty() {
TestBean tb = new TestBean();
DataBinder binder = new DataBinder(tb, "tb");
binder.registerCustomEditor(int.class, "age", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(new Integer(99));
}
@Override
public String getAsText() {
return "argh";
}
});
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("age", "");
binder.bind(pvs);
assertEquals("argh", binder.getBindingResult().getFieldValue("age"));
assertEquals(99, tb.getAge());
}
DataBinderTests.java 文件源码
项目:spring4-understanding
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void testEditorForNestedIndexedField() {
IndexedTestBean tb = new IndexedTestBean();
tb.getArray()[0].setNestedIndexedBean(new IndexedTestBean());
tb.getArray()[1].setNestedIndexedBean(new IndexedTestBean());
DataBinder binder = new DataBinder(tb, "tb");
binder.registerCustomEditor(String.class, "array.nestedIndexedBean.list.name", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue("list" + text);
}
@Override
public String getAsText() {
return ((String) getValue()).substring(4);
}
});
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("array[0].nestedIndexedBean.list[0].name", "test1");
pvs.add("array[1].nestedIndexedBean.list[1].name", "test2");
binder.bind(pvs);
assertEquals("listtest1", ((TestBean)tb.getArray()[0].getNestedIndexedBean().getList().get(0)).getName());
assertEquals("listtest2", ((TestBean)tb.getArray()[1].getNestedIndexedBean().getList().get(1)).getName());
assertEquals("test1", binder.getBindingResult().getFieldValue("array[0].nestedIndexedBean.list[0].name"));
assertEquals("test2", binder.getBindingResult().getFieldValue("array[1].nestedIndexedBean.list[1].name"));
}
DataBinderTests.java 文件源码
项目:spring4-understanding
阅读 24
收藏 0
点赞 0
评论 0
@Test
public void testSpecificEditorForNestedIndexedField() {
IndexedTestBean tb = new IndexedTestBean();
tb.getArray()[0].setNestedIndexedBean(new IndexedTestBean());
tb.getArray()[1].setNestedIndexedBean(new IndexedTestBean());
DataBinder binder = new DataBinder(tb, "tb");
binder.registerCustomEditor(String.class, "array[0].nestedIndexedBean.list.name", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue("list" + text);
}
@Override
public String getAsText() {
return ((String) getValue()).substring(4);
}
});
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("array[0].nestedIndexedBean.list[0].name", "test1");
pvs.add("array[1].nestedIndexedBean.list[1].name", "test2");
binder.bind(pvs);
assertEquals("listtest1", ((TestBean)tb.getArray()[0].getNestedIndexedBean().getList().get(0)).getName());
assertEquals("test2", ((TestBean)tb.getArray()[1].getNestedIndexedBean().getList().get(1)).getName());
assertEquals("test1", binder.getBindingResult().getFieldValue("array[0].nestedIndexedBean.list[0].name"));
assertEquals("test2", binder.getBindingResult().getFieldValue("array[1].nestedIndexedBean.list[1].name"));
}
DataBinderTests.java 文件源码
项目:spring4-understanding
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void testInnerSpecificEditorForNestedIndexedField() {
IndexedTestBean tb = new IndexedTestBean();
tb.getArray()[0].setNestedIndexedBean(new IndexedTestBean());
tb.getArray()[1].setNestedIndexedBean(new IndexedTestBean());
DataBinder binder = new DataBinder(tb, "tb");
binder.registerCustomEditor(String.class, "array.nestedIndexedBean.list[0].name", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue("list" + text);
}
@Override
public String getAsText() {
return ((String) getValue()).substring(4);
}
});
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("array[0].nestedIndexedBean.list[0].name", "test1");
pvs.add("array[1].nestedIndexedBean.list[1].name", "test2");
binder.bind(pvs);
assertEquals("listtest1", ((TestBean)tb.getArray()[0].getNestedIndexedBean().getList().get(0)).getName());
assertEquals("test2", ((TestBean)tb.getArray()[1].getNestedIndexedBean().getList().get(1)).getName());
assertEquals("test1", binder.getBindingResult().getFieldValue("array[0].nestedIndexedBean.list[0].name"));
assertEquals("test2", binder.getBindingResult().getFieldValue("array[1].nestedIndexedBean.list[1].name"));
}
DataBinderTests.java 文件源码
项目:spring4-understanding
阅读 24
收藏 0
点赞 0
评论 0
@Test
public void testBindToStringArrayWithArrayEditor() {
TestBean tb = new TestBean();
DataBinder binder = new DataBinder(tb, "tb");
binder.registerCustomEditor(String[].class, "stringArray", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(StringUtils.delimitedListToStringArray(text, "-"));
}
});
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("stringArray", "a1-b2");
binder.bind(pvs);
assertTrue(!binder.getBindingResult().hasErrors());
assertEquals(2, tb.getStringArray().length);
assertEquals("a1", tb.getStringArray()[0]);
assertEquals("b2", tb.getStringArray()[1]);
}
DataBinderTests.java 文件源码
项目:spring4-understanding
阅读 55
收藏 0
点赞 0
评论 0
@Test
public void testBindToStringArrayWithComponentEditor() {
TestBean tb = new TestBean();
DataBinder binder = new DataBinder(tb, "tb");
binder.registerCustomEditor(String.class, "stringArray", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue("X" + text);
}
});
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("stringArray", new String[] {"a1", "b2"});
binder.bind(pvs);
assertTrue(!binder.getBindingResult().hasErrors());
assertEquals(2, tb.getStringArray().length);
assertEquals("Xa1", tb.getStringArray()[0]);
assertEquals("Xb2", tb.getStringArray()[1]);
}
SelectTagTests.java 文件源码
项目:spring4-understanding
阅读 21
收藏 0
点赞 0
评论 0
@Test
public void withListAndTransformTagAndEditor() throws Exception {
this.tag.setPath("realCountry");
this.tag.setItems(Country.getCountries());
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(getTestBean(), "testBean");
bindingResult.getPropertyAccessor().registerCustomEditor(Country.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(Country.getCountryWithIsoCode(text));
}
@Override
public String getAsText() {
return ((Country) getValue()).getName();
}
});
getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
this.tag.doStartTag();
TransformTag transformTag = new TransformTag();
transformTag.setValue(Country.getCountries().get(0));
transformTag.setVar("key");
transformTag.setParent(this.tag);
transformTag.setPageContext(getPageContext());
transformTag.doStartTag();
assertEquals("Austria", getPageContext().findAttribute("key"));
}
SelectTagTests.java 文件源码
项目:spring4-understanding
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void withListAndEditor() throws Exception {
this.tag.setPath("realCountry");
this.tag.setItems(Country.getCountries());
this.tag.setItemValue("isoCode");
this.tag.setItemLabel("name");
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(getTestBean(), "testBean");
bindingResult.getPropertyAccessor().registerCustomEditor(Country.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(Country.getCountryWithIsoCode(text));
}
@Override
public String getAsText() {
return ((Country) getValue()).getName();
}
});
getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
this.tag.doStartTag();
String output = getOutput();
assertTrue(output.startsWith("<select "));
assertTrue(output.endsWith("</select>"));
assertTrue(output.contains("option value=\"AT\" selected=\"selected\">Austria"));
}
SelectTagTests.java 文件源码
项目:spring4-understanding
阅读 29
收藏 0
点赞 0
评论 0
@Test
public void nestedPathWithListAndEditor() throws Exception {
this.tag.setPath("bean.realCountry");
this.tag.setItems(Country.getCountries());
this.tag.setItemValue("isoCode");
this.tag.setItemLabel("name");
TestBeanWrapper testBean = new TestBeanWrapper();
testBean.setBean(getTestBean());
BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(testBean , "testBean");
bindingResult.getPropertyAccessor().registerCustomEditor(Country.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(Country.getCountryWithIsoCode(text));
}
@Override
public String getAsText() {
return ((Country) getValue()).getName();
}
});
getPageContext().getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "testBean", bindingResult);
this.tag.doStartTag();
String output = getOutput();
assertTrue(output.startsWith("<select "));
assertTrue(output.endsWith("</select>"));
assertTrue(output.contains("option value=\"AT\" selected=\"selected\">Austria"));
}
WebRequestDataBinderTests.java 文件源码
项目:spring4-understanding
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void testBindingWithNestedObjectCreation() throws Exception {
TestBean tb = new TestBean();
WebRequestDataBinder binder = new WebRequestDataBinder(tb, "person");
binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(new TestBean());
}
});
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("spouse", "someValue");
request.addParameter("spouse.name", "test");
binder.bind(new ServletWebRequest(request));
assertNotNull(tb.getSpouse());
assertEquals("test", tb.getSpouse().getName());
}
ServletRequestDataBinderTests.java 文件源码
项目:spring4-understanding
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void testBindingWithNestedObjectCreation() throws Exception {
TestBean tb = new TestBean();
ServletRequestDataBinder binder = new ServletRequestDataBinder(tb, "person");
binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(new TestBean());
}
});
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("spouse", "someValue");
request.addParameter("spouse.name", "test");
binder.bind(request);
assertNotNull(tb.getSpouse());
assertEquals("test", tb.getSpouse().getName());
}
ServletRequestDataBinderTests.java 文件源码
项目:spring4-understanding
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void testBindingWithNestedObjectCreationAndWrongOrder() throws Exception {
TestBean tb = new TestBean();
ServletRequestDataBinder binder = new ServletRequestDataBinder(tb, "person");
binder.registerCustomEditor(ITestBean.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(new TestBean());
}
});
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("spouse.name", "test");
request.addParameter("spouse", "someValue");
binder.bind(request);
assertNotNull(tb.getSpouse());
assertEquals("test", tb.getSpouse().getName());
}
CustomEditorTests.java 文件源码
项目:spring4-understanding
阅读 19
收藏 0
点赞 0
评论 0
@Test
public void testCustomEditorForSingleProperty() {
TestBean tb = new TestBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
bw.registerCustomEditor(String.class, "name", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue("prefix" + text);
}
});
bw.setPropertyValue("name", "value");
bw.setPropertyValue("touchy", "value");
assertEquals("prefixvalue", bw.getPropertyValue("name"));
assertEquals("prefixvalue", tb.getName());
assertEquals("value", bw.getPropertyValue("touchy"));
assertEquals("value", tb.getTouchy());
}
CustomEditorTests.java 文件源码
项目:spring4-understanding
阅读 18
收藏 0
点赞 0
评论 0
@Test
public void testCustomEditorForAllStringProperties() {
TestBean tb = new TestBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue("prefix" + text);
}
});
bw.setPropertyValue("name", "value");
bw.setPropertyValue("touchy", "value");
assertEquals("prefixvalue", bw.getPropertyValue("name"));
assertEquals("prefixvalue", tb.getName());
assertEquals("prefixvalue", bw.getPropertyValue("touchy"));
assertEquals("prefixvalue", tb.getTouchy());
}
CustomEditorTests.java 文件源码
项目:spring4-understanding
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void testCustomEditorForSingleNestedProperty() {
TestBean tb = new TestBean();
tb.setSpouse(new TestBean());
BeanWrapper bw = new BeanWrapperImpl(tb);
bw.registerCustomEditor(String.class, "spouse.name", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue("prefix" + text);
}
});
bw.setPropertyValue("spouse.name", "value");
bw.setPropertyValue("touchy", "value");
assertEquals("prefixvalue", bw.getPropertyValue("spouse.name"));
assertEquals("prefixvalue", tb.getSpouse().getName());
assertEquals("value", bw.getPropertyValue("touchy"));
assertEquals("value", tb.getTouchy());
}
CustomEditorTests.java 文件源码
项目:spring4-understanding
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void testCustomEditorForAllNestedStringProperties() {
TestBean tb = new TestBean();
tb.setSpouse(new TestBean());
BeanWrapper bw = new BeanWrapperImpl(tb);
bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue("prefix" + text);
}
});
bw.setPropertyValue("spouse.name", "value");
bw.setPropertyValue("touchy", "value");
assertEquals("prefixvalue", bw.getPropertyValue("spouse.name"));
assertEquals("prefixvalue", tb.getSpouse().getName());
assertEquals("prefixvalue", bw.getPropertyValue("touchy"));
assertEquals("prefixvalue", tb.getTouchy());
}
CustomEditorTests.java 文件源码
项目:spring4-understanding
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void testIndexedPropertiesWithListPropertyEditor() {
IndexedTestBean bean = new IndexedTestBean();
BeanWrapper bw = new BeanWrapperImpl(bean);
bw.registerCustomEditor(List.class, "list", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
List<TestBean> result = new ArrayList<TestBean>();
result.add(new TestBean("list" + text, 99));
setValue(result);
}
});
bw.setPropertyValue("list", "1");
assertEquals("list1", ((TestBean) bean.getList().get(0)).getName());
bw.setPropertyValue("list[0]", "test");
assertEquals("test", bean.getList().get(0));
}
AbstractPropertyAccessorTests.java 文件源码
项目:spring4-understanding
阅读 23
收藏 0
点赞 0
评论 0
@Test
public void setStringPropertyWithCustomEditor() throws Exception {
TestBean target = new TestBean();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.registerCustomEditor(String.class, "name", new PropertyEditorSupport() {
@Override
public void setValue(Object value) {
if (value instanceof String[]) {
setValue(StringUtils.arrayToDelimitedString(((String[]) value), "-"));
}
else {
super.setValue(value != null ? value : "");
}
}
});
accessor.setPropertyValue("name", new String[] {});
assertEquals("", target.getName());
accessor.setPropertyValue("name", new String[] {"a1", "b2"});
assertEquals("a1-b2", target.getName());
accessor.setPropertyValue("name", null);
assertEquals("", target.getName());
}
AbstractPropertyAccessorTests.java 文件源码
项目:spring4-understanding
阅读 25
收藏 0
点赞 0
评论 0
@Test
public void setPrimitiveArrayPropertyLargeMatchingWithSpecificEditor() {
PrimitiveArrayBean target = new PrimitiveArrayBean();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.registerCustomEditor(int.class, "array", new PropertyEditorSupport() {
@Override
public void setValue(Object value) {
if (value instanceof Integer) {
super.setValue(new Integer((Integer) value + 1));
}
}
});
int[] input = new int[1024];
accessor.setPropertyValue("array", input);
assertEquals(1024, target.getArray().length);
assertEquals(1, target.getArray()[0]);
assertEquals(1, target.getArray()[1]);
}
AbstractPropertyAccessorTests.java 文件源码
项目:spring4-understanding
阅读 24
收藏 0
点赞 0
评论 0
@Test
public void setPrimitiveArrayPropertyLargeMatchingWithIndexSpecificEditor() {
PrimitiveArrayBean target = new PrimitiveArrayBean();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.registerCustomEditor(int.class, "array[1]", new PropertyEditorSupport() {
@Override
public void setValue(Object value) {
if (value instanceof Integer) {
super.setValue(new Integer((Integer) value + 1));
}
}
});
int[] input = new int[1024];
accessor.setPropertyValue("array", input);
assertEquals(1024, target.getArray().length);
assertEquals(0, target.getArray()[0]);
assertEquals(1, target.getArray()[1]);
}
AbstractPropertyAccessorTests.java 文件源码
项目:spring4-understanding
阅读 19
收藏 0
点赞 0
评论 0
@Test
public void setMapPropertyWithUnmodifiableMap() {
IndexedTestBean target = new IndexedTestBean();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (!StringUtils.hasLength(text)) {
throw new IllegalArgumentException();
}
setValue(new TestBean(text));
}
});
Map<Integer, String> inputMap = new HashMap<Integer, String>();
inputMap.put(1, "rod");
inputMap.put(2, "rob");
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("map", Collections.unmodifiableMap(inputMap));
accessor.setPropertyValues(pvs);
assertEquals("rod", ((TestBean) target.getMap().get(1)).getName());
assertEquals("rob", ((TestBean) target.getMap().get(2)).getName());
}
AbstractPropertyAccessorTests.java 文件源码
项目:spring4-understanding
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void setMapPropertyWithCustomUnmodifiableMap() {
IndexedTestBean target = new IndexedTestBean();
AbstractPropertyAccessor accessor = createAccessor(target);
accessor.registerCustomEditor(TestBean.class, "map", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if (!StringUtils.hasLength(text)) {
throw new IllegalArgumentException();
}
setValue(new TestBean(text));
}
});
Map<Object, Object> inputMap = new HashMap<Object, Object>();
inputMap.put(1, "rod");
inputMap.put(2, "rob");
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("map", new ReadOnlyMap<>(inputMap));
accessor.setPropertyValues(pvs);
assertEquals("rod", ((TestBean) target.getMap().get(1)).getName());
assertEquals("rob", ((TestBean) target.getMap().get(2)).getName());
}
BaseControllerAdvice.java 文件源码
项目:javabase
阅读 20
收藏 0
点赞 0
评论 0
/**
* 初始化数据绑定
* 1. 将所有传递进来的String进行HTML编码,防止XSS攻击
* 2. 将字段中Date类型转换为String类型
*/
@InitBinder
protected void initBinder(WebDataBinder binder) {
// String类型转换,将所有传递进来的String进行HTML编码,防止XSS攻击
binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
public String getAsText() {
Object value = getValue();
return value != null ? value.toString() : "";
}
public void setAsText(String text) {
setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim()));
}
});
/*
* // Date 类型转换 binder.registerCustomEditor(Date.class, new PropertyEditorSupport() { public void
* setAsText(String text) { setValue(DateUtils.parseDate(text)); } });
*/
}
SuperController.java 文件源码
项目:nbone
阅读 21
收藏 0
点赞 0
评论 0
/**
* 初始化数据绑定
* 1. 将所有传递进来的String进行HTML编码,防止XSS攻击
* 2. 将字段中Date类型转换为String类型
*/
@InitBinder
protected void initBinder(WebDataBinder binder) {
// String类型转换,将所有传递进来的String进行HTML编码,防止XSS攻击
/* binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) {
setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim()));
}
@Override
public String getAsText() {
Object value = getValue();
return value != null ? value.toString() : "";
}
});*/
// Date 类型转换
binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
@Override
public void setAsText(String text) {
setValue(DateFPUtils.parseDateMultiplePattern(text));
}
});
}
UserDataProperty.java 文件源码
项目:sdk
阅读 19
收藏 0
点赞 0
评论 0
@Override
public PropertyEditor getPropertyEditor() {
return new PropertyEditorSupport(spatial.getUserData(name)) {
@Override
public boolean supportsCustomEditor() {
return true;
}
@Override
public Component getCustomEditor() {
return new UserDataDialog(new JFrame(), true, node, name);
}
};
// return new AnimationPropertyEditor(control);
}
BaseController.java 文件源码
项目:plagueForGradle
阅读 23
收藏 0
点赞 0
评论 0
/**
* 初始化参数绑定
* 将所有传递进来的String进行HTML编码,防止XSS攻击
*/
@InitBinder
protected void initBinder(WebDataBinder binder){
// String类型转换,将所有传递进来的String进行HTML编码,防止XSS攻击
binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
@Override
public String getAsText(){
Object value = getValue();
return value!=null?value.toString():"";
}
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim()));
}
});
}
EditorDialog.java 文件源码
项目:jdatechooser
阅读 36
收藏 0
点赞 0
评论 0
public EditorDialog(Frame owner, PropertyEditorSupport editor) {
super(owner, true);
propertyEditor = getClonedEditor(editor);
setCanceled(false);
Container pane = getContentPane();
pane.setLayout(new BorderLayout());
OnClick onClick = new OnClick();
bOK = new JButton(getEditorLocaleString("OK"));
bOK.addActionListener(onClick);
bCancel = new JButton(getEditorLocaleString("Cancel"));
bCancel.addActionListener(onClick);
bPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
bPane.add(bOK);
bPane.add(bCancel);
pane.add(bPane, BorderLayout.SOUTH);
tryToCreateEditorPanel(false);
pack();
}