【问题标题】:Lotus Xpages TypeAhead option changes the DOM id of the labelLotus Xpages TypeAhead 选项更改标签的 DOM id
【发布时间】:2012-08-17 08:24:11
【问题描述】:

更改为输入文本字段生成的标签 ID,前提是该字段启用了 字段。

1。 上的源码不带

<xp:tr> <th scope="row">
<xp:label id="labelClientRapporteur" for="clientRapporteur"> <xp:this.value><![CDATA[${javascript:clientData['clientRapporteur']}]]></xp:this.value> </xp:label> </th> <xp:td> <xp:inputText id="clientRapporteur" value="#{complaintDocument.clientRapporteur}">
</xp:inputText> </xp:td> </xp:tr>

2. 以及浏览器中页面的来源:

<tr> <th scope="row"> <label id="view:_id1:_id2:_id31:_id45:labelClientRapporteur" class="xspTextLabel" for="view:_id1:_id2:_id31:_id45:clientRapporteur">Ügyfélreferens</label> </th> <td> <input id="view:_id1:_id2:_id31:_id45:clientRapporteur" class="xspInputFieldEditBox" type="text" name="view:_id1:_id2:_id31:_id45:clientRapporteur"> </td> </tr>

3。 的代码在 的情况下为相同的输入启用:

<xp:tr> <th scope="row">
<xp:label id="labelClientRapporteur" for="clientRapporteur"> <xp:this.value><![CDATA[${javascript:clientData['clientRapporteur']}]]></xp:this.value> </xp:label> </th> <xp:td> <xp:inputText id="clientRapporteur" value="#{complaintDocument.clientRapporteur}"> <xp:typeAhead mode="partial" minChars="1" ignoreCase="true" valueList="#{javascript:return namesTypeAhead();}" var="lupkey" valueMarkup="true"> </xp:typeAhead> </xp:inputText> </xp:td> </xp:tr>

4。以及浏览器中带有字段的页面来源:

<tr> <th scope="row"> <label id="view:_id1:_id2:_id31:_id45:clientRapporteur_label" class="xspTextLabel" for="view:_id1:_id2:_id31:_id45:clientRapporteur">Ügyfélreferens</label> </th> <td> <span id="view:_id1:_id2:_id31:_id45:_id78" mode="partial" jsid="view__id1__id2__id31__id45__id78" dojotype="ibm.xsp.widget.layout.data.TypeAheadReadStore"></span> <div id="widget_view:_id1:_id2:_id31:_id45:clientRapporteur" class="dijit dijitReset dijitInlineTable dijitLeft xspInputFieldEditBox dijitTextBox dijitComboBox" role="combobox" widgetid="view:_id1:_id2:_id31:_id45:clientRapporteur" aria-labelledby="view:_id1:_id2:_id31:_id45:clientRapporteur_label"> </td> </tr>

5。为标签生成的 id 为:

view:_id1:_id2:_id31:_id45:clientRapporteur_label

,而不是

view:_id1:_id2:_id31:_id45:clientRapporteur

。问题是,我使用

setTextLabelForRequired("#{id:labelClientRapporteur}");

改变标签的样式,这个代码在这种情况下不起作用,因为标签的id改变了。

我想知道如何解决此 id 更改问题,或者最好的解决方法是什么?

【问题讨论】:

  • 所以使用 setTextLabelForRequired("#{id:labelClientRapporteur}");在带有预先输入的标签上无法返回正确生成的 id?
  • 是的,因为在前面输入字段的情况下,id "view:_id1:_id2:_id31:_id45:clientRapporteur" 不存在。
  • 我了解生成的id发生了变化。但是 #{id:labelClientRapporteur} 应该处理好并返回正确的 id。它会返回错误的 id 吗?
  • 我猜你需要像 xpage 内容一样通过 Lotus 引擎呈现你的 javascript。至少这就是我从上面的 cmets 得到的
  • 我做了一个小测试(使用 8.5.3FP2),在我的测试中,如果 inputText 控件启用了预输入,标签不会在其 ID 后附加“_label”。您使用的是哪个版本的 Notes 和 Domino?

标签: lotus type-ahead xpage type-ahead xpage type-ahead type-ahead javascript dojo xpages lotus type-ahead


【解决方案1】:

我认为这是一个可行的解决方法。最佳方案是拥有唯一的 jsid ofc。

这会

  1. 使用选择器循环所有节点
  2. 循环所有文本框
  3. 通过 domNode 查找注册的小部件(不确定逻辑如何,但通过 Id 肯定更好)

所以:

var arr = dojo.filter(dojo.query('.xspInputFieldEditBox'), function(domNode) {

   if(/labelClientRapporteur/.test(domNodes.className))
      return true;

});
var widget = dijit.getEnclosingWidget(arr[0]);

或者更松散的匹配:

var nodes = dojo.query('.xspInputFieldEditBox[id*="labelClientRaporteur"]');
var domNode = nodes[0];

【讨论】:

  • 建议的解决方法似乎有效。我将xspInputFieldEditBox替换为xspTextLabel,因为我们要查找标签的id,而不是输入。谢谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-06
  • 2011-12-20
  • 1970-01-01
  • 2021-12-20
  • 1970-01-01
  • 2019-02-09
  • 1970-01-01
相关资源
最近更新 更多