I would think this blog post, by Mark Hughes, would no longer be relevant in 9.0.1 FP1 SHF309 and ExtLib version 9.0.1v00_10_20141105-0922. However, I am using the ExtLib dialog control that is 4 panels deep and the only way I can get it to display is with a Full Update. It is always appearing outside the form tags as shown in this screenshot, , and even if I create a CSS class to set the position to absolute and z-index to 950 it won't show with a partial refresh.
The dialog is actually within a custom control, ccSettleAtmConfirmation, towards the bottom of the 'settlementPanel'. I have tried to do a partial refresh of each of the four panels and another partial refresh in the onComplete with no luck. To make things a bit easier this is the SSJS in the button:
try {
sessionScope.infoMsg = "";
//Did you confirm settlement amount?
var now:Date = #Now();
var nineAM:Date = #Date(now.getFullYear(), now.getMonth()+1, now.getDate(), 9, 0, 0) //Runs on the server, which is always in VA (ET)
if(viewScope.settlementOptions == "Initiate Settlement"){
if(now.UTC() <= nineAM.UTC()){
sessionScope.infoMsg = "You cannot initiate settlement of " + atmBean.atmID + " as the current time is prior or equal to 0900 ET";
} else { //SRD FR103072, FR79121
var sttlDialog = getComponent("sttlDlg");
sttlDialog.show();
}
}
} catch (e) {
logInfo("Settlement: " + e.getLocalizedMessage());
sessionScope.infoMsg = "Error trying to open confirmation prompt. Please try again.";
}
Code for the 4 layers of panels which contain the button which shows the dialog.
<xp:panel id="panel1">
<xp:panel id="panel2">
<xp:panel id="panel3">
<xp:panel id="settlementPanel">
<xp:this.rendered><![CDATA[#{javascript:viewScope.operation == "Settlement"}]]></xp:this.rendered>
<xp:table style="width:100%">
<xp:tr>
<xp:td style="width:3%" />
<xp:td style="width:81.0%">
<xp:table style="width:100%">
<xp:tr>
<xp:td style="width:40%" styleClass="home-table-cell">
<xp:label value="Today's Settlement Amount:"
styleClass="home-label" id="label9" />
</xp:td>
<xp:td>
<xp:inputText id="inputText6" style="font-size:12pt;width:8em"
value="#{atmBean.atmTodaySettlementAmt}" styleClass="non-editable clear-on-cancel">
</xp:inputText>
<!-- <xp:message id="message1"></xp:message>-->
</xp:td>
</xp:tr>
<xp:tr>
<xp:td styleClass="home-table-cell" style="width:40%">
<xp:label value="Options for Settlement:"
styleClass="home-label" id="label10" />
</xp:td>
<xp:td style="width:60%">
<script>
$(function()
{$('input.currency-mask').numericInput();});
</script>
<xp:comboBox id="comboBox1"
style="font-family:Calibri;font-size:12pt;width:16em"
styleClass="editable clear-on-cancel" value="#{viewScope.settlementOptions}"
defaultValue="--">
<xp:selectItems id="selectItems2">
<xp:this.value><![CDATA[#{javascript://keywordBean.getReportCombobox();
if(atmBean.atmStatus == "IN PROGRESS") {
//viewScope.put('settlementOptions',#Trim(keywordBean.getVector("SettlementInProgressAtmStatus")));
return #Trim(keywordBean.getVector("SettlementInProgressAtmStatus"));
} else if(atmBean.atmStatus == "OPEN" || atmBean.atmStatus == "CLOSED" || atmBean.atmStatus == "WOUNDED") {
//viewScope.put('settlementOptions',#Trim(keywordBean.getVector("SettlementOpenClosedWoundedAtmStatus")));
return #Trim(keywordBean.getVector("SettlementOpenClosedWoundedAtmStatus"));
} else if(atmBean.atmStatus == "MASS CLOSEOUT IN PROGRESS") {
//viewScope.put('settlementOptions',#Trim(keywordBean.getVector("SettlementMassCloseoutInProgressAtmStatus")));
return #Trim(keywordBean.getVector("SettlementMassCloseoutInProgressAtmStatus"));
}
return #Trim(keywordBean.getVector("SettlementOptions"));}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="settlementPanel">
<xp:this.onComplete><![CDATA[XSP.partialRefreshPost("#{id:infoMessagePanel}",{onStart:null,onError:null,onComplete:null});]]></xp:this.onComplete>
</xp:eventHandler>
</xp:comboBox>
</xp:td>
</xp:tr>
<xp:tr>
<xp:this.rendered><![CDATA[#{javascript:var currDt:java.util.Date = new java.util.Date();
var busDt:java.util.Date = atmBean.atmBusinessDate;
if(atmBean.atmStatus == "OPEN" || atmBean.atmStatus == "CLOSED" || atmBean.atmStatus == "WOUNDED") {
if(viewScope.get('settlementOptions') == "Initiate Settlement") {
if(#Date(currDt).equals(#Date(busDt))) {
return true;
} else {
// sessionScope.infoMsg = "The Settlement function cannot be performed on this ATM because " + atmBean.atmID + "'s Business Date is greater than the current date";
// return false;
return true;
}
}
}}]]></xp:this.rendered>
<xp:td
styleClass="home-table-cell" style="width:40%">
<xp:label
value="Is the Settlement Amount correct?"
styleClass="home-label" id="label11" />
</xp:td>
<xp:td style="width:60%">
<xp:radioGroup
id="radioGroup2" style="font-family:Calibri;font-size:12pt"
value="#{viewScope.settlementCorrectYN}"
styleClass="clear-on-cancel">
<xp:selectItem
itemLabel="Yes" itemValue="Y" id="selectItem6" />
<xp:selectItem
itemLabel="No" itemValue="N" id="selectItem7" />
<xp:eventHandler
event="onclick" submit="true" refreshMode="partial"
refreshId="settlementPanel" id="eventHandler4">
<xp:this.script><![CDATA[$(".amtRec").val(""); //works in IE
//$(".amtRec").text(""); //works in Chrome ???
//this is needed because of the way that the jQuery plugin works]]></xp:this.script>
<xp:this.onComplete><![CDATA[$(".amtRec").numericInput();]]></xp:this.onComplete>
<xp:this.action><![CDATA[#{javascript:atmBean.atmAmountReceived = null;
/*
if(viewScope.settlementCorrectYN == "N"){
atmBean.atmAmountReceived = null;
}
*/}]]></xp:this.action>
</xp:eventHandler>
</xp:radioGroup>
</xp:td>
</xp:tr>
<xp:tr>
<xp:this.rendered><![CDATA[#{javascript:if(viewScope.get('settlementCorrectYN') == 'N') {
return true;
} else {
return false;
}}]]></xp:this.rendered>
<xp:td styleClass="home-table-cell" style="width:40%">
<xp:label value="Amount Received:" styleClass="home-label"
id="label12" />
</xp:td>
<xp:td style="width:60%">
<xp:inputText id="atmAmtRcvd" value="#{atmBean.atmAmountReceived}"
style="font-size:12pt">
<xp:this.disabled><![CDATA[#{javascript:/*
if(viewScope.settlementCorrectYN == "N"){
return false;
} else {
return true;
}
*/}]]></xp:this.disabled>
<xp:this.styleClass><![CDATA[#{javascript:if(viewScope.settlementCorrectYN == "N"){
return "editable currency-mask clear-on-cancel amtRec";
} else {
return "unavailable clear-on-cancel";
}}]]></xp:this.styleClass>
<xp:eventHandler event="onkeypress" submit="false">
<xp:this.script><![CDATA[/*
48 - 57: 0-9
8: backspace
9: horizontal tab
35: end
36: home
37: left arrow
39: right arrow
46: delete
var keyCode = event.keyCode;
if((keyCode >= 48 && keyCode <= 57) ||keyCode == 8 || keyCode == 9 || keyCode == 35 || keyCode == 36 || keyCode == 37 || keyCode == 39 || keyCode == 46){
event.returnValue = true;
}else{
event.returnValue = false;
}
*/]]></xp:this.script>
</xp:eventHandler>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="settlementPanel">
</xp:eventHandler>
</xp:inputText>
<!-- <xp:message id="message1"></xp:message>-->
</xp:td>
</xp:tr>
<xp:tr>
<xp:td style="width:40%" styleClass="home-table-cell">
<xp:label value="Comments (Optional):" styleClass="home-label"
id="label8" />
</xp:td>
<xp:td style="width:60%;padding-top:1.0em">
<xp:inputTextarea id="inputTextarea3" style="height:4em;width:25em"
value="#{atmBean.commentsSettle}" styleClass="clear-on-cancel" />
</xp:td>
</xp:tr>
<xp:tr>
<xp:this.rendered><![CDATA[#{javascript:if(atmBean.atmStatus == "WOUNDED"){
return true;
} else {
return false;
}}]]></xp:this.rendered>
<xp:td styleClass="home-table-cell" style="width:40%">
<xp:label value="Wounded Updates:" styleClass="home-label"
id="label13" />
</xp:td>
<xp:td style="width:60%">
<xp:inputTextarea id="inputTextarea4" style="height:4em;width:25em"
value="#{atmBean.woundedUpdates}" styleClass="clear-on-cancel" />
</xp:td>
</xp:tr>
<xp:tr>
<xp:td colspan="2" styleClass="home-table-cell" align="center"
valign="middle">
**<xp:button
value="Settle ATM" id="button14" style="font-size:11pt">
<xp:this.disabled><![CDATA[#{javascript:var hol:java.util.ArrayList = keywordBean.getString("holidaysBlast");
var currDt:Date = #Today();
var sdf:java.text.SimpleDateFormat = new java.text.SimpleDateFormat("MM/dd/yyyy");
if(#Contains(hol,sdf.format(currDt))) {
return true;
} else if(viewScope.settlementOptions == "--" || viewScope.settlementOptions == null) {
return true;
} else if(viewScope.settlementOptions == "Initiate Settlement") {
if(viewScope.settlementCorrectYN == null || (viewScope.settlementCorrectYN == "N" & getComponent("atmAmtRcvd").getValue() == null)) {
return true;
}
} else if(viewScope.settlementOptions == "No Settlement Process Allowed") {
return true;
}
return false}]]></xp:this.disabled>
<xp:eventHandler
event="onclick" submit="true" id="eventHandler5"
refreshMode="complete">
<xp:this.script><![CDATA[//XSP.openDialog("#{id:sttlDlg}");
/*
var deferred = atmRPC.settleAtmConfirmation();
deferred.addCallback(function(result){
if (result == "false") {
XSP.partialRefreshGet("#{id:infoMessagePanel}",{onStart:null,onError:null,onComplete:null});
} else if(result == "true"){
XSP.partialRefreshGet("#{id:infoMessagePanel}",{onStart:null,onError:null,onComplete:null});
XSP.openDialog("#{id:sttlDlg}");
}
})
*/]]></xp:this.script>
<!--
<xp:this.onComplete><![CDATA[XSP.partialRefreshPost("#{id:infoMessagePanel}",
{ onStart:null, onError:null, onComplete:
null});]]></xp:this.onComplete>
-->
<xp:this.action><![CDATA[#{javascript:try {
sessionScope.infoMsg = "";
//Did you confirm settlement amount?
var now:Date = #Now();
var nineAM:Date = #Date(now.getFullYear(), now.getMonth()+1, now.getDate(), 9, 0, 0) //Runs on the server, which is always in VA (ET)
if(viewScope.settlementOptions == "Initiate Settlement"){
if(now.UTC() <= nineAM.UTC()){
sessionScope.infoMsg = "You cannot initiate settlement of " + atmBean.atmID + " as the current time is prior or equal to 0900 ET";
} else { //SRD FR103072, FR79121
var sttlDialog = getComponent("sttlDlg");
sttlDialog.show();
}
}
} catch (e) {
logInfo("Settlement: " + e.getLocalizedMessage());
sessionScope.infoMsg = "Error trying to open confirmation prompt. Please try again.";
}}]]></xp:this.action>
<xp:this.onComplete><![CDATA[XSP.partialRefreshGet("#{id:infoMessagePanel}",{onStart:null,onError:null,onComplete:null});]]></xp:this.onComplete>
</xp:eventHandler>
</xp:button>**
<xp:button value="Cancel" id="button11" style="font-size:11pt">
<xp:eventHandler
event="onclick" submit="true" refreshMode="partial"
refreshId="fullPage" id="eventHandler7" immediate="false"
save="false">
<xp:this.action><![CDATA[#{javascript://updates may need to be made in the 'Yes' and 'No' button of the 'sttlDlg'
//id
atmBean.clearATMStatus();
atmBean.atmID = null;
atmBean.atmTodaySettlementAmt = null;
atmBean.atmAmountReceived = null;
atmBean.commentsSettle = null;
atmBean.woundedUpdates = null;
sessionScope.put('atmID',null);
viewScope.put('operation',null);
viewScope.put('settlementOptions',null);
viewScope.put('settlementCorrectYN',null);
viewScope.put('javaErrCode',null);
viewScope.put('javaErrMsg',null);
sessionScope.put('infoMsg', null)}]]></xp:this.action>
<xp:this.script><![CDATA[$(".clear-on-cancel").val("");
//this is needed because of the way that the jQuery plugin works]]></xp:this.script>
<xp:this.onComplete><![CDATA[XSP.partialRefreshPost("#{id:infoMessagePanel}",{onStart:null,onError:null,onComplete:null});]]></xp:this.onComplete>
</xp:eventHandler>
</xp:button>
</xp:td>
</xp:tr>
**<xp:tr>
<xp:td colspan="2">
<xc:ccSettleAtmConfirmation id="sttlAtmConfirm"></xc:ccSettleAtmConfirmation>
</xp:td>
</xp:tr>**
</xp:table>
</xp:td>
<xp:td style="width:25%" />
</xp:tr>
</xp:table>
</xp:panel>
</xp:panel>
</xp:panel>
</xp:panel>
No problem here opening xe:dialog id="dialog1" via ssjs with a partial update of a panel containing my xe:dialog ...
<xp:button value="Open dialog" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="panelAll">
<xp:this.action><![CDATA[#{javascript:getComponent("dialog1").show();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
Related
I have an value picker in a dialog box. The user selects a value and that value is entered into an Edit Box, which is bound to a scope variable. So far so good.
I then have a button where I want to ask the access the value that is in the edit box.
I have tried using
var satLoc:String = viewScope.get("selLoc");
var satLoc:String = getComponent("selLoc").getValue();
neither of which works - I just get null.
My code is below. I would appreciate some help.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:button id="button15" style="font-weight:bold;font-size:8pt" value="Load Satellite Dialog">
<xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="dialogAddSat">
<xp:this.action><![CDATA[#{javascript:var d = getComponent('dialogAddSat')d.show()}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xe:dialog id="dialogAddSat" style="width:300px">
<xe:this.title><![CDATA[#{javascript:"Make This Location A Hub"}]]></xe:this.title>
<xe:dialogButtonBar>
<xp:table id="tblCrd" style="width:99.0%">
<xp:tr>
<xp:td>
<xp:label id="label24" for="region" value="Hub Location Number" />
</xp:td>
<xp:td>
<xe:djTextBox id="djTextBox2"
style="width:35px;text-align:right">
<xe:this.dojoAttributes>
<xp:dojoAttribute name="readOnly"
value="true">
</xp:dojoAttribute>
</xe:this.dojoAttributes>
<xe:this.value><![CDATA[#{javascript:"0002"}]]></xe:this.value><xp:eventHandler event="onChange"
submit="true" refreshMode="partial" refreshId="tblCrd">
</xp:eventHandler>
</xe:djTextBox>
</xp:td>
<xp:td style="text-align:right">
<xp:button id="button13" value="Attach Satellite">
<xp:eventHandler event="onclick"
submit="true" refreshMode="complete" id="eventHandler7"
disableValidators="true">
<xp:this.script><![CDATA[XSP.closeDialog('#{id:dialogMakeHub}');]]></xp:this.script>
<xp:this.action>
<xp:actionGroup>
<xp:confirm>
<xp:this.message><![CDATA[#{javascript:try {
var satLoc:String = viewScope.get("selLoc");
//var satLoc:String = getComponent("selLoc").getValue();
var hubLoc = "0002";
//var hubLoc:String = document1.getDocument().getItemValueString("locNum");
return "Make Location " + satLoc + " a Satellite for Location Number " + hubLoc
} catch(e){
return e;
}
}]]></xp:this.message>
</xp:confirm>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:print ("Here")}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button></xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label id="label25" for="region" value="Select Location..." />
</xp:td><xp:td>
<xp:inputText id="selLoc" value="#{viewScope.selLoc}"></xp:inputText>
<xe:valuePicker id="valuePicker77"
dialogTitle="Choose A Location To Add As A Satellite"
pickerIcon="/picker.png" for="selLoc">
<xe:this.dataProvider>
<xe:simpleValuePicker>
<xe:this.valueList><![CDATA[#{javascript:import xpUtilities
var tmpLocView:NotesView = database.getView("(DbLocsOperActiveLOnly)");
var arr = new Array();
var tmpLocNum:String;
var hubLocNum:String;
//hubLocNum = padToFour(document1.getDocument().getItemValueString("locNum"));
hubLocNum = "0002;"
//arr[0] = hublocNum
var tmpLocDoc:NotesDocument = tmpLocView.getFirstDocument();
while (tmpLocDoc != null) {
tmpLocNum = tmpLocDoc.getItemValueString("locNum");
if (tmpLocNum != hubLocNum)
{arr.push(tmpLocDoc.getItemValueString("locNum"));}
var tmpdoc = tmpLocView.getNextDocument(tmpLocDoc);
tmpLocDoc.recycle();
tmpLocDoc = tmpdoc;
}
return arr
}]]></xe:this.valueList>
</xe:simpleValuePicker>
</xe:this.dataProvider>
</xe:valuePicker></xp:td>
<xp:td style="text-align:right">
<xp:button value="Cancel" id="button10">
<xp:eventHandler event="onclick"
submit="true" refreshMode="complete" id="eventHandler4">
<xp:this.script><![CDATA[XSP.closeDialog('#{id:dialogAddSat}')]]></xp:this.script>
</xp:eventHandler>
</xp:button></xp:td>
</xp:tr>
<xp:tr>
<xp:td>
</xp:td>
<xp:td>
</xp:td>
<xp:td style="text-align:right">
</xp:td>
</xp:tr>
</xp:table>
</xe:dialogButtonBar>
</xe:dialog>
</xp:view>
I have found a solution. I had an action group with a Confirmation Action. I was trying to get the value in the confirmation action. For some reason, it doesn't work there. I just ignore it in the confirmation action and now it work.
The problem is about the timing. On the following code, you compute a confirmation text. But this is being computed at the server side, when it's being rendered. At the time of rendering, the viewScope variable is empty.
<xp:button
id="button13"
value="Attach Satellite">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete"
id="eventHandler7"
disableValidators="true">
<xp:this.script><![CDATA[XSP.closeDialog('#{id:dialogMakeHub}');]]></xp:this.script>
<xp:this.action>
<xp:actionGroup>
<xp:confirm>
<xp:this.message><![CDATA[#{javascript:try {
var satLoc:String = viewScope.get("selLoc");
//var satLoc:String = getComponent("selLoc").getValue();
var hubLoc = "0002";
//var hubLoc:String = document1.getDocument().getItemValueString("locNum");
return "Make Location " + satLoc + " a Satellite for Location Number " + hubLoc
} catch(e){
return e;
}}]]>
</xp:this.message>
</xp:confirm>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:print ("Here")}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
If you refresh the button component when the input value changes, it will show the correct value. However, I'd prefer computing the value of the confirmation on the client side, in the script attribute. Closing dialog should be the final action (if the user does not confirm the value, it shouldn't be closed. Here is the modified version.
<xp:button
id="button13"
value="Attach Satellite">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete"
id="eventHandler7"
onComplete="XSP.closeDialog('#{id:dialogAddSat}');"
disableValidators="true">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:print ("Here")}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:this.action>
<xp:this.script><![CDATA[return confirm("Location will be set "+dojo.byId('#{id:selLoc}').value+". Confirm?")]]></xp:this.script>
</xp:eventHandler>
</xp:button>
I have the following dialog, the password field focus is set when the dialog has focus but this only works when first loaded, I want to set the password field focus when the passwords don't match (i.e. after clicking the OK button and running the SSJS).
<xe:dialog id="dialogConfirmPassword" title="Confirm Your Password">
<xe:dialogContent id="dialogConfirmPasswordContent">
<xp:messages id="messagesConfirmPassword" layout="table" />
<xp:table style="width:100%" id="tableConfirmPassword">
<xp:tr>
<xp:td>
<xp:label value="Password" id="lblPassword"
for="confirmPassword" />
</xp:td>
<xp:td>
<xp:inputText id="confirmPassword"
password="true">
</xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
</xe:dialogContent>
<xe:dialogButtonBar id="dialogButtonBarConfirmPassword">
<xp:button value="OK" id="btnConfirmPasswordOk">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:try{
var confirmPassword:String = getComponent("confirmPassword").getValueAsString();
if (session.verifyPassword(confirmPassword, HTTPPassword)){
/* RUNS NOTES AGENT */
getComponent('dialogConfirmPassword').hide();
return true;
} else {
facesContext.addMessage("messagesConfirmPassword", new javax.faces.application.FacesMessage("You have entered an incorrect password, please try again.") );
/* WANT TO SET FOCUS FOR PASSWORD FIELD */
return false;
}
} catch (e) {
facesContext.addMessage("messagesConfirmPassword", new javax.faces.application.FacesMessage("ERROR! " + e.toString()) )
return false;
}}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
</xe:dialogButtonBar>
<xp:eventHandler event="onFocus" submit="false">
<xe:this.script><![CDATA[dijit.byId("dialogConfirmPassword").focus();]]></xe:this.script>
</xp:eventHandler>
</xe:dialog>
Can I set the password field focus after setting the facesContext.addMessage or another way?
Update: The following output script worked:
<xp:scriptBlock id="scriptBlockConfirmPassword">
<xp:this.value><![CDATA[#{javascript: if(viewScope.PWDSuccess === null) {
return "";
};
var result = "dojo.byId(\"";
result += getComponent("confirmPassword").getClientId(facesContext);
result += "\").focus();";
return result;}]]></xp:this.value>
</xp:scriptBlock>
A few pointers:
Don't go after components like getComponent("confirmPassword") but bind your component to a scope variable, makes better code
You can't directly run a Client JavaScript action in your SSJS (where you indicated)
Your event handler never works since the XPages ID is different from the clientside ID
A outputscript probably can solve your challenge
So modify your code (only essentials here):
<xp:inputText id="confirmPassword" password="true" value="#{viewScope.confirmPWD}">
</xp:inputText>
<xp:button value="OK" id="btnConfirmPasswordOk">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:try{
viewScope.PWDSuccess = session.verifyPassword(viewScope.confirmPWD, HTTPPassword);
if (viewScope.PWDSuccess){
/* RUNS NOTES AGENT */
getComponent('dialogConfirmPassword').hide();
} else {
facesContext.addMessage("messagesConfirmPassword", new javax.faces.application.FacesMessage("You have entered an incorrect password, please try again.") );
}
} catch (e) {
facesContext.addMessage("messagesConfirmPassword", new javax.faces.application.FacesMessage("ERROR! " + e.toString()) );
viewScope.PWDSuccess = false;
}
return viewScope.PWDSuccess
}]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:outputScript>
<this.value><!CDATA[#{javascript:if(viewScope.PWDSuccess) {return "";};
var result = "dijit.byId(\"";
result += getComponent("confirmPassword").getClientId();
result += "\").focus();";
return result;
}]]</this.value>
</xp:outputScript>
(Typed off my head - will contain errors).
Let us know how it goes.
The following save button code works well on mobile xpage:
var checkBox31:com.ibm.xsp.component.xp.XspInputCheckbox = getComponent("checkBox31");
var customerID1:com.ibm.xsp.component.xp.XspInputText = getComponent("customerID1");
var a = checkBox31.getValue();
var b = customerID1.getValue()
if (a == "" || a == null){
if (b == ""){
sessionScope.put("ITDialog","You must enter Customer ID");
var dialog1:com.ibm.xsp.extlib.component.dialog.UIDialog = getComponent("dialog1");
dialog1.show();
}
}
But it does not work on web xpage. I'm using 8.5.3FP6. I used 8.5.3FP1 and 8.5.3FP5 bu had same issue.
Thanks in advance for any help.
Here is sample of code which is not working.
]]></xp:this.script>
</xp:executeClientScript>
</xp:this.script>
</xp:eventHandler>
</xp:button>
</xp:panel>
</xe:dialog>
</xp:panel>
<xp:table>
<xp:tr>
<xp:td style="background-color:rgb(226,226,226)">
<xp:label
value="Company:"
id="company_Label1"
for="company1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText
value="#{document1.Company}"
id="company1">
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td style="background-color:rgb(226,226,226)">
<xp:label
value="Address:"
id="address_Label1"
for="address1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText
value="#{document1.Address}"
id="address1">
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td style="background-color:rgb(226,226,226)">
<xp:label
value="Contact person:"
id="contactPerson_Label1"
for="contactPerson1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText
value="#{document1.ContactPerson}"
id="contactPerson1">
</xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
</xp:panel>
</xp:view>
A checkbox has a value of either 'false' or 'true' (indicating it is 'deselected' & 'selected'), it shouldn't return a value of "" or null. Therefore, the first if statement is never true, and your dialog will never appear.
I believe what you want is that if the checkbox is unselected, there must be a customer ID entered in the input. If so, I think this is the code you want:
var checkBox31:com.ibm.xsp.component.xp.XspInputCheckbox = getComponent("checkBox31");
var customerID1:com.ibm.xsp.component.xp.XspInputText = getComponent("customerID1");
var a = checkBox31.getValue();
var b = customerID1.getValue();
if (a == "false") {
if (b == "") {
sessionScope.put("ITDialog","You must enter Customer ID");
var dialog1:com.ibm.xsp.extlib.component.dialog.UIDialog = getComponent("dialog1");
dialog1.show();
}
}
I am working on this functionality where-in I need to provide the user with a list of documents and provide an option for the user to change/add values to a field(s) inside these documents. I was going through this example Xpages - Display filtered Document Collection in a repeat control and did a similar implementation and got it to work. So what I have now is a panel inside a repeat which has its data source set with the form and document id set to return the value in the repeat control variable (which is the document UNID from the document collection), thus I am able to bind fields directly to these documents using the data source defined in the panel. The challenge is that I want to get the handle to these documents to set a particular value in them and also save the values in the fields that I bind to the back-end document. Is there any way I can access the documents from outside the repeat control (let say on the click of a button)? Following is my code for the repeat:
<xp:repeat id="rptApprDocuments" rows="30" var="apprDoc"
indexVar="docIndex" first="0">
<xp:this.value><![CDATA[#{javascript:// Look up the employee details view to get the employee appraisal details from the current database
var curDB:NotesDatabase = session.getCurrentDatabase();
var vwlkApprView:NotesView = curDB.getView("vwlkApprAllFGCompAppr");
var collDocAppr:NotesDocumentCollection = vwlkApprView.getAllDocumentsByKey(sessionScope.key);
var apprDocCount = collDocAppr.getCount();
if(apprDocCount != 0){
var docAppr:NotesDocument;
var docUNIDArray = new Array();
for(i=0;i<apprDocCount;i++){
docAppr = collDocAppr.getNthDocument(i+1);
//print(docAppr.getUniversalID());
docUNIDArray.push(docAppr.getUniversalID());
}
viewScope.put("docUNIDArray",docUNIDArray);
return docUNIDArray;
/*return collDocAppr;
/return sortColByItemName(collDocAppr, "AppraiseeCWLCluster");*/
}
return null;
]]></xp:this.value>
<xp:panel id="pnlRR">
<xp:this.data>
<xp:dominoDocument formName="frmAppraisal" var="appraisalDoc"
action="editDocument" ignoreRequestParams="true">
<xp:this.postSaveDocument><![CDATA[#{javascript:if(requestScope.SubmitRR == true){
appraisalDoc.setValue("ApperRRStatus","1");
appraisalDoc.save();
}}]]></xp:this.postSaveDocument>
<xp:this.documentId><![CDATA[#{javascript://apprDoc.getUniversalID();
return apprDoc;}]]></xp:this.documentId>
</xp:dominoDocument>
</xp:this.data>
<xp:tr>
<xp:td styleClass="tdCls" style="width:2%">
<xp:label id="SrNo">
<xp:this.value><![CDATA[#{javascript:var index = parseInt(docIndex)
index = index + 1;
index.toString();}]]></xp:this.value>
</xp:label>
</xp:td>
<xp:td styleClass="tdCls" style="width:20.0%">
<xp:label id="ApeName">
<xp:this.value><![CDATA[#{javascript://return apprDoc.getItemValueString("AppraiseeName");
return appraisalDoc.getItemValueString("AppraiseeName");}]]></xp:this.value>
</xp:label>
</xp:td>
<xp:td styleClass="tdCls" style="width:8.0%">
<xp:label id="ApeGrade">
<xp:this.value><![CDATA[#{javascript://return apprDoc.getItemValueString("Appraisee_Grade");
return appraisalDoc.getItemValueString("Appraisee_Grade");}]]></xp:this.value>
</xp:label>
</xp:td>
<xp:td styleClass="tdCls" style="width:15.0%">
<xp:div style="text-align:center">
<xp:label id="appeTotImpRate"
style="font-size:10pt;color:rgb(255,0,0);font-weight:bold">
<xp:this.value><![CDATA[#{javascript://return apprDoc.getItemValueDouble("AppeTotImpRate").toFixed(2);
return appraisalDoc.getItemValueDouble("AppeTotImpRate").toFixed(2);}]]></xp:this.value>
</xp:label>
</xp:div>
</xp:td>
<xp:td styleClass="tdCls" style="width:15.0%">
<xp:div style="text-align:center">
<xp:label id="apprTotImpRate"
style="color:rgb(255,0,0);font-size:10pt;font-weight:bold">
<xp:this.value><![CDATA[#{javascript://return apprDoc.getItemValueDouble("ApprTotImpRate").toFixed(2);
return appraisalDoc.getItemValueDouble("ApprTotImpRate").toFixed(2);}]]></xp:this.value>
</xp:label>
</xp:div>
</xp:td>
<xp:td styleClass="tdCls" style="width:15.0%">
<xp:div style="text-align:center">
<xp:label id="revTotImpRate"
style="font-size:10pt;color:rgb(255,0,0);font-weight:bold">
<xp:this.value><![CDATA[#{javascript://return apprDoc.getItemValueDouble("RevTotImpRate").toFixed(2);
return appraisalDoc.getItemValueDouble("RevTotImpRate").toFixed(2);}]]></xp:this.value>
</xp:label>
</xp:div>
</xp:td>
<xp:td styleClass="tdCls" style="width:12.0%">
<xp:div
style="font-size:10pt;color:rgb(255,0,0);font-weight:bold;text-align:center">
<xp:comboBox id="apprGrades" style="width:50.0px"
disableClientSideValidation="true" value="#{appraisalDoc.ApperFinalGrade}"
readonly="true">
<xp:selectItem itemLabel="-" itemValue=""
id="selectItem1">
</xp:selectItem>
<xp:selectItem itemLabel="1" itemValue="1"
id="selectItem2">
</xp:selectItem>
<xp:selectItem itemLabel="2" itemValue="2"
id="selectItem3">
</xp:selectItem>
<xp:selectItem itemLabel="3" itemValue="3"
id="selectItem4">
</xp:selectItem>
<xp:selectItem itemLabel="4" itemValue="4"
id="selectItem5">
</xp:selectItem>
<xp:selectItem itemLabel="5" itemValue="5"
id="selectItem6">
</xp:selectItem>
</xp:comboBox>
</xp:div>
</xp:td>
<xp:td styleClass="tdCls" style="width:12.0%">
<xp:div
style="font-size:10pt;color:rgb(255,0,0);font-weight:bold;text-align:center">
<xp:comboBox id="ApperRelativeRank" style="width:50.0px"
disableClientSideValidation="true" value="#{appraisalDoc.ApperRelativeRank}">
<xp:this.readonly><![CDATA[#{javascript:/*if(compositeData.UserRole == "Appraiser"){
return true;
}
if(parseInt(appraisalDoc.getValue("CurrFGRRStatus")) >= parseInt(compositeData.compStatus)){
return true;
}*/
return false;}]]></xp:this.readonly>
<xp:this.rendered><![CDATA[#{javascript:/*if(compositeData.UserRole == "Appraiser"){
return false;
}*/
return true;}]]></xp:this.rendered>
<xp:selectItem itemLabel="-" itemValue=""
id="selectItem13">
</xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:// Look up the employee details view to get the employee appraisal details from the current database
var curDB:NotesDatabase = session.getCurrentDatabase();
var vwlkApprView:NotesView = curDB.getView("vwlkCWLApprAllFGCompAppr");
var cwlCluster = appraisalDoc.getItemValueString("AppraiseeCWLCluster");
var collEntAppr:NotesViewEntryCollection = vwlkApprView.getAllEntriesByKey(sessionScope.key + cwlCluster);
var entCount = collEntAppr.getCount()
if(entCount != 0){
var ranks = new Array();
var rankValue, rankLabel;
for(i=0;i<entCount;i++){
rankValue = i + 1;
rankLabel = rankValue + "/" + entCount;
ranks.push(rankLabel + "|" + rankValue);
}
return ranks;
}
return null;}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xp:div>
</xp:td>
</xp:tr>
</xp:panel>
</xp:repeat>
You can access the data sources of a panel, see http://xpageswiki.com/web/youatnotes/wiki-xpages.nsf/dx/Work_with_datasources#Reset+%2F+clear+a+datasource for example code.
But that solves only half of the problem, you need a handle to each panel inside the repeater.
You can find an XPages API browser on openNTF (I don't know the exact name at the moment). Taking this, you can examine the repeat's control at runtime and check for methods and properties. I bet there is something to get components that are inside the repeater.
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.
You need to post sample code, as there is no way to diagnose your issue from your initial question.
I would recommend to take the "XPages MasterClass" training. It is roughly about four hours. It will show you how to use the XPages Toolbox, which you can use to debug these kinds of issues.