I have an Extension Library Dialog Control on my XPage that is opened through a button:
XSP.openDialog("#{id:commentsDialog}");
On my XPage, I have a document source, called document1. When I put those fields (drag and drop from Data Palette) on the dialog control, the field (docID) exists, but is not editable -- looks computed for display:
<xe:dialog id="commentsDialog" title="Comments" styleClass="dialogBoxComments">
<xp:panel>
<xp:table style="width:100%">
<xp:tr>
<xp:td>
<xp:label value="Enter your comments..." id="label2"></xp:label>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:inputTextarea id="comments" style="width:100%;height:100px">
</xp:inputTextarea>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:div style="text-align:right">
<xp:button value="Submit" id="submitButton">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:saveComments();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button id="cancelButton" value="Cancel">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[XSP.closeDialog("#{id:commentsDialog}");]]></xp:this.script>
</xp:eventHandler>
</xp:button>
</xp:div>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:inputText value="#{document1.docID}" rendered="false"
id="docID"></xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
</xp:panel>
<xp:br></xp:br>
</xe:dialog>
I have a input text area where the user will enter values, but I am having trouble getting that value using SSJS. I have tried:
function getComponentValue(id){
var field = getComponent(id);
var value = field.getSubmittedValue();
if( null == value ){
// else not yet submitted
value = field.getValue();
}
return value
}
To grab the value in the input text area, I am not sure what to do, since if I bind to an existing field in the Data Palette it appears non-editable and I cannot enter any values.
Also, I have a Submit button on the dialog control which calls some SSJS:
function saveComments() {
// Need to create a comments doc for the movie...
var db:NotesDatabase = session.getCurrentDatabase();
var doc:NotesDocument = currentDocument.getDocument();
var unid = getComponentValue("docID");
// Grab comments from dialog...
var comments = getComponentValue("comments");
// Create the comments doc...
var docComm:NotesDocument = db.createDocument();
docComm.replaceItemValue("Form", "comment");
var nowValue = @Text(@Now());
var currentUser = sessionScope.get("currentUser");
docComm.replaceItemValue("cm_Key", unid);
docComm.replaceItemValue("cm_By", currentUser);
docComm.replaceItemValue("cm_Date", nowValue);
docComm.replaceItemValue("cm_Key", unid);
docComm.save();
}
How would I close the Dialog from the server-side?
So, 3 things (appreciate your patience):
- How to make fields editable on the dialog control
- How to get the value from the input text area that is not bound to a field on the document1
- How to close the dialog from server-side
Thanks!
EDITS: I put edits in this comment so I could show an image correctly...
- I made the docID field visible and it appears computed, not editable.
- I added a second document data source (commentDocument) and set the value of the field to the Data palette value -- field does not appear, thinking it may be non-editable.
Here is the image -- green box is where the comments field (cm_Comm from the commentsDocument source) should exist and the red box is the docID field that is non-editable:
Here is the code behind the control now:
<xe:dialog id="commentsDialog" title="Comments" styleClass="dialogBoxComments">
<xp:panel>
<xp:table style="width:100%">
<xp:tr>
<xp:td>
<xp:label value="Enter your comments..." id="label2"></xp:label>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:inputTextarea id="comments" style="width:100%;height:100px"
value="#{commentDocument.cm_Comm}">
</xp:inputTextarea>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:div style="text-align:right">
<xp:button value="Submit" id="submitButton">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:saveComments();getComponent("commentsDialog").hide();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button id="cancelButton" value="Cancel">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[XSP.closeDialog("#{id:commentsDialog}");]]></xp:this.script>
</xp:eventHandler>
</xp:button>
</xp:div>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:inputText value="#{document1.docID}" id="docID"></xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
</xp:panel>
<xp:br></xp:br>
</xe:dialog>
Please let me know what I am doing incorreclty -- appreciate this!