【问题标题】:XPages - disable client side validation for Dojo Combo boxXPages - 禁用 Dojo 组合框的客户端验证
【发布时间】:2013-10-09 08:04:45
【问题描述】:

我尝试禁用 Dojo 组合框的客户端验证,但未成功。我添加了一个 dojo 属性“必需”并将其设置为 false,但这仍然不起作用。我确实希望启用服务器端验证,这就是我设置 required="true" 的原因。任何人都可以看到需要对以下代码进行哪些更改?

<xe:djComboBox id="djComboBox1" required="true" disableClientSideValidation="true">
<xe:this.dojoAttributes>
<xp:dojoAttribute name="required" value="false">
</xp:dojoAttribute>
</xe:this.dojoAttributes>
<xp:selectItem itemLabel="" />
<xp:selectItem itemLabel="Apples" />
<xp:selectItem itemLabel="Oranges" />
<xp:selectItem itemLabel="Pears" />
<xp:selectItem itemLabel="Bananas" />
<xp:selectItem itemLabel="Plums" />
</xe:djComboBox>

【问题讨论】:

  • 绑定了什么?

标签: dojo xpages


【解决方案1】:

尝试使用始终返回 true 的方法覆盖组合框的客户端验证公式:

<xe:djComboBox
    id="djComboBox1"
    required="true"
    validatorExt="return true;">
    <xp:selectItem itemLabel="" />
    <xp:selectItem itemLabel="Apples" />
    <xp:selectItem itemLabel="Oranges" />
    <xp:selectItem itemLabel="Pears" />
    <xp:selectItem itemLabel="Bananas" />
    <xp:selectItem itemLabel="Plums" />
</xe:djComboBox>

【讨论】:

  • 非常感谢。这是一个非常好的解决方案。客户端验证被禁用,但服务器端验证继续工作。
【解决方案2】:

据我所知,您不能在 Dojo 表单控件上禁用客户端验证。 Dojo 是一个客户端框架,控件只是让实现 Dojo 版本变得更加容易。验证是 Dojo 客户端 JavaScript 代码的一部分,而不是 XPages 服务器端运行时的任何内容。因此验证旨在运行客户端而不是服务器端。

标准的 ComboBox 控件将为您提供所需的内容。您可以通过使用例如标识相关样式来重现 Dojo 版本的样式。萤火虫。

另一个选项是在您的保存按钮中进行验证。有一个 XSnippet 可以帮助将控件标记为无效并发布到 xp:messages 或 xp:message 控件http://openntf.org/XSnippets.nsf/snippet.xsp?id=ssjs-form-validation-that-triggers-errormessage-controls。但这不会给出 Dojo 错误样式,它也是 Dojo 代码的一部分,而不是 XPages 运行时的特定部分。

【讨论】:

  • 如果将Dojo表单控件的required属性设置为false,客户端验证将被禁用。
  • 我确实将 required 属性设置为 false 如您所见,但没有达到预期的结果。
  • @TonyGuiheen:不。在上面的代码中,required 设置为 true,而不是 false
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-06
  • 1970-01-01
  • 1970-01-01
  • 2016-01-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多