gpt4 book ai didi

java - GWT - 片段中的参数

转载 作者:行者123 更新时间:2023-11-30 09:54:27 24 4
gpt4 key购买 nike

这是我的历史值更改事件处理程序:

  public void onValueChange(ValueChangeEvent<String> event) {
String token = event.getValue();

if (token != null) {

if (token.equals("!list")) {
GWT.runAsync(new RunAsyncCallback() {

public void onFailure(Throwable caught) {
}

public void onSuccess() {
presenter = new ContactsPresenter(rpcService, eventBus, new ContactsView());
presenter.go(container);
}
});
}
else if (token.equals("!add")) {
GWT.runAsync(new RunAsyncCallback() {

public void onFailure(Throwable caught) {
}

public void onSuccess() {
presenter = new EditContactPresenter(rpcService, eventBus, new EditContactView());
presenter.go(container);
}
});
}
else if (token.equals("!edit")) {
GWT.runAsync(new RunAsyncCallback() {

public void onFailure(Throwable caught) {
}

public void onSuccess() {
presenter = new EditContactPresenter(rpcService, eventBus, new EditContactView());
presenter.go(container);
}
});
}

}

如您所见,转到 www.domain.com/#edit 会加载编辑 View 。但是,我将如何在片段中指定参数,例如一个 id,并将其传递给 Edit Contacts Presenter?

www.domain.com/#edit/1

最佳答案

您通过 event.getValue() 获取的 token 只是一个字符串 - 因此您可以使用 token.split("/") 获取所有片段并然后根据,例如,第一个(如果我们得到“编辑”,那么我们应该期待下一个数字,等等)。

关于java - GWT - 片段中的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3255353/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com