I have two buttons in different custom controls which within their onclick events call context.redirectToPage(). In one instance, this causes an HTTP redirect (HTTP status of 302) to the expected URL (i.e. header Location = http://frontend.company.com/path/to/file.nsf/myXpages.xsp?documentId=C699C5D6E81721EA85257A2F00683319&openDocument). In the other instance, it returns a tag like this:
<script>window.location.href='http://backend.company.com:81/path/to/file.nsf/myXpage.xsp?documentId=C699C5D6E81721EA85257A2F00683319&openDocument'</script>
Both instances have submit=true, refresh=complete and immediate=true. Both have client-side scripts which execute correctly and a few lines of SSJS that execute before the redirect call. The only difference that I can conceive that might be causing this is that the button which returns the script is within an (xe:dialog).
The astute among you will notice why this is a problem for me as our Domino server is behind a reverse proxy. Mere mortals do not have direct access to Domino and so the URL generated in the script tag will not work.
Does anyone have an idea on how to get the preferred behavior of a 302 redirect from the second button, or even a way to get it to use the correct URL? Or even shed some light on why the behavior would be different?
Thanks,
Rich
EDIT: code for button that generates script tag for context.redirect():
<xp:button
id="errorReloadButton"
value="Reload Page">
<xp:this.rendered><![CDATA[#{javascript:whichButton == "reload"}]]></xp:this.rendered>
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete"
immediate="true">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript>
<xp:this.script><! [CDATA[#{javascript:sessionScope.remove("errors");
var c = getComponent("errorDialog")
c.hide();
var redirectTarget = view.getPageName() + '?documentId=' + compositeData.docID + '&openDocument';
context.redirectToPage(redirectTarget,true);
}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:this.action>
<xp:this.script>
<xp:executeClientScript>
<xp:this.script><![CDATA[setClean("#{javascript:compositeData.docID}");
XSP._setDirty(false,"");]]></xp:this.script>
</xp:executeClientScript>
</xp:this.script>
</xp:eventHandler>
</xp:button>
EDIT 2: source for button that correctly forces a 302 redirect:
<xp:button
id="cancelButton"
value="Cancel"
rendered="#{javascript:compositeData.documentDataSource.isEditable()}">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete"
onError="handleError(arguments[0],arguments[1])"
immediate="true">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:var xdoc:NotesXspDocument = compositeData.documentDataSource;
if(xdoc.isNewNote()){
return;
}
var doc:NotesDocument = xdoc.getDocument(false);
/* more code here, not relevant to this */
var docid = doc.getUniversalID();
context.redirectToPage(view.getPageName() + '?documentId=' + docid + '&openDocument')}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:this.action>
<xp:this.script>
<xp:executeClientScript>
<xp:this.script><![CDATA[setClean("#{javascript:docId(compositeData.documentDataSource)}");
if(#{javascript:compositeData.documentDataSource.isNewNote()}){
popPageStack();
return false;
}]]></xp:this.script>
</xp:executeClientScript>
</xp:this.script>
</xp:eventHandler>
</xp:button>