具有多个数据源的 xPage 始终在编辑模式下打开第二个数据源 [英] xPage with multiple datasources has the second datasource always opened in edit mode

查看:18
本文介绍了具有多个数据源的 xPage 始终在编辑模式下打开第二个数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 2 个数据源的 xPage.我打开页面,第一个数据源是只读的,而第二个数据源处于编辑模式.添加 ignoreRequestParms=true 似乎会导致此行为,但这是将文档保存到不同数据源的唯一方法.

I have an xPage with 2 datasources. I open the page and the first datasource is readonly, while the second datasource is in edit mode. Adding ignoreRequestParms=true seems to cause this behavior, but its the only way that the document will save to a different datasource.

我发现有人发现了类似行为的链接.

I have found this link that someone has found similar behavior. http://www-10.lotus.com/ldd/nd85forum.nsf/7756aedc25e6d81285256324005ac76c/5e2f855ea18ff802852576e3007c34f2?OpenDocument

发生了一些我不明白的事情.如果有人能向我解释这一点,我将不胜感激.

There is something going on that I don't understand. If someone could explain this to me I would appreciate it.

这是数据源和标签面板中字段的代码

Here is the code for the data source and the fields in the tab panel

<xp:dominoDocument var="document2" action="createDocument"
        formName="software" ignoreRequestParams="true">
    </xp:dominoDocument>

<xp:tabbedPanel id="tabbedPanel1">
    <xp:tabPanel id="tabPanel1" label="Checklist Items">
        <xp:checkBoxGroup id="checkBoxGroup1" layout="pageDirection"
            value="#{document1.checklist}">
            <xp:selectItems>
                <xp:this.value><![CDATA[#{javascript:var dbName = new     Array("","");
var Rep = @Unique(@DbColumn(dbName,"checklistitems",3));
Rep}]]></xp:this.value>
            </xp:selectItems>
        </xp:checkBoxGroup>
    </xp:tabPanel>
    <xp:tabPanel label="Software" id="tabPanel2">



        <xp:button value="Edit Software list" id="button1">

        <xp:eventHandler event="onclick" submit="true" refreshMode="partial"  refreshId="panelsoft">
            <xp:this.action>
                <xp:changeDocumentMode mode="edit"
                    var="document2">
                </xp:changeDocumentMode>
            </xp:this.action></xp:eventHandler></xp:button>
        <xp:button value="Save Software list" id="button2">
            <xp:eventHandler event="onclick" submit="true"
                refreshMode="partial" refreshId="panelsoft">
                <xp:this.action>

                    <xp:actionGroup>



                        <xp:modifyField name="uid"
                            value="#{javascript:document1.getDocument().getUniversalID()}"
                            var="document2">
                        </xp:modifyField>

                    <xp:executeScript script="#{javascript:document2.save()}">
                        </xp:executeScript></xp:actionGroup>
                </xp:this.action>
            </xp:eventHandler>
        </xp:button>
        <xp:br></xp:br>

        <xp:panel id="panelsoft"><xp:table rendered="#{javascript:document2.isEditable()}"><xp:tr><xp:td><xp:br></xp:br>
                    Software Name
                </xp:td>
                <xp:td>
                    <xp:inputText id="inputText1"
                        style="width:300px" value="#{document2.Softwarename}">
                    </xp:inputText></xp:td>
            </xp:tr>
            <xp:tr>
                <xp:td></xp:td>
                <xp:td></xp:td>
            </xp:tr>
        </xp:table>
        <xp:viewPanel rows="30" id="viewPanel1">
            <xp:this.facets>
                <xp:pager partialRefresh="true"
                    layout="Previous Group Next" xp:key="headerPager" id="pager1">
                </xp:pager>
            </xp:this.facets>
            <xp:this.data>
                <xp:dominoView var="view2" viewName="CustomSoftware"
                    categoryFilter="#{javascript:document1.getDocument().getUniversalID()}">
                </xp:dominoView>
            </xp:this.data>
            <xp:viewColumn columnName="uid" id="viewColumn1">
                <xp:viewColumnHeader value="uid"
                    id="viewColumnHeader1">
                </xp:viewColumnHeader>
            </xp:viewColumn>
            <xp:viewColumn columnName="Softwarename"
                id="viewColumn2">
                <xp:viewColumnHeader value="Software Name"
                    id="viewColumnHeader2">
                </xp:viewColumnHeader>
            </xp:viewColumn>
            <xp:viewColumn columnName="comments" id="viewColumn3">
                <xp:viewColumnHeader value="Comments"
                    id="viewColumnHeader3">
                </xp:viewColumnHeader>
            </xp:viewColumn>
        </xp:viewPanel>

        </xp:panel>

        <xp:br></xp:br>
        <xp:br></xp:br>
        <xp:br></xp:br>

        <xp:br></xp:br>



        <xp:br></xp:br>




        <xp:br></xp:br>

        <xp:panel>

        </xp:panel>
        <xp:br></xp:br>
    </xp:tabPanel>
