【问题标题】:use a variable value within a selector on Richfaces JQuery在 Richfaces JQuery 的选择器中使用变量值
【发布时间】:2013-01-06 17:30:43
【问题描述】:

我想在 RichFaces 4 项目中在表单内的输入字段出错时实现光标位置。

我已经在同一个表单中使用了一个 JQuery 函数,以便在显示表单时关注第一个输入字段;这很好用,每次我显示表单时,焦点都在第一个输入字段上。

<rich:jQuery query="focus().select()" selector="#ESUserEditPanelGrid :input:visible:enabled:first" name="focusFirst"/>
<rich:popupPanel id="ESUserEditPanel" autosized="false" keepVisualState="false" domElementAttachment="parent"
                     width="800" height="400" headerClass="panel-header-class" resizeable="true" onshow="focusFirst();" >

为了实现我的目标,我尝试使用 bean 方法更改选择器关键字,但它不起作用。

<rich:jQuery query="focus().select()" selector="#{eSUser.focus}" name="focusFirst"/>

显示表单时似乎没有调用getFocus()方法。

任何提示将不胜感激。

【问题讨论】:

    标签: jquery jsf richfaces


    【解决方案1】:

    也许你可以这样尝试:

    <rich:jQuery query="focus().select()" name="focusFirst"/>
    <rich:popupPanel id="ESUserEditPanel" autosized="false" keepVisualState="false"   
        domElementAttachment="parent" width="800" height="400" 
        headerClass="panel-header-class" resizeable="true" 
        onshow="focusFirst(#{rich:jQuery(eSUser.focus)},{})" >
    

    这应该可以正常工作。 #{rich:jQuery(eSUser.focus)} 命令将从 bean 中获取您的组件 ID 并评估正确的 jQuery 对象。这将传递给命名的 jQuery 函数&lt;rich:jQuery query="focus().select()" name="focusFirst"/&gt;,它将执行焦点查询。

    我知道我有点晚了,但也许将来有人也会遇到同样的问题 :)

    亲切的问候, exor298

    【讨论】:

      猜你喜欢
      • 2010-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-13
      • 1970-01-01
      • 1970-01-01
      • 2013-07-03
      • 1970-01-01
      相关资源
      最近更新 更多