@ModelAttribute 與 @MapAttribute
@ModelAttribute 詳解
@Override
public TextInputFactory bindInput(String field, String initValue) {
bind(AttributeController.FIELD_TAG, field);
bind(AttributeController.VALUE_TAG, initValue);
return this;
}使用範例
public class TestModel {
public Color testColor;
public LocalDate testDate;
public LocalTime testTime;
@Override
public String toString() {
return "TestModel{" +
"testColor=" + testColor.toString() +
", testDate=" + testDate.toString() +
", testTime=" + testTime.toString() +
'}';
}
}@ViewDescriptor(
name = "Test GUI",
rows = 2,
patterns = {
"ZZZZZZZZZ",
"ZZZZZZZZA"
},
cancelMove = {'Z', 'A'}
)
public class TestView implements View<Void> {
@Override
public void renderView(Void model, UIContext context) {
ButtonFactory button = context.factory(ButtonFactory.class);
RGBSelectorFactory rgbSelector = context.factory(RGBSelectorFactory.class);
DateSelectorFactory dateSelector = context.factory(DateSelectorFactory.class);
TimeSelectorFactory timeSelector = context.factory(TimeSelectorFactory.class);
context.pattern('Z')
.components(
rgbSelector
.bindInput("testColor", Color.WHITE)
.label("&aColor Select: (shift to move color, click to +/-, middle to input)")
.create(),
dateSelector
.bindInput("testDate", LocalDate.now())
.label("&aDate Select: (shift move unit, click to +/-, middle to input)")
.icon(Material.BEACON)
.create(),
timeSelector
.bindInput("testTime", LocalTime.now())
.label("&aTime Select: (shift move unit, click to +/-, middle to input)")
.icon(Material.CLOCK)
.create()
)
.and()
.pattern('A')
.components(
button.title("&aTest").icon(Material.DIAMOND_BLOCK).create()
);
}
}@MapAttribute 詳解
選填屬性
最后更新于