【问题标题】:How is it possible to get all available java script methods of the component rich:modalPanel?如何获取组件rich:modalPanel 的所有可用java 脚本方法?
【发布时间】:2023-04-10 06:36:02
【问题描述】:

我的 xhtml 页面中有这个 rich:modalPanel:

<rich:modalPanel id="submitPanel" width="100" height="100"
    style="text-align:center;margin-top:30px;">
    <h:graphicImage value="/img/ajax-loader.gif" style="border: 0;"
            height="30" width="30" />
</rich:modalPanel>

现在我可以在组件 h:commandLink 的 onclick js 属性中调用它,例如:

<h:commandLink styleClass="dontsave left" value="#{txt.cancel}"
        action="#{newMessageBean.cancelAction}"
        onclick="#{rich:component('submitPanel')}.show(); return true;" />

但是我怎样才能获得组件rich:modalPanel 的所有可用js 方法呢? JBoss 文档不是一个好方法,因此我可能使用较旧的 Richfaces 版本,该版本没有以合适的方式记录。

如何调用我在运行时使用所有可用方法检查这些对象?例如,通过使用 Firebug 和命令“console.log(#{rich:component('submitPanel')})”或其他什么?最好的解决方法是什么?

【问题讨论】:

  • 你说的不对。转到http://www.jboss.org/richfaces/docs 并查看 RichFaces 3.3.3 部分。有很好的文档。尝试以demo 开头。
  • 所以,但我过去也遇到过这种情况,想使用 rich:calendar 组件的记录方法。而且在这种情况下,文档和使用对象不一样!!
  • 在开发人员指南中,每个组件都有JavaScript API 部分。对于日历组件,它是 表 6.163。 JavaScript API。见link
  • 更多关于在 RichFaces 中使用 javascrript 的信息在 Practical RichFaces, Second Edition 一书中
  • 你不对!看这里:文档谈到了方法“getSelectedDate()”中的rich:calendar 组件,但是这个方法不起作用,因为它不存在于这个对象中。在这种情况下,正确的方法是“getSelectedDateString()”

标签: javascript jsf richfaces


【解决方案1】:

您可以像这样调用显示模式面板:

<a4j:commandButton styleClass="button" value="#{msg.addNote}"
    oncomplete="Richfaces.showModalPanel('noteDetails')">
</a4j:commandButton>

<rich:modalPanel id="noteDetails" />
    <f:facet name="controls">
        <h:graphicImage value="/images/close.png" 
            style="cursor:pointer" onclick="Richfaces.hideModalPanel('noteDetails')" />
    </f:facet>
</rich:modalPanel>

这是带有onclick的版本:

<a4j:commandButton value="Find Segments" immediate="true"
    ajaxSingle="true"
    oncomplete="Richfaces.showModalPanel('clientCatSearch')"
    event="onclick" reRender="clientCatSearch">
</a4j:commandButton>

【讨论】:

    【解决方案2】:

    您需要知道组件的完整 id,例如j_id352:panel。然后您可以使用$('j_id352:panel').component 访问该组件。

    您不能使用#{rich:component('submitPanel')},因为#{…} 仅适用于在页面呈现之前的服务器端处理。

    你应该考虑更新,如果你不能去 RF 4,至少到 RF 3.3.3。

    【讨论】:

      【解决方案3】:

      您可以在 Firebug 中检查 ModalPanel.prototype 对象。

      一个快速的 JavaScript sn-p 输出ModalPanel.prototype 的所有成员:

      var result = '';
      for (var item in ModalPanel.prototype) {
         result += item + '\n';
      }
      alert(result);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-21
        相关资源
        最近更新 更多