GWT 탭 패널이 있으며 특정 이벤트 (예 : 버튼 클릭)가 다른 탭에서 발생하면 하나의 탭을 다시로드하려고합니다. 그렇게 할 수있는 방법이 있습니까? 탭을 선택하면 일부 코드 (예 : 탭에 새 요소 추가)가 실행될 수도 있습니다. 도움이 될 것입니다. 이미 잠시 붙어 있습니다.GWT : 탭 패널에 단일 탭 다시로드
더 구체적인 질문을하기 위해 아래에 몇 가지 코드를 제공합니다.
화면에 정리 된 코드가 있습니다. 탭 패널을 시작하는 홈 스크린이 있습니다. 그리고 각 탭의 시작을위한 별도의 화면이 있습니다.
홈 화면에 대한 간단한 코드 : 탭 화면
public class HomeScreen extends Composite{
public HomeScreen() {
TabPanel tabPanel = new TabPanel();
FlowPanel flowpanel;
flowpanel = new FlowPanel();
ProfileTabScreen profileTabScreen = new ProfileTabScreen();
flowpanel.add(profileTabScreen);
tabPanel.add(flowpanel, "Profile");
flowpanel = new FlowPanel();
GroupsTabScreen groupsTabScreen = new GroupsTabScreen();
flowpanel.add(groupsTabScreen);
tabPanel.add(flowpanel, "Groups");
initWidget(tabPanel);
}
}
코드 내가 다시로드 시작하려는 : 다시로드 할 수있는 탭 화면
private VerticalPanel groupPanel = new VerticalPanel();
private Button newGroupButton = new Button("New group");
public GroupsTabScreen() {
newGroupButton.addClickHandler(new ClickHandler(){
public void onClick(ClickEvent event) {
createNewGroup();
}
});
groupPanel.add(newGroupButton);
initWidget(groupPanel);
}
코드 :
private VerticalPanel profilePanel = new VerticalPanel();
private Label label = new Label("No groups yet.");
public ProfileTabScreen() {
profilePanel.add(label);
initWidget(profilePanel);
}
은 그래서 난 그냥 WHI profileTab에서 라벨의 텍스트를 (변경하려는 가정 해 봅시다 실제로 ListBox 및 기타 요소), newGroupButton을 groupTab에서 클릭하면됩니다.
내가 말했듯이, 매번 프로필 탭을 다시로드하는 것이 허용 될 수도 있습니다.
탭 패널에 클릭 리스너를 추가하는 방법과 탭 패널에서 탭의 요소에 액세스하는 방법을 잘 모르겠습니다. 좀 더 구체적인 질문을하기 위해 프로그램의 간단한 코드를 추가했습니다. – april
나는 내 편집도 :-) – Corsair
답장을 보내 주셔서 감사합니다. getters와 setter를 사용하기 전에 요소를 정의하는 아이디어는 매우 유용했습니다. 그러나 나는 당신이 제안한 예제로 작동하도록 할 수 없었다 : profileTabScreenPanel.getLabel(). setText ("New Text"); 다른 한편으로는 다음과 같이 작업했습니다 : HomeScreen.getProfileTabScreen(). getLabel(). setText ("some text"); HomeScreen 클래스에 하나와 ProfileTabScreen 클래스에 하나씩 두 개의 getter 메서드를 추가했습니다. – april