背景:タブ付きテーブル(コンテナコントロールから)と複数のデータソース(タブごとに1つ)を含むXPage。ユーザーがページを更新すると、保存ボタンが重複して作成されるという問題が発生していました。これを修正するために、TommyValandによって作成されたこのソリューションを実装しました。 http://dontpanic82.blogspot.com/2010/06/xpages-avoid-saving-duplicate-documents.html
問題は、ユーザーが2番目のタブを表示し、完全更新を使用してドキュメントを保存する場合です(添付ファイルのためにこれが必要です)。関数は以下を除いてうまく機能します...
問題:リダイレクトにより、ユーザーは常に最初のタブに移動します。これは、最初のタブを除くすべてのタブで明らかに問題になります。
URLを2番目のタブに直接送信する方法を教えてください。Tommyのコードを変更してハッシュタグを含めようとしましたが、これを機能させることができませんでした。ハッシュタグがxpagesで機能するかどうかさえわかりません。この問題についてご協力いただきありがとうございます。
function redirectToCurrentDocument( switchMode:boolean, tab){
try {
if( typeof currentDocument === 'undefined' || viewScope.stopRedirect ){ return; }
// Gets the name of the XPage. E.g. /Person.xsp
var page = view.getPageName();
// Finds extra parameters, strips away XPages parameters/trims leading &
var parameters = context.getUrl().getQueryString().substring(1);
var extraParameters = parameters.replace(
/([&\?^]*_[a-z0-9=]+[&]{0,1})|(action=\w{4}Document[\&]{0,1})|(documentId=[\w]{32}[\&]{0,1})/ig, '').replace( /\&$/, '' );
// Gets the unid of the current document
//var unid = currentDocument.getDocument().getUniversalID();
//var unid = document1.getDocument().getUniversalID(); //changed this line to make work with multiple data sources - SJZ
var unid = document1.getDocument().getNoteID(); //also changed to use NoteID since it gave runtime errors for new documents - SJZ
// Sets/changes the action according according to the mode the document is in
var isEditable = currentDocument.isEditable();
if( switchMode ){ isEditable = !isEditable; } // false -> true / true -> false
var action = ( isEditable ) ? 'editDocument' : 'openDocument';
// Open the current document via a get request
var redirectUrl = page + '?documentId=' + unid + '&action=' + action;
if( extraParameters ){ redirectUrl += '&' + extraParameters; }
print("tab=" + tab)
if(tab == "Invoices") { redirectUrl += '#tabPanel1'; }
if(tab == "Credits") { redirectUrl += '#view:_id1:tabPanel2:editPanelCredits'; }
print(redirectUrl);
context.redirectToPage( redirectUrl );
} catch(e){ /* Exception logging */ }
}