1
上我在完全喪失的類型如何進一步進行:交換鏈接的依賴模型對象
我有面板採用了DropDownChoice和下一個提交按鈕即可。根據DropDownChoice的選定值(獲取OnChangeAjaxBehavior附加到它後獲得的,提交按鈕需要用不同的替換整個面板,或成爲ExternalLink。)
目前,代碼看起來像即:
public class ReportSelectionPanel extends Panel {
protected OptionItem selectedOption ;
public ReportSelectionPanel(String id) {
super(id);
IModel<List<OptionItem>> choices = new AbstractReadOnlyModel() {
// Create a list of options to be displayed in the DropDownChoice
} ;
final IModel<OptionItem> optionModel =
new PropertyModel<OptionItem>(this,"selectedOption") ;
final DropDownChoice<OptionItem> options =
new DropDownChoice("selectChoice",optionModel,choices) ;
// I don't know what the button should be... Plain Button? A Link?
final Component button = ???
options.add(new OnChangeAjaxBehavior() {
protected void onUpdate(AjaxRequestTarget target) {
if (selectedOption.getChild() == null) {
// button becomes an ExternalLink.
// A new window will popup once button is clicked
} else {
// button becomes a Something, and upon clicking,
// this ReportSelectionPanel instance gets replaced by
// an new Panel instance, the type of which is
// selectedOption.getChild()
}
}) ;
我真的不太清楚註釋行應該變成什麼樣達到的效果有什麼建議
感謝
埃裏克
0123?!
這做的伎倆!謝謝! (重載的方法是onSubmit),並且我的組件層次結構有一些小問題,但我認爲現在我的狀態已經變好了! – Eric