0

クライアント側の検証を使用する XPage があります。検証に失敗すると、ユーザーにalertメッセージが表示され、サーバー側の処理は許可されません。私が遭遇した問題は、サーバー側の変数をクライアント側に「割り当てる」ことができないことです。たとえば、次のような XP 入力フィールドがあるとします。

<xp:inputText 
  styleClass="doc_field_textinput" id="input_part_title" type="text" size="40" 
  disableClientSideValidation="true" >
</xp:inputText>

そして、検証するためにボタンを使用し、検証が成功した場合は、これを保存します:

<xp:button id="save_part_btn" value="+Add this" style="float:right;">
             <xp:eventHandler event="onclick" submit="true"
                refreshMode="complete">
                <xp:this.action><![CDATA[#{javascript:

                    var estdoc:NotesDocument=database.getDocumentByUNID(doc_source.getDocument().getParentDocumentUNID())
                    var estPartdoc:NotesDocument=estdoc.getParentDatabase().createDocument()

                    estPartdoc.replaceItemValue('Form','Estimate_Cost_Part')
                    estPartdoc.replaceItemValue('Predoc',estdoc.getUniversalID())
                    estPartdoc.replaceItemValue('$OSN_IsSaved','1')

                    estPartdoc.replaceItemValue('Title', getComponent('input_part_title').getValue())

                    }]]>
            </xp:this.action>
                <xp:this.script><![CDATA[ 
                var result = "";
                var wholeResult = true;

                function isStringEmpty(string2Check) 
                {
                    return string2Check == "" || string2Check[0] == " ";
                }

                if(isStringEmpty(document.getElementById("#{id:input_part_title}").value)) 
                {
                    wholeResult = false;
                    result += 'The field cannot be empty!'
                }

                result = result.replace(/\n$/, "")

                if(!wholeResult) 
                {
                    alert(result)
                }

                return wholeResult;

                ]]>
                </xp:this.script>
             </xp:eventHandler>
</xp:button>

残念ながら、input_part_titleサーバー側のは、どのような状況でも常にnulldocument.getElementById("#{id:input_part_title}").valueですが、非常にうまく機能し、実際に期待どおりに機能します。documentサーバー側に同じコード行を追加できればいいのですが、サーバー側のプロパティが不明なためできません。input_part_titleクライアント側から値に何らかの方法で割り当てる方法はありますか?

4

1 に答える 1