我可以使用 JavaScript 触发 IceFaces 操作吗?

发布于 2024-09-24 11:06:24 字数 394 浏览 2 评论 0原文

如果我有一个简单的按钮:

   <ice:panelGroup> 
            <ice:commandButton value="foobar" 
            action="#{fileManager.openNoFlashVisiblePopup}" />
   </ice:panelGroup>

是否可以仅使用 javascript 触发 openNoFlashVisiblePopup 操作?我知道 IceFaces 有一个 JavaScript 桥,但我不知道有什么简单的方法可以做到这一点。

我需要这样做,因为我有一大块 JavaScript 可以检测 Flash,并且我需要显示一个 IceFaces 弹出窗口。

If I have a simple button:

   <ice:panelGroup> 
            <ice:commandButton value="foobar" 
            action="#{fileManager.openNoFlashVisiblePopup}" />
   </ice:panelGroup>

Is it possible to trigger the action openNoFlashVisiblePopup using just javascript? I know that there IceFaces has a JavaScript bridge but I don't know see a simple way to do just this.

i need to do this because I have a chunk of JavaScript that detects Flash and I need to show a IceFaces popup.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

云巢 2024-10-01 11:06:24

一种方法是通过 ID 获取按钮元素并调用其 click() 函数。

document.getElementById('clientId').click();

您只需要给表单和按钮一个固定的id,这样您就可以在Javascript代码中使用生成的HTML ID作为clientId

One way is to get the button element by ID and call its click() function.

document.getElementById('clientId').click();

You only need to give the form and button a fixed id so that you can use the generated HTML ID as clientId in Javascript code.

递刀给你 2024-10-01 11:06:24

我知道我看到这一点有点晚了,但是处理这个问题的正确方法(也许减去过度活跃的错误检查)是:

        // There's a <div> that looks like: <div class="portletfaces-bridge-body" id="A8660">.
    // We'll find it and pull out the value of the ID to build elementId like: A8660:wtfForm:editeventparent
    var div = null; 
    var divCollection = document.getElementsByTagName("div");
    for (var i=0; i<divCollection.length; i++) {
        if(divCollection[i].getAttribute("class") == "portletfaces-bridge-body") {
            div = divCollection[i];
            break;
        } 
    }
    if (div == null){
        alert("could not find div portletfaces-bridge-body.");
        return;
    }

    // Pull the id out of divInnerText.
    var id = div.getAttribute("id");
    if (id == null){
        alert("id was null");
    }

    // prepare initializes fields to null so rendered cannot begin until both itemId and parentId are set.
    var prepare = document.getElementById(id + ":wtfForm:editeventprepare");
    if (prepare == null){
        alert("editeventprepare element was not found.");
        return;
    }
    prepare.click();

I know I'm a little late in seeing this, but the correct way to handle this (minus perhaps the overly exhuberant error checking) is:

        // There's a <div> that looks like: <div class="portletfaces-bridge-body" id="A8660">.
    // We'll find it and pull out the value of the ID to build elementId like: A8660:wtfForm:editeventparent
    var div = null; 
    var divCollection = document.getElementsByTagName("div");
    for (var i=0; i<divCollection.length; i++) {
        if(divCollection[i].getAttribute("class") == "portletfaces-bridge-body") {
            div = divCollection[i];
            break;
        } 
    }
    if (div == null){
        alert("could not find div portletfaces-bridge-body.");
        return;
    }

    // Pull the id out of divInnerText.
    var id = div.getAttribute("id");
    if (id == null){
        alert("id was null");
    }

    // prepare initializes fields to null so rendered cannot begin until both itemId and parentId are set.
    var prepare = document.getElementById(id + ":wtfForm:editeventprepare");
    if (prepare == null){
        alert("editeventprepare element was not found.");
        return;
    }
    prepare.click();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文