Richfaces 组件控制切换弹出窗口

发布于 2025-01-03 15:19:54 字数 843 浏览 2 评论 0原文

我希望单个控件显示 rich:popupPanel (如果它不可见),并隐藏它(如果它已经可见)。

通过教程和代码示例,我想出了:

<h:outputLink value="#" id="loginLink">Login
    <rich:componentControl event="click"  operation="show" target="loginPane" >
        <a4j:param name="event" value="event" noEscape="true" />
        ... more params for positioning ...
    </rich:componentControl>
</h:outputLink>

<rich:popupPanel id="loginPane" autosized="true" modal="false" moveable="false" resizeable="false" followByScroll="false" onshow="#{rich:element('userName')}.focus()" >
    <h:form>
   ...
    </h:form>
</rich:popupPanel>

它很好地显示了我的 popupPanel 和后续表单。我只是无法识别一种方法来重载该outputLink的componentControl以隐藏和显示。当然,“toggle”不是一个关键字 - 那太简单了:) 我对 JSF 和 javascript 还很陌生,并且在今天的大部分时间里一直在尝试各种事情。谁能推荐一些东西让我朝着正确的方向前进?

I'd like for a single control to show a rich:popupPanel if it isn't visible, and hide it if it's already visible.

Following through the tutorials and code examples, I've come up with:

<h:outputLink value="#" id="loginLink">Login
    <rich:componentControl event="click"  operation="show" target="loginPane" >
        <a4j:param name="event" value="event" noEscape="true" />
        ... more params for positioning ...
    </rich:componentControl>
</h:outputLink>

<rich:popupPanel id="loginPane" autosized="true" modal="false" moveable="false" resizeable="false" followByScroll="false" onshow="#{rich:element('userName')}.focus()" >
    <h:form>
   ...
    </h:form>
</rich:popupPanel>

Which shows my popupPanel and subsequent form well. I just can't recognize a way to overload that outputLink's componentControl to hide as well as show. Naturally "toggle" isn't a keyword - that would be too easy :) I'm pretty new with JSF and javascript, and have been trying various things for the better part of today. Can anyone recommend something to get me in the right direction?

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

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

发布评论

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

评论(3

江心雾 2025-01-10 15:19:54

对我来说,以下解决方案有效,而confirmPanel是弹出窗口中包含更新数据的面板。

<rich:column>
    <a4j:commandButton value="Delete" render="confirmPanel"
        oncomplete="#{rich:component('confirmPane')}.show()"
        ajaxSingle="true">
        <a4j:param value="#{record.id}" assignTo="#{showActivitiesAsTableView.selectedActivityId}" />
    </a4j:commandButton>
</rich:column>

For me the following solution worked, while confirmPanel is the panel in the popup containing the updated data.

<rich:column>
    <a4j:commandButton value="Delete" render="confirmPanel"
        oncomplete="#{rich:component('confirmPane')}.show()"
        ajaxSingle="true">
        <a4j:param value="#{record.id}" assignTo="#{showActivitiesAsTableView.selectedActivityId}" />
    </a4j:commandButton>
</rich:column>
染年凉城似染瑾 2025-01-10 15:19:54

最后,我最终选择了懒惰的路线:

我内联编辑了页面的 css,以采用 rf-p-shade 样式而不影响 alpha,并创建了一个 onmaskclick 事件来关闭弹出窗口。我无法让它用 javascript 或 jsf 符号复制“切换”之类的行为。

In the end, I ended up just choosing the lazy route:

I edited the css of the page inline to take the rf-p-shade style not effect alpha and made an onmaskclick event to close the popup. I could not get it to replicate a "Toggle" like behavior with javascript or jsf notations.

小草泠泠 2025-01-10 15:19:54

我刚刚偶然发现了这一点。希望经过这么长时间,有人会发现我相对简单的解决方案很有用:

<h:form id="myForm">

  <h:outputScript>
    var popupVisible = false;

    function toggleComponent(component, currentVisibility) {
      if (!currentVisibility) {
        component.show();
      } else {
        component.hide();
      }
    }
  </h:outputScript>

  <rich:popupPanel id="myPopup" domElementAttachment="form" modal="false"
                   onshow="popupVisible = true;"
                   onhide="popupVisible = false;">
    <!-- popup content here -->
  </rich:popupPanel>

  <a4j:commandLink onclick="toggleComponent( #{rich:component('myPopup')}, popupVisible );">
    <h:graphicImage value="/images/some_fancy_icon.jpg" />
  </a4j:commandLink>

</h:form>

请注意:它仅适用于非模式面板。

您甚至可以有多个弹出窗口,并且在一个弹出窗口的 onshow() 上,您可以关闭所有其他弹出窗口。当然,每个人都需要一个单独的 ...Visible 变量。

I've just stumbled on this. Hopefully, someone will find my relatively simple solution useful after such a long time:

<h:form id="myForm">

  <h:outputScript>
    var popupVisible = false;

    function toggleComponent(component, currentVisibility) {
      if (!currentVisibility) {
        component.show();
      } else {
        component.hide();
      }
    }
  </h:outputScript>

  <rich:popupPanel id="myPopup" domElementAttachment="form" modal="false"
                   onshow="popupVisible = true;"
                   onhide="popupVisible = false;">
    <!-- popup content here -->
  </rich:popupPanel>

  <a4j:commandLink onclick="toggleComponent( #{rich:component('myPopup')}, popupVisible );">
    <h:graphicImage value="/images/some_fancy_icon.jpg" />
  </a4j:commandLink>

</h:form>

Please note: it only works with a non-modal panel.

You can even have multiple popups, and on onshow() of one popup, you can close all the others. Of course, you need a separate ...Visible variable for each of them.

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