</xp:tabbedPanel>

推荐答案

因为 action 设置为 createDocument(您可以省略,因为这是默认值),这会导致在内存中创建一个新文档.这就是文档处于编辑模式的原因:您正在编写新记录.如果您不想创建新文档,请将 action 属性更改为其他选项之一:openDocumenteditDocument.其中任何一个都需要设置 documentId 属性,因为数据源需要分别知道哪个您希望打开或编辑的文档.

Because action is set to createDocument (which you could omit, since that's the default value), this causes a new document to be created in memory. This is why the document is in edit mode: you're composing a new record. If you don't want to create a new document, then change the action attribute to one of the other options: openDocument or editDocument. Either of these require that the documentId attribute be set as well, because the data source needs to know which document you wish to, respectively, open or edit.

如果省略 ignoreRequestParams 属性,则此数据源不会忽略 URL 请求参数.相反,它查找名为 databaseNameformNamedocumentIdaction 的参数.如果 URL 中包含这些参数中的任何一个,则每个参数的值都会覆盖数据源上定义的值.这就是为什么如果你打开一个 document1 的实例,但没有在 document2 上设置 ignoreRequestParams,然后 both文档将具有相同的模式(读取/编辑):因为两个数据源都没有忽略 URL,所以两个数据源都在执行 URL 告诉它们的操作.

If you omit the ignoreRequestParams attribute, then this data source doesn't ignore the URL request parameters. Instead, it looks for parameters named databaseName, formName, documentId, and action. If any of these parameters are included in the URL, the value of each overrides what is defined on the data source. This is why if you open an instance of document1, but don't set ignoreRequestParams on document2, then both documents will have the same mode (read/edit): because neither data source is ignoring the URL, so both data sources are doing what the URL is telling them to.

通常,在同一个 XPage 上定义多个数据源时,您将拥有一个可以被视为主要"数据源的数据源;任何其他数据都与该数据有某种关系,但主要数据是用户查看该页面上所有数据的上下文.因此,您希望该数据源尊重 URL 参数,以允许导航(从数据视图、视图面板、重复等)能够指示正在打开哪个文档以及以何种模式打开.但是所有与该文档相关的数据源都应该明确指定它们绑定到哪些数据,以及对该数据采取的操作,并使用 ignoreRequestParams 来确保 URL不会覆盖此信息.

Generally, when defining multiple data sources on the same XPage, you'll have one that can be considered the "primary" data source; any other data has some relationship to that data, but the primary data is the user's context for viewing all the data on that page. So you want that data source to respect URL parameters to allow navigation (from a Data View, View Panel, Repeat, etc.) to be able to indicate which document is being opened, and in what mode. But all data sources related to that document should explicitly specify what data they're bound to, and the action being taken on that data, and use ignoreRequestParams to ensure that the URL doesn't override this information.

这篇关于具有多个数据源的 xPage 始终在编辑模式下打开第二个数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