I have a page bound to a doc data source. At the top of the page is a panel where the fields for the doc is set. In the bottom of the page is a view of the docs.
Let's say the fields are [A] and [B], and [B]'s value depends on [A], which partial refreshes [B] on some value change. When I just set [A] that doesn't trigger the partial refresh then press submit/save, the doc is saved and the page updates fully and the doc appears in the view below.
BUT if I set [A] such that [B] refreshes then press submit/save, the doc is saved BUT the doc doesn't appear in the view. I need to reload the page by pressing ENTER in the URL bar to update the view. Tried to do a research on this but to no avail.
What do you think I can do to update the view on the last scenario?
Here is the simplified code:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom"
style="font-size:11pt;font-weight:bold">
<xp:this.beforePageLoad>
<![CDATA[#{javascript:var currLocation=context.getUrl();
var webDBPath=@LeftBack(currLocation,"/");
sessionScope.jQuery=webDBPath+"/jquery.min.js";
sessionScope.jQueryUI=webDBPath+"/jquery-ui.min.js";
sessionScope.jQueryBlockUI=webDBPath+"/jquery.blockUI.js"}]]>
</xp:this.beforePageLoad>
<xp:this.data>
<xp:dominoDocument var="attachmentDoc" formName="Attachment"></xp:dominoDocument>
</xp:this.data>
<xp:this.resources>
<xp:script src="#{javascript:sessionScope.jQuery}"
clientSide="true">
</xp:script>
<xp:script src="#{javascript:sessionScope.jQueryUI}"
clientSide="true">
</xp:script>
<xp:script src="#{javascript:sessionScope.jQueryBlockUI}"
clientSide="true">
</xp:script>
<xp:script src="/home.js" clientSide="true"></xp:script>
<xp:styleSheet href="/style.css"></xp:styleSheet>
<xp:styleSheet href="/jquery-ui.css"></xp:styleSheet>
<xp:script src="/utils.jss" clientSide="false"></xp:script>
</xp:this.resources>
<xp:span style="font-weight:bold;font-size:11pt"></xp:span>
<xp:span style="font-size:14pt"></xp:span>
<xp:span style="font-weight:bold;font-size:11pt"></xp:span>
<xp:inputText id="reUploadAttachmentID" style="display: none;"
styleClass="reUploadAttachmentID"></xp:inputText>
<xp:br style="font-size:11pt"></xp:br>
<xp:panel style="margin-left:auto;margin-right:auto;width:940.0px"
id="mainPanel">
<xp:span style="font-size:14pt"></xp:span>
<xp:span style="font-size:14pt"></xp:span>
<xp:br style="font-weight:bold"></xp:br>
<xp:br></xp:br>
<xp:inputText id="errorMessage" value="#{requestScope.errorMessage}"
styleClass="errorMessage"></xp:inputText>
<xp:span style="font-weight:bold"></xp:span>
<xp:span style="font-weight:bold">
<xp:span style="font-weight:bold"></xp:span>
</xp:span>
<xp:br></xp:br>
<xp:panel styleClass="upload-details-panel">
<xp:span>Upload:</xp:span>
<xp:fileUpload id="fileUpload1" value="#{attachmentDoc.Attachment}"></xp:fileUpload>
</xp:panel>
<xp:panel styleClass="upload-details-panel">
<span>Type:</span>
<xp:comboBox id="cbUploadType" value="#{attachmentDoc.File_Type}"
styleClass="cbUploadType">
<xp:selectItem itemLabel="Attachment"></xp:selectItem>
<xp:selectItem itemLabel="eCR Master File"></xp:selectItem>
<xp:selectItem itemLabel="Financial Analysis"></xp:selectItem>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="panelUploadDetails">
</xp:eventHandler>
</xp:comboBox>
</xp:panel>
<xp:panel id="panelUploadDetails">
<xp:panel styleClass="upload-details-panel">
<xp:this.rendered><![CDATA[#{javascript:var uploadType = getComponent("cbUploadType").getValue();
if(uploadType == "Attachment" || uploadType == null){
return false;
}
return true;}]]></xp:this.rendered>
<span>Division:</span>
<xp:comboBox id="comboBox1" value="#{attachmentDoc.File_Database}"
styleClass="cbUploadDatabase">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var options = ["---"];
return options.concat(@Unique(@DbColumn("", "eCR Database Settings", 1)));}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial"
refreshId='#{javascript:var uploadType = getComponent("cbUploadType").getValue();
if(uploadType == "Financial Analysis"){
return "panelFAType";
}
return "panelExtra";
}'>
</xp:eventHandler>
</xp:comboBox>
</xp:panel>
<xp:panel id="panelExtra">
<!--
this is just used to redirect partial refresh of Division
Selection for non-FA
-->
</xp:panel>
<xp:panel styleClass="upload-details-panel" id="panelFAType">
<xp:this.rendered><![CDATA[#{javascript:var uploadType = getComponent("cbUploadType").getValue();
if(uploadType == "Financial Analysis"){
return true;
}
return false;}]]></xp:this.rendered>
<span>Financial Analysis Type:</span>
<xp:comboBox id="comboBoxFAType" value="#{attachmentDoc.FAType}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var division = getComponent("comboBox1").getValue();
if(division != null){
return getFATypeOptions(getComponent("comboBox1").getValue());
}
return "---";}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xp:panel>
</xp:panel>
<xp:panel styleClass="upload-details-panel">
<span></span>
<xp:button id="btnUpload" value="Upload" styleClass="btnUpload"
style="height:26.0px">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete" immediate="false" save="true">
<xp:this.action><![CDATA[#{javascript:
var fileData:com.ibm.xsp.http.UploadedFile = facesContext.getExternalContext().getRequest().getParameterMap().get(getClientId('fileUpload1'));
var db:NotesDatabase = session.getCurrentDatabase();
var agent = database.getAgent("Import Data to Document");
//var attDoc:NotesDocument = attachmentDoc.getDocument();
//var doc:NotesDocument = db.createDocument();
var doc:NotesDocument = attachmentDoc.getDocument();
var settingsDoc:NotesDocument = db.getProfileDocument("eCRFilesDBConfiguration", "");
var repositoryPath:String;
if (fileData != null) {
//doc.replaceItemValue('Form', 'Attachment');
doc.computeWithForm(true, false);
var clientFileName:String = fileData.getClientFileName();
var newFile:java.io.File = new java.io.File(fileData.getServerFileName());
var filePath:string = doc.getItemValueString("File_Path");
doc.replaceItemValue('File_Name', clientFileName);
// get file extension
var extension:string = '';
var newFileName:string = '';
var i:int;
i = clientFileName.lastIndexOf('.');
if (i > 0) {
extension = clientFileName.substring(i+1);
}
doc.replaceItemValue('File_Extension', extension);
newFileName = doc.getUniversalID() + '.' + extension;
//var savedFile:java.io.File = new java.io.File('C:\\' + newFileName);
//var savedFile:java.io.File = new java.io.File('C:\\' + clientFileName);
repositoryPath = settingsDoc.getItemValueString("FileRepositoryPath")
var savedFile:java.io.File = new java.io.File(repositoryPath + newFileName);
newFile.renameTo(savedFile);
doc.replaceItemValue("File_Size", savedFile.length())
doc.replaceItemValue("Processed_eCR_Template", "");
// Save the new file
if (savedFile.exists()) {
// this is used to retain the icon/appearance of the attachment
// in the document
//doc.replaceItemValue('Attachment', attDoc.getItemValue('Attachment'));
doc.save();
} else {
//requestScope.errorMessage = 'Server file not found';
print('Server file not found');
}
} else {
requestScope.errorMessage = 'No File found';
print('No File found');
}
// this code prevents resubmit of the uploaded file when the user refreshes
// the page
// var curURL = window.location.href;
// var NSFURL = curURL.toLowerCase().split( '.nsf')[0] + '.nsf';
// window.location.href = NSFURL}]]></xp:this.action>
<xp:this.script><![CDATA[//validate fields before submission
var uploadType = document.getElementById("#{id:cbUploadType}").value;
if(uploadType == "Attachment"){
return true;
}else{
var division = document.getElementById("#{id:comboBox1}").value;
if(division == "---"){
alert("Please specify the division.");
return false;
}
if(uploadType == "eCR Master File"){
return true;
}else if(uploadType == "Financial Analysis"){
var faType = document.getElementById("#{id:comboBoxFAType}").value;
if(faType == "---"){
alert("Please specify the Financial Analysis Type.");
return false;
}else{
return true;
}
}
}
//if upload type not rcognized
alert("Upload Type not recognized. Please contact you administrator.");
return false;
]]></xp:this.script>
</xp:eventHandler>
</xp:button>
</xp:panel>
<xp:panel id="panelUploadedFiles">
<xp:viewPanel rows="30" id="viewPanel1" viewStyle="width:100%">
<xp:this.facets>
<xp:pager partialRefresh="true" layout="Previous Group Next"
xp:key="headerPager" id="pager1">
</xp:pager>
</xp:this.facets>
<xp:this.data>
<xp:dominoView var="view1" viewName="Attachments For Web"
keys="#{javascript:@UserName()}" categoryFilter="File_Owner">
</xp:dominoView>
</xp:this.data>
<xp:viewColumn columnName="File_Name" id="viewColumn2">
<xp:viewColumnHeader value="File Name"
id="viewColumnHeader2">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="Date_Uploaded" id="viewColumn3">
<xp:viewColumnHeader value="Date Uploaded"
id="viewColumnHeader3">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="Last_Attached" id="viewColumn4">
<xp:viewColumnHeader value="Last Attached"
id="viewColumnHeader4">
</xp:viewColumnHeader>
</xp:viewColumn>
</xp:viewPanel>
</xp:panel>
</xp:panel>
<xp:br></xp:br>
</xp:view>
The elements that triggers the partial refresh are comboboxes (onchange). The save button is the "Upload" button. The panel panelUploadedFiles contains the view.