0

私は4つのタブを持っています。現在のタブへの入力が完了していないため、ユーザーが (window.alert の例を使用して) 別のタブに移動できないようにしたいと考えています。ユーザーがすべてのフィールドへの入力を完了すると、現在のタブ内に (次のタブに移動できるという) テキストが表示されます。そして、彼は下のタブをクリックできるようになります。

BeforeSelectionEvent ハンドラまたは SelectionHandler を使用する必要がありますか?

4

2 に答える 2

1

私は私の質問に答えるためにこのコードを実行しますが、長すぎます

is there a possibility to turn it into a short function ?
 this.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
              public void onBeforeSelection(BeforeSelectionEvent<Integer> event) {
                if (Application.get().getChampsObligatoire().values().contains("Fiche")) {
                    if (event.getItem().intValue() > 0){
                    event.cancel();
                    Window.alert("You must fill all fields before proceeding to the next step.");
                    }

                    }
                if (Application.get().getChampsObligatoire().values().contains("projet")) {
                    if (event.getItem().intValue() > 1){
                    event.cancel();
                    Window.alert("You must fill all fields before proceeding to the next step.");
                    }
                }
                    if (Application.get().getChampsObligatoire().values().contains("cibles")) {
                        if (event.getItem().intValue() > 2){
                        event.cancel();
                        Window.alert("You must fill all fields before proceeding to the next step.");
                        }

                        }

                    if (Application.get().getChampsObligatoire().values().contains("Ressources")) {
                        if (event.getItem().intValue() > 3){
                        event.cancel();
                        Window.alert("You must fill all fields before proceeding to the next step.");
                        }

                        }
                    if (Application.get().getChampsObligatoire().values().contains("Contrôle")) {
                        if (event.getItem().intValue() > 4){
                        event.cancel();
                        Window.alert("You must fill all fields before proceeding to the next step.");
                        }

                        }



              }

            }); 
于 2012-10-08T16:21:25.167 に答える
0

GWT TabPanel の場合:

@Override
public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex)
{
    String currentTabName = widget.getTabHTML(widget.getSelectedTab()); // for reference
    String tabNameYouTryingToSelect = widget.getTabHTML(tabIndex);  // for reference

    // check some external self-written method and return true or false to allow/disallow selection
    if (isCurrentlyActiveTabBuilt()){
        return true;
    } else {
        Window.alert("You must fill all fields before proceeding to the next step.");
        return false;
    }
}
于 2012-10-05T18:31:57.433 に答える