从重复控制中获取值 [英] Getting values from repeat control

查看:27
本文介绍了从重复控制中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在重复控件中有一个字段.现在我在 onChange 事件中使用 viewScope 来捕获重复控件内的字段值.每次字段必须部分刷新以获取范围变量中设置的值.

I have a field inside a repeat control. Right now am using a viewScope in the onChange event to capture the field values inside the repeat control. Each time the field has to partial refreshes in order to get the value set in the scope variable.

这里的问题是当用户在重复控件之外设置焦点时,直到字段的部分刷新完成后才设置焦点.有时,当用户访问远程多米诺服务器时,这种部分刷新太慢了.提交表单时,有没有有效的方法来捕获重复控件中的值?

The problem here is when the users set the focus outside the repeat control, the focus is not set until the partial refresh of the field is completed. Sometimes this partial refresh is too slow when user is accessing a remote domino server. Is there a effective way to capture the values inside the repeat control when the form is submitted?

这个想法是在用户点击添加按钮时动态创建字段.当您将焦点从重复控件内的字段移动到重复控件外的字段时,就会出现问题.不会设置焦点,直到重复控件内部字段的部分刷新完成.如果服务器在您的机器上本地运行,您可能不会发生这种情况.下面的代码展示了使用重复控件动态创建字段

The idea is to create fields dynamically when user click on the add button. The problem happen when you move the focus from the field inside the repeat control to the field outside the repeat control. The focus is not set, until the partial refresh of field inside the repeat control is completed. You may not occur this scenario, if the server is running locally on your machine. The below code shows the usage of repeat control to create fields dynamically

<xp:button value="Add Objects" id="addNavObj">
    <xp:eventHandler event="onclick" submit="true"
        refreshId="objLine" refreshMode="partial" id="eventHandler24">
        <xp:this.action><![CDATA[#{javascript:viewScope.rowItems=viewScope.rowItems+1;getComponent("navObjRep").setValue(parseInt(viewScope.rowItems));}]]></xp:this.action>
    </xp:eventHandler>
</xp:button>
<xp:repeat rows="30" var="rowData" indexVar="rowIndex"
    repeatControls="false" first="0" value="#{javascript:viewScope.rowItems}"
    id="navObjRep" style="width:800.0px">
    <xp:panel style="width:800.0px" id="objLine">
        <xp:table style="width:800.0px">
            <xp:tr>
                <xp:td style="width:245.0px">
                    <xp:inputText id="objType" style="width:130.0px">
                        <xp:typeAhead mode="full" minChars="1" ignoreCase="true"
                            id="typeAhead4" rendered="false">
                        </xp:typeAhead>
                    </xp:inputText>
                </xp:td>
                <xp:td style="width:46.0px">
                    <xp:inputText id="objCode">
                        <xp:eventHandler event="onchange" submit="true"
                            refreshMode="partial" refreshId="objCode" id="eventHandler3">
                            <xp:this.action><![CDATA[#{javascript:viewScope['objCode'+rowIndex] = getComponent("objCode").getValue()}]]></xp:this.action>
                        </xp:eventHandler>
                    </xp:inputText>
                </xp:td>
                <xp:td style="width:300.0px">
                    <xp:inputTextarea id="objDesc" style="height:40.0px;width:200.0px">
                        <xp:eventHandler event="onclick" submit="false" id="eventHandler40"></xp:eventHandler>
                        <xp:eventHandler event="onchange" submit="true"
                            refreshMode="partial" refreshId="objDesc" id="eventHandler4">
                            <xp:this.action><![CDATA[#{javascript:viewScope['objDesc'+rowIndex] = getComponent("objDesc").getValue()}]]></xp:this.action>
                        </xp:eventHandler>
                    </xp:inputTextarea>
                </xp:td>
            </xp:tr>
        </xp:table>
    </xp:panel>
</xp:repeat>

推荐答案

不要使用编辑框的 onChange 事件进行部分刷新 - 您会创建一个体验噩梦.练习 23 有你需要的一切.

Don't use the onChange event of an edit box for a partial refresh - you create an experience night mare. Excercise 23 has all you need.

这篇关于从重复控制中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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