2012-06-15 1 views
0

Dani의 GWTP 과정을 따라했지만 발표자가 TabLayoutPanel을 사용하는 것은 다루지 않았습니다.GWTP에서 TabLayoutPanel 이벤트를 어떻게 처리 할 수 ​​있습니까?

TabLayoutPanel에 탭이 세 개 있습니다 (각 탭에 VerticalPanel이 있음). 각 탭의 코드가 독립적으로로드되도록 @ProxyCodeSplit을 사용했습니다.

Eclipse에서 GWT의 디자이너에서 OnBeforeSelection에 대한 처리기를 추가하면 코드가 자동으로 내보기에 추가됩니다. 보기는 적절한 발표자를로드 할 수 있습니다.

코드에 적합한 장소로 느껴지지 않습니다. 그렇죠?

TabLayoutPanel 및 코드 분할에서 다른 탭을 어떻게 넘겨 줍니까?

답변

0

나는 이것을 알아 냈다고 생각합니다. TabLayoutPanel와 발표자에

(의이 MainPresenter를 부르 자) :

@ContentSlot public static final Type<RevealContentHandler<?>> SLOT_first = new Type<RevealContentHandler<?>>(); 
@ContentSlot public static final Type<RevealContentHandler<?>> SLOT_second = new Type<RevealContentHandler<?>>(); 

public interface MyView extends View { 
    public void setMainPresenter(MainPresenter presenter); 
    public TabLayoutPanel getTeamsPanel(); 
} 

@Inject PlaceManager placeMananger; 
@Inject FirstPresenter firstPresenter; 
@Inject SecondPresenter secondPresenter; 

@ProxyCodeSplit 
public interface MyProxy extends Proxy<MainPresenter> { 
} 

@Inject 
public MainPresenter(final EventBus eventBus, final MyView view, 
     final MyProxy proxy) { 
    super(eventBus, view, proxy); 
    view.setMainPresenter(this); 
} 

@Override 
protected void revealInParent() { 
    RevealRootContentEvent.fire(this, this); 
} 

public void setTabContents(Integer tab) { 
    if (tab == 0) { 
     placeMananger.revealPlace(new PlaceRequest("first")); 
    } else if (tab == 1) { 
     placeMananger.revealPlace(new PlaceRequest("second")); 
} 

이 그런 다음 MAINVIEW에 로컬 참조를 저장하는 방법 setMainPresenter()를 구현합니다. 보통 setInSlot()를 구현 한 후이 탭 처리기를 추가 :

@UiHandler("mainTabs") 
void onMainTabsBeforeSelection(BeforeSelectionEvent<Integer> event) { 
    mainPresenter.setTabContents(event.getItem()); 
} 

핸들러는 사용자가 탭을 변경 MainPresenter 때마다 호출합니다. setTabContents()는 적절한 "tab"Presenter에 대해 revealInParent()를 호출합니다.

관련 문제