I am using a viewpanel and allowing users to choose documents via a checkbox in a "choose" panel.
The document source is defined in the "view/edit" panel.
- When they reach the last document the "view/edit" panel disappears and the "choose" panel appears.
All of the above works.
I have navigation button at the top which opens the "view/edit" panel. If the user puts a document in edit mode and decides (for whatever reason) that they want to use the navigation button to return to the "choose" panel and then chooses a new batch of documents to view or edit and the document that was in edit mode is the first document to be viewed - it will still be in edit mode.
- I have tried using the javascript command: context.setDocumentMode("readonly") in many different places (before calculating the document, in afterRestoreView, in the navigation button) to no effect.
I hope there is an obvious solution.
Here is a code simplified code snippet to demonstrate the problem. All you need is to plugin your own datasource:>)
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
>
<xp:panel id="buttonpanel">
<xp:button id="button1" value="Choose Docs">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="wrapperpanel">
<xp:this.action><![CDATA[#{javascript:viewScope.choosepanelvis= true;
viewScope.vieweditpanelvis = false;}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:panel>
<xp:panel id="wrapperpanel">
<xp:panel id="choosepanel" rendered="#{javascript:viewScope.choosepanelvis}">
<xp:label id="label1"></xp:label>
<xp:button styleClass="BlueButton" id="button6"
value="View/Edit Selected Docs">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="wrapperpanel">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:viewScope.DocIdList = new Array();
var viewPanel = getComponent("viewPanel1");
var docIDList = viewPanel.getSelectedIds();
viewScope.DocIdList = docIDList;
viewScope.DocIdLength = viewScope.DocIdList.length;}]]></xp:this.script>
</xp:executeScript>
<xp:actionGroup condition="#{javascript:viewScope.DocIdList.length === 0;}">
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:var varAlert = "Please select one or more documents.";
var al = "alert('"+ varAlert +"')";
view.postScript(al);
return false;
}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
<xp:actionGroup>
<xp:this.condition><![CDATA[#{javascript:viewScope.DocIdList.length > 0}]]></xp:this.condition>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:viewScope.DocIdIndex = 0
var DocId=viewScope.DocIdList[viewScope.DocIdIndex];
viewScope.DocId = DocId;
viewScope.choosepanelvis= false;
viewScope.vieweditpanelvis = true;}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:viewPanel rows="30" id="viewPanel1">
<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="NISDTeacher">
</xp:dominoView>
</xp:this.data>
<xp:viewColumn columnName="CampusName" id="viewColumn1"
showCheckbox="true">
<xp:viewColumnHeader value="CampusName" id="viewColumnHeader1"
showCheckbox="true">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="TeacherFirst" id="viewColumn2">
<xp:viewColumnHeader value="TeacherFirst" id="viewColumnHeader2">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="TeacherLast" id="viewColumn3">
<xp:viewColumnHeader value="TeacherLast" id="viewColumnHeader3">
</xp:viewColumnHeader>
</xp:viewColumn>
</xp:viewPanel>
</xp:panel>
<xp:panel id="vieweditpanel" rendered="#{javascript:viewScope.vieweditpanelvis}">
<xp:this.data>
<xp:dominoDocument var="document1" action="openDocument"
formName="CoopInfo" documentId="#{javascript:viewScope.DocId}"
ignoreRequestParams="true">
</xp:dominoDocument>
</xp:this.data>
<xp:text escape="true" id="computedField1" value="#{document1.TeacherFirst}"></xp:text>
<xp:text escape="true" id="computedField2" value="#{document1.TeacherLast}"></xp:text>
<xp:text escape="true" id="computedField3" value="#{document1.CampusName}"></xp:text>
<xp:br></xp:br>
<xp:inputTextarea id="inputTextarea1" value="#{document1.Comments}"></xp:inputTextarea>
<xp:button id="button2" styleClass="BlueButton" value="View Next Doc">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" id="eventHandler5" refreshId="wrapperpanel">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript script="#{javascript:viewScope.DocIdIndex++;}">
</xp:executeScript>
<xp:actionGroup>
<xp:this.condition><![CDATA[#{javascript:viewScope.DocIdIndex >= viewScope.DocIdLength}]]></xp:this.condition>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:viewScope.DocIdList = new Array();
viewScope.choosepanelvis= true;
viewScope.vieweditpanelvis = false;}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
<xp:actionGroup>
<xp:this.condition><![CDATA[#{javascript:viewScope.DocIdIndex < viewScope.DocIdLength}]]></xp:this.condition>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:var DocId=viewScope.DocIdList[viewScope.DocIdIndex];
viewScope.DocId = DocId;}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button id="button3" styleClass="BlueButton" value="Edit This Record">
<xp:this.rendered><![CDATA[#{javascript:if (document1.isEditable()) {
return false;
} else {
return true;
}}]]></xp:this.rendered>
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" id="eventHandler8" refreshId="wrapperpanel">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:context.setDocumentMode("document1","edit");}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button id="button11" styleClass="BlueButton"
value="Save Doc and View Next Record">
<xp:this.rendered><![CDATA[#{javascript:if (document1.isEditable()) {
return true;
} else {
return false;
}}]]></xp:this.rendered>
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" id="eventHandler7" refreshId="wrapperpanel">
<xp:this.script><![CDATA[var choice = null;
var comment = null;
for (var i=0; i<document.forms[0].elements.length; i++) {
if (document.forms[0].elements[i].name === "#{id:RadioG2}") {
if (document.forms[0].elements[i].checked === true) {
choice = document.forms[0].elements[i].value;
}
}
}
if (choice === "0") {
for (var i=0; i<document.forms[0].elements.length; i++) {
if (document.forms[0].elements[i].name === "#{id:Comments2}") {
comment = document.forms[0].elements[i].value;
}
}
}
if (comment === "" && choice === "0") {
alert("You must enter a comment if you are not going to recommend a teacher.");
return false;
}
]]></xp:this.script>
<xp:this.action>
<xp:actionGroup>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:var radioGroup1:com.ibm.xsp.component.xp.XspSelectOneRadio = getComponent("radioGroup1").getValue();
document1.replaceItemValue("RatingNum",radioGroup1);
var inputTextarea1:com.ibm.xsp.component.xp.XspInputTextarea = getComponent("inputTextarea1").getValue();
document1.replaceItemValue("Comments",inputTextarea1);
database.updateFTIndex(false);
viewScope.DocIdIndex++;
}]]></xp:this.script>
</xp:executeScript>
<xp:actionGroup>
<xp:this.condition><![CDATA[#{javascript:viewScope.DocIdIndex >= viewScope.DocIdLength}]]></xp:this.condition>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:viewScope.DocIdList = new Array();
viewScope.choosepanelvis= true;
viewScope.vieweditpanelvis = false;}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
<xp:actionGroup>
<xp:this.condition><![CDATA[#{javascript:viewScope.DocIdIndex < viewScope.DocIdLength}]]></xp:this.condition>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:var DocId=viewScope.DocIdList[viewScope.DocIdIndex];
viewScope.DocId = DocId;
}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:radioGroup id="radioGroup1" value="#{document1.RatingNum}">
<xp:selectItem itemLabel="Highly Recommended"
itemValue="0">
</xp:selectItem>
<xp:selectItem itemLabel="Recommended" itemValue="1"></xp:selectItem>
<xp:selectItem itemLabel="Not Recommended" itemValue="2"></xp:selectItem>
</xp:radioGroup>
</xp:panel>
</xp:panel>
</xp:view>