【问题标题】:rich:panel set text and X(Close) in header丰富:面板在标题中设置文本和 X(关闭)
【发布时间】:2012-05-03 19:20:58
【问题描述】:

我正在尝试在rich:panel 的标题中设置一个文本AND X(关闭)标签,但我一次只能设置一个。

示例:

http://docs.jboss.org/richfaces/latest_4_0_X/Component_Reference/en-US/html/images/figu-Component_Reference-richpopupPanel-Header_and_controls.png

但是这个例子是用rich:popupPanel 运行的,我需要在rich:panel 组件中实现。

我试过了:

<rich:panel>
      <f:facet name="header">
          <h:outputText value="Text Header here" />
      </f:facet>
   <f:facet name="controls">
       <h:outputLink value="#" onclick="#{rich:component('component')}.hide()return false;">
          <h:outputText value="X" />
       </h:outputLink>
   </f:facet> 
</rich:panel>

与:

<rich:panel>
   <f:facet name="header">
           <h:outputText value="Text Header here" />
   </f:facet>
       <f:facet name="controls">
           <h:outputLink value="#" onclick="#{rich:component('component')}.hide(); return false;">
               X
           </h:outputLink>
       </f:facet>
</rich:panel>

还有其他的,但都没有工作

谢谢。

【问题讨论】:

  • 这不是rich:panel,而是rich:popupPanel
  • 是的,但我需要在 Rich:panel 中实现此功能
  • 好吧,让我告诉你rich:panel 没有f:facet name="controls"。您可以做的是将 X 放在标题中并将其发送到左侧
  • 好的,但是当用户点击“X”时我如何处理事件点击?

标签: java jsf-2 richfaces


【解决方案1】:

您可以尝试通过执行类似的操作来模拟相同的行为

<h:form id="frmTest">
    <rich:panel id="panelTest" style="width: 200px">
        <f:facet name="header">
            <h:outputText value="Text Header here" />
            <div style="position: relative; float: right;">
                <a4j:commandLink
                    onclick="document.getElementById('frmTest:panelTest').style.display='none'; return false;">
                    <h:outputText value="X" />
                </a4j:commandLink>
            </div>
        </f:facet> 
        <p>
            Some text here!
        </p>
    </rich:panel>
    <br />
    <a4j:commandLink onclick="document.getElementById('frmTest:panelTest').style.display='block'; return false;">
        <h:outputText value="Show panel" />
    </a4j:commandLink>
</h:form>

【讨论】:

    猜你喜欢
    • 2011-05-06
    • 1970-01-01
    • 2011-03-12
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-05
    相关资源
    最近更新 更多