在新的浏览器窗口中打开网格内的 url

发布于 2024-11-04 16:18:02 字数 1331 浏览 3 评论 0原文

我在网格中有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等风来 2024-11-11 16:18:02

您可以使用以下示例,

Executions.getCurrent().sendRedirect("http://www.google.com", "_blank");

或者您可以将 A 组件与 setHref() 方法一起使用,而不是使用 Toolbarbutton 组件。

You can use the following example,

Executions.getCurrent().sendRedirect("http://www.google.com", "_blank");

Or you may use the A component with the setHref() method instead of the Toolbarbutton component.

在巴黎塔顶看东京樱花 2024-11-11 16:18:02

这对我来说效果很好,谢谢!

  UrlObj url = (UrlObj) data;

  Toolbarbutton tb = new Toolbarbutton(url.getUrlApp());
  tb.setHref(url.getUrlApp());
  tb.setTarget("_blank");

  row.getChildren().add(new Label("Some data"));
  row.getChildren().add(tb);

This works fine for me, thanks!

  UrlObj url = (UrlObj) data;

  Toolbarbutton tb = new Toolbarbutton(url.getUrlApp());
  tb.setHref(url.getUrlApp());
  tb.setTarget("_blank");

  row.getChildren().add(new Label("Some data"));
  row.getChildren().add(tb);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文