crud module: add a @InputType annotation to define the html input type of the field
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
play framework |
New
|
Undecided
|
Arthur Embleton |
Bug Description
step 1. define @InputType:::::
import jxp.enums.
import java.lang.
import java.lang.
import java.lang.
import java.lang.
@Retention(
@Target(
public @interface InputType {
/** html input type */
Component component() default Component.text;
/** html input field size */
int size() default 20;
}
step 2. define Enum Component::::
public enum Component {
text, password, textarea, richeditor, checkbox, number, date, datetime, file, select, spinner, slider, rating, colorpicker
}
step 3. use @InputType in entities:::
@Entity
public class User extends Model {
@InputType(
public String name;
@InputType(
public String password;
@InputType(
public String profile;
@InputType(
public Date birthday;
}
step 4. use with CRUD and controllers:::
just add these lines to CRUD -> ObjectField::
....
/** use to check if the field is unique */
public boolean unique;
public ObjectField(Field field) {
......
if (field.
type = field.getAnnota
}
if (field.
unique = field.getAnnota
}
name = field.getName();
}
.....
Then, we can define all the input types. and it will not limit to JPA and Play's annotations. and we can add a 'exists' to crud to check if the field is unique (by ajax or validation before save).
I will implement this as part of the richCrud branch that I am working on: https:/ /code.launchpad .net/~aembleton /play/richCrud