在新的浏览器窗口中打开网格内的 url
我在网格中有一个 url 列表,我需要当用户单击 url 时,打开一个具有相同 url 的新浏览器窗口,
我读了一些线程,但就我而言,我相信我的情况有点不同。在我的控制器中 我正在使用以下代码
UrlListCollection.generateListUrl();
dataGrid.setRowRenderer(new RowRenderer() {
public void render(Row row, Object data) throws Exception {
UrlObj url = (UrlObj) data;
row.getChildren().add(new Label("Some data"));
row.getChildren().add(new Toolbarbutton(url.getUrlApp())); // url.getUrlApp() will be return a link like http://www.google.com
}
});
在我看来(zul)我有
<grid id="dataGrid" width="100%">
<columns>
<column label="Some Data" sort="auto(FIELD_NAME)" width="200px" />
<column label="URL LINK" sort="auto(URL)" width="630px" />
</columns>
</grid>
但是在java中设置事件组件的常见方法可以是:
Toolbarbutton button = new Toolbarbutton(url.getUrlApp()));
button.addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(evt) {
// what I put here to open a Link in another web browser window ????
// and I need to be able to open every object value retrieved by url.getUrlApp() ???
}
});
我现在不知道让我的代码工作需要什么..对我来说将事件应用于使用 RowRenderer 方法的网格内的工具栏按钮很奇怪。我自己看不到解决方案。
I have a list of urls in a grid, And I need that when a user click in a url a new browser windows open with the same url
I read some threads but in my case I believe my situation is a little different. In my controller
I'm using the following code
UrlListCollection.generateListUrl();
dataGrid.setRowRenderer(new RowRenderer() {
public void render(Row row, Object data) throws Exception {
UrlObj url = (UrlObj) data;
row.getChildren().add(new Label("Some data"));
row.getChildren().add(new Toolbarbutton(url.getUrlApp())); // url.getUrlApp() will be return a link like http://www.google.com
}
});
In my view(zul) I have
<grid id="dataGrid" width="100%">
<columns>
<column label="Some Data" sort="auto(FIELD_NAME)" width="200px" />
<column label="URL LINK" sort="auto(URL)" width="630px" />
</columns>
</grid>
But the common way to set an event an component in java can be:
Toolbarbutton button = new Toolbarbutton(url.getUrlApp()));
button.addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(evt) {
// what I put here to open a Link in another web browser window ????
// and I need to be able to open every object value retrieved by url.getUrlApp() ???
}
});
I don't now what is necessary to make my code works..for me the way to apply a Event to toolbar button inside a grid that use RowRenderer method is strange. I can't see a solution by myself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下示例,
或者您可以将
A
组件与setHref()
方法一起使用,而不是使用Toolbarbutton
组件。You can use the following example,
Or you may use the
A
component with thesetHref()
method instead of theToolbarbutton
component.这对我来说效果很好,谢谢!
This works fine for me, thanks!