Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

spring converter in initbinder

public class CategoryEditor extends PropertyEditorSupport {

    // Converts a String to a Category (when submitting form)
    @Override
    public void setAsText(String text) {
        Category c = new Category(text);
        this.setValue(c);
    }

    // Converts a Category to a String (when displaying form)
    @Override
    public String getAsText() {
        Category c = (Category) this.getValue();
        return c.getName();
    }

}




public class MyController {

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        binder.registerCustomEditor(Category.class, new CategoryEditor());
    }

    ...

}
Comment

PREVIOUS NEXT
Code Example
Java :: choose image java 
Java :: truncar a 2 decimales java 
Java :: contoh object dalam oop java 
Java :: cannot apply java lang integer android 
Java :: display pop up window overlay permission in redmi android studio 
Java :: java map get value 
Java :: setting up javafx in eclipse 
Java :: scrollbar in textarea java 
Java :: hashtable 
Java :: java importing 
Java :: split each character in a string (java) 
Java :: class syntax in java 
Java :: java indexof not found 
Java :: Calculate weeks from date using java 
Java :: javafx access fxml elements 
Java :: java float precision 
Java :: springboot avoid generated security password: 
Java :: Access HashMap Elements 
Java :: int in string umwandeln 
Java :: ticket sales java program 
Java :: in java write a code that suppose the following input is supplied to the program: 9 Then, the output should be: 12096 (99+999+9999+999) 
Sql :: mysql create user with remote access 
Sql :: GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 
Sql :: sql add column after another 
Sql :: cambiar nombre tabla mysql 
Sql :: too many connections mysql 
Sql :: show table columns mysql command line 
Sql :: mysql update field from one table to another 
Sql :: ubuntu stop mysql 
Sql :: psql filed name alter 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =