XPages-数据绑定问题
我在计算数据绑定字段名时遇到问题。我没有收到任何错误,但是单选按钮处于“禁用”状态。当我将简单的数据绑定放在我知道有效的字段上时,收音机将失去“禁用”状态并按预期工作,但显然没有保存到我想要的字段名。最终目标是基于两个自定义属性的组合构建字段名。我尝试了多种方法,其中一些方法如下所示:XPages-数据绑定问题,xpages,Xpages,我在计算数据绑定字段名时遇到问题。我没有收到任何错误,但是单选按钮处于“禁用”状态。当我将简单的数据绑定放在我知道有效的字段上时,收音机将失去“禁用”状态并按预期工作,但显然没有保存到我想要的字段名。最终目标是基于两个自定义属性的组合构建字段名。我尝试了多种方法,其中一些方法如下所示: 1. compositeData.dataSource[compositeData.fieldName #compositeData.radio1LabelText] 2. compositeDa
1. compositeData.dataSource[compositeData.fieldName #compositeData.radio1LabelText]
2. compositeData.dataSource[compositeData.fieldName+compositeData.radio1LabelText]
3. compositeData.dataSource[compositeData.fieldName,compositeData.radio1LabelText]
4. try{
var fieldName:string=compositeData.fieldName;
var fieldLabel:string=compositeData.radio1LabelText;
return compositeData.dataSource+"."+fieldName+fieldLabel;
}catch(e){
openLogBean.addError(e,this.getParent());
}
5. compositeData.dataSource[compositeData.fieldName += compositeData.radio1LabelText]
6.compositeData.dataSource[compositeData.fieldName.concat(compositeData.radio1LabelText)]
谢谢
与Jesse聊天的评论更新:
<xp:repeat id="repeat1" rows="30"
value="#{javascript:compositeData.labels}" var="rptLabels">
<tr>
<td>
<xp:panel>
<xp:this.dataContexts>
<xp:dataContext var="concatRadioName1">
<xp:this.value><![CDATA[#{javascript:var tmpString = "GIMS"+rptLabels+"Self";
var fieldName = tmpString.replace(/\s+/g, '');
print(fieldName);
return fieldName
}]]></xp:this.value>
</xp:dataContext>
</xp:this.dataContexts>
<xp:radioGroup styleClass="no-margin">
<xp:this.value><![CDATA[#{compositeData.dataSource[concatRadioName1]}]]></xp:this.value>
<xp:selectItem itemValue="1" itemLabel=""></xp:selectItem>
<xp:selectItem itemValue="2" itemLabel=""></xp:selectItem>
<xp:selectItem itemValue="3" itemLabel=""></xp:selectItem>
</xp:radioGroup>
</xp:panel>
</td>
</tr>
</xp:repeat>
无论出于何种原因,XPages中的EL没有字符串连接运算符,这使得这类操作变得棘手。在我脑海中,我能想到两条可行的路线:
- 在自定义控件中,可以有一个连接这两个属性的
,如dataContext
。然后,您可以稍后在页面中使用#{compositeData.dataSource[concatFieldName]}
- 如果这些值在调用页面上是硬编码的,或者可以使用${}-binding计算,那么可以使用SSJS生成绑定,类似于在#4中尝试的。您可以将SSJS计算放在${}绑定中,然后让输出成为连接字符串的#{}绑定的字符串版本。当您这样做链时,运行时将正确解析内部运行时绑定
compositeData.dataSource
是空的。在数据源中传递的周围代码可能有问题。