本文介绍了Xpage, createForm=false 禁用链接上的 SSJS 事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在这里澄清一下:我不小心将 createForm 属性设置为 false.然后我期望一个应该打开另一个页面的链接事件不再起作用.这是 SSJS 事件的预期行为,例如在禁用表单创建时的链接中?

I ask this just to be clear here: I accidently set the createForm property to false. I then expected a link event that should open another page only not to function any more.Is this the intended behavior of SSJS events e.g. in links when you disable form creation?

推荐答案

正如前面提到的,所有事件都需要一个表单:如果它们完全刷新,那么页面需要一个表单来发布以触发重定向;如果它们是部分刷新,则表单确定 AJAX POST 的内容.

As Per mentions, all events require a form: if they are full refresh, then the page needs a form to post to in order to trigger the redirect; if they are partial refresh, the form determines the contents of the AJAX POST.

XPage 运行时包括对表单组件的支持,但它不包含在组件选项板中(并且无法通过设计器首选项添加),因此将其添加到页面的唯一方法是直接编辑源 XML.例如:

The XPages runtime includes support for a form component, but it is not included in the component palette (and it cannot be added via Designer Preferences), so the only way to add it to a page is by editing the source XML directly. For example:

<xp:form>
    <xp:link id="exampleLink" text="Example Text">
        <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
            <xp:this.action><![CDATA[#{javascript:// event code}]]></xp:this.action>
        </xp:eventHandler>
    </xp:link>
</xp:form>

这个组件有用的原因(至少)有两个:

There are (at least) two reasons why this component is useful:

  1. 它可以提高性能.如果一个页面包含功能不同的不同区域——换句话说,页面一个部分的事件不需要知道任何其他部分的数据页面的一部分——然后将每个部分包装在一个单独的表单组件中,导致每个事件只发布包含在与触发事件的组件相同的表单中的数据.您的问题表明,当您将 createForm 设置为 false 时断开的链接应该将用户导航到另一个页面;因此,这个事件很可能不需要知道任何字段值,因为用户无论如何都会离开当前页面.如果这是真的,请将这个链接包装在它自己的表单中,并将任何字段包装在一个单独的表单中,并且该链接的执行速度会稍微快一些,因为浏览器不必发布任何字段数据……只是链接本身的标识符.
  2. 它可以提供样式灵活性.开发人员通常会从不熟悉 Domino 的设计人员那里收到与实际最终用户要求分开的预先确定的 CSS——例如,如果网站设计是外包的,或者必须遵守企业风格准则.当设计人员做出某些乍一看与 Domino 生成的标记不兼容的假设时,这通常会成为紧张的根源.最常见的例子之一是当网站包含搜索功能时,因为大多数 Web 开发人员将有一个用于搜索的表单和一个用于任何其他字段的单独的同级表单.当设计人员或开发人员必须修改设计人员已经开发的样式表以说明围绕所有内容的单个表单标签时,这会增加项目的成本.简而言之,取消默认表单元素并在需要时明确指定表单组件可以更轻松地遵守外部强加的样式指南.
  1. It can improve performance. If a page contains different areas that are functionally distinct -- in other words, an event in one portion of the page does not need to be aware of data in any other portions of the page -- then wrapping each section in a separate form component causes each event to only post data that is contained inside the same form as the component that triggers the event. Your question indicates that the link that broke when you set createForm to false should navigate the user to another page; it's likely, therefore, that this event doesn't need to know about any field values, because the user is leaving the current page anyway. If that's true, wrap this link in its own form, and any fields inside a separate form, and the link will perform marginally faster because the browser doesn't have to post any field data... just the identifier for the link itself.
  2. It can provide style flexibility. It's common for a developer to receive, separately from the actual end user requirements, pre-determined CSS from a designer unfamiliar with Domino -- for instance, if the site design is outsourced, or must adhere to corporate style guidelines. This often becomes a source of tension when the designer has made certain assumptions that, at first glance, are incompatible with the markup that Domino generates. One of the most common examples of this is when the site contains search features, because most web developers will have one form for search and a separate sibling form for any other fields. This can increase the cost of a project when either the designer or the developer has to revise a stylesheet that the designer already developed to account for a single form tag surrounding all the content. In short, suppressing the default form element and explicitly specifying form components where needed makes it easier to adhere to externally imposed style guidelines.

因此,在许多用例中,实际上最好在 XPage 上使用一个或多个表单组件……只要记住,所有数据和事件都必须在一个表单内——无论是通常包围所有内容的默认表单,或手动包含的表单组件——并且该表单不能嵌套.您可以根据需要添加任意数量的表单组件,但它们必须是兄弟.任何形式都不能包含另一种形式.

So there are many use cases where it's actually preferable to use one or more form components on an XPage... just remember that all data and events must be inside a form -- whether the default form that usually surrounds all the content, or a manually included form component -- and that forms cannot be nested. You can add as many form components as you want, but they must be siblings. No form can contain another form.

这篇关于Xpage, createForm=false 禁用链接上的 SSJS 事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 12:10