2012-04-11 33 views
2

我正嘗試通過編輯框的值+自己的值來更新計算字段值。xpages中的計算字段值

寫在按鈕上的代碼:這裏我把編輯框的值放在作用域變量中,並使編輯框爲空。 comment_te是編輯框的名稱

requestScope.put("commentValue", getComponent("comments_te").getValue); 
getComponent("comments_te").setValue(""); 

爲計算字段的值編寫的代碼:評論是計算領域

getComponent("comments").getValue + "\n" + requestScope.get("commentValue") 

的名字,但我得到的輸出是: 0 com.ibm.xsp .component.xp.XspInputText @ 65426542

請幫我這個。

回答

6

您在調用getValue()時缺少括號。通過省略這些,您將返回指向組件的getValue方法的指針,而不是調用該方法的結果。將每個引用更改爲getValue getValue(),您將得到不同的結果。

0

您的代碼返回對象。 請嘗試以下操作。 下面的代碼獲取編輯框的值並設置爲範圍變量。

requestScope.commentValue = getComponent("comments_te").value; 
getComponent("comments_te").value = ""; 

以下代碼將該值設置爲計算字段。

getComponent("comments").value = getComponent("comments").value + "\n" + requestScope.commentValue; 

當您將值附加到計算字段時,默認情況下會將0添加到其值。如果需要的話進行驗證。

我希望這可以幫助你... !!!