在 SSJS 按钮中,我有一个 NotesViewEntryCollection [英] In a SSJS button I have got a NotesViewEntryCollection

查看:17
本文介绍了在 SSJS 按钮中,我有一个 NotesViewEntryCollection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

by veCol = vw.getAllEntriesByKey(key,false) 其中 key 是来自表单"控件的值.如果 veCol 中的计数为零,我将返回一条消息,指出搜索失败,如果计数为 1(一),我将设置一些值并将页面重定向到输入页面,但是,如果计数大于一,我想将 veCol 显示到重复控件.我想为 veCol 设置一个 viewScope 变量,但我看到警告不要将 Notes 对象存储在 Scope 变量中,因为它们没有序列化.所以我的问题是有没有办法将我的 veCol 传递给同一个自定义控件上的重复控件?"实际上控件是一个对话框,但这应该无关紧要.

by veCol = vw.getAllEntriesByKey(key,false) where key is a value from a control on the 'form'. If the count in the veCol is Zero I return a message that the search failed, if the count is 1 (One) I set some values and redirect the page to an input page, however, if the count is greater than one I want to display the veCol to a repeat control. I thought of setting a viewScope variable to the veCol but I have seen the admonished don't store a Notes Object in a Scope variable because they are not serialized. So my question is "Is there a way to pass my veCol to a repeat control on the same custom control?" Actually the control is a dialog but that shouldn't matter.

在另一个实例中,我将集合转换为 viewScope 变量中的 UNID 数组,然后将重复绑定到变量.这意味着我必须使用有效的 UNID 再次获取每个文档,但是 veCol 已经包含了我需要的一切,只要能够通过它就会更有效率.所以我知道我可以让它工作,但需要相当多的开销.

In another instance I took the collection and turned it into an array of UNIDs in a viewScope variable then bound the repeat to the variable. This means that I have to get each document again using the UNID which works, but the veCol already contains everything that I need, just being able to pass it would be more efficient. So I know I can make it work but with a fair bit of overhead.

按钮中的代码非常简单,我执行 var veCol:NotesViewEntryCollection = vw.getAllEntriesByKey(key, false);

The code is pretty simple in my button I execute var veCol:NotesViewEntryCollection = vw.getAllEntriesByKey(key, false);

在包含按钮的同一个对话框中,我想要使用作为 veCol 返回的值进行重复.

in the same dialog that contains the button I want a repeat using the value returned as veCol.

感谢任何帮助.

推荐答案

您可以创建自己的 ValueBinding 并覆盖现有的重复项之一:

You could create your own ValueBinding and overwrite the exitsing one of the repeat:

<xp:button
    value="Label"
    id="button1">
    <xp:eventHandler
        event="onclick"
        submit="true"
        refreshMode="partial"
        refreshId="repeat1">
        <xp:this.action>
            <![CDATA[#{javascript:
                var valueExpr = "#{javascript:vw.getAllEntriesByKey(key, false);}";
                var value:javax.faces.el.ValueBinding = facesContext.getApplication().createValueBinding(valueExpr);
                var veCol:NotesViewEntryCollection = value.getValue( facesContext );

                if( veCol.getCount() > 0 ){
                    var cmpRepeat:com.ibm.xsp.component.xp.XspDataIterator = getComponent('repeat1');
                    cmpRepeat.setValueBinding( "value", value );
                }else{
                    // do redirect
                }
        }]]></xp:this.action>
    </xp:eventHandler>
</xp:button>

或者只是在您的按钮中定义一个 SSJS 变量,然后测试该变量是否存在:

Or just define a SSJS variable in your button, and test if the variable exists:

<xp:repeat
    id="repeat1"
    rows="30"
    var="doc">
    <xp:this.value>
        <![CDATA[#{javascript:
            if(  typeof( veCol ) != "undefined" ){
                return veCol;
            }
        }]]>
    </xp:this.value>
    <xp:label
        value="#{javascript:if( doc != null ) doc.getUniversalID()}"
        id="label1">
    </xp:label>
</xp:repeat>

这篇关于在 SSJS 按钮中,我有一个 NotesViewEntryCollection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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