Java Code Examples for org.springframework.web.servlet.tags.TransformTag#setValue()
The following examples show how to use
org.springframework.web.servlet.tags.TransformTag#setValue() .
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: SelectTagTests.java From spring-analysis-note with MIT License | 6 votes |
@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")); }
Example 2
Source File: SelectTagTests.java From java-technology-stack with MIT License | 6 votes |
@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")); }
Example 3
Source File: SelectTagTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@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")); }
Example 4
Source File: SelectTagTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void withListAndTransformTag() throws Exception { this.tag.setPath("country"); this.tag.setItems(Country.getCountries()); assertList(true); TransformTag transformTag = new TransformTag(); transformTag.setValue(Country.getCountries().get(0)); transformTag.setVar("key"); transformTag.setParent(this.tag); transformTag.setPageContext(getPageContext()); transformTag.doStartTag(); assertEquals("Austria(AT)", getPageContext().findAttribute("key")); }
Example 5
Source File: SelectTagTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void withListAndTransformTag() throws Exception { this.tag.setPath("country"); this.tag.setItems(Country.getCountries()); assertList(true); TransformTag transformTag = new TransformTag(); transformTag.setValue(Country.getCountries().get(0)); transformTag.setVar("key"); transformTag.setParent(this.tag); transformTag.setPageContext(getPageContext()); transformTag.doStartTag(); assertEquals("Austria(AT)", getPageContext().findAttribute("key")); }
Example 6
Source File: SelectTagTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void withListAndTransformTag() throws Exception { this.tag.setPath("country"); this.tag.setItems(Country.getCountries()); assertList(true); TransformTag transformTag = new TransformTag(); transformTag.setValue(Country.getCountries().get(0)); transformTag.setVar("key"); transformTag.setParent(this.tag); transformTag.setPageContext(getPageContext()); transformTag.doStartTag(); assertEquals("Austria(AT)", getPageContext().findAttribute("key")); }