Xpages display attachment in dialog box from another document - xpages

I am opening a dialog box in an Xpage. In the dialog box I am displaying some fields from 3 other documents, and allowing the user to save some notes. All of this works, except I want to display attachments if there are any. I entered a file download control and for the data source pointed to the target document and did a
tmpDoc.getAttachment("attachments")
to get the attachments. But nothing shows up.
Here is the code from the one row in the table in the dialog box.
The other fields work fine, and I know I am getting the tmpDoc, but how do I display the attachment so the user can view it?
<xp:td>
<xp:fileDownload
rows="30"
id="fileDownload1"
displayLastModified="false">
<xp:this.value><![CDATA[#{javascript:
var prtUNID:String = document.getItemValueString("PCTaskParentID");
var tmpView:NotesView = database.getView("(dbAllPCTasksByTaskID)");
var tmpDoc:NotesDocument = tmpView.getDocumentByKey(prtUNID);
tmpDoc.getAttachment("attachments")
}]]></xp:this.value>
</xp:fileDownload>
</xp:td>
I am having more issues with this. Now it does not really work at all.
Here is what I am trying to accomplish.
I have a form PC Build. It is all the tasks that must be done to build a PC in my company. There is a list of Master Tasks called PC Tasks. When a new PC Build is saved, the PC Tasks get copied to rspPCTask forms attached to the PC Build.
As a user works om building a computer they can open up the PC Build and see the individual tasks. I want them to be able to click on a task and pull up the notes and attachments from the master task, while entering notes for the individual task.
Below is a screen shot. In the second field I am grabbing something with javascript. In the first field I am binding the field to the data source, but it is always blank. I cannot figure out why.
I have put in all my code below. Any assistance would be greatly appreciated!!!
<?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"
xmlns:xc="http://www.ibm.com/xsp/custom"
dojoForm="true"
dojoParseOnLoad="true"
dojoTheme="true">
<xp:this.data>
<xp:dominoDocument
var="document1"
action="openDocument"
computeWithForm="onsave"
formName="PCBuild">
<xp:this.postNewDocument>
<xp:actionGroup>
<xp:setValue
binding="#{document1.ID}"
value="#{javascript:session.evaluate('#Unique')}" />
<xp:setValue
binding="#{document1.crtDte}"
value="#{javascript:session.evaluate('#Today')}" />
<xp:setValue
binding="#{document1.crtUsr}"
value="#{javascript:session.getCommonUserName()}" />
</xp:actionGroup>
</xp:this.postNewDocument>
</xp:dominoDocument>
</xp:this.data>
<xp:this.resources>
<xp:styleSheet
href="/custom.css" />
<xp:script
src="/xpValidationPCBuild.jss"
clientSide="false" />
<xp:script
src="/xpUtilities.jss"
clientSide="false"></xp:script>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/resources/tundraGrid.css">
</xp:styleSheet>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/grid/resources/tundraEnhancedGrid.css">
</xp:styleSheet>
<xp:dojoModule
name="dojox.grid.EnhancedGrid"></xp:dojoModule>
</xp:this.resources>
<xp:this.beforePageLoad><![CDATA[#{javascript:viewScope.ID = document1.getItemValueString("ID")}]]></xp:this.beforePageLoad>
<xp:this.afterPageLoad><![CDATA[#{javascript:viewScope.put("rows","25")}]]></xp:this.afterPageLoad>
<xp:panel
style="width:900.00px">
<xp:panel>
<xp:text
escape="true"
id="dspDocUNID"
style="display:none">
<xp:this.value><![CDATA[#{javascript:if (#IsNewDoc())
{
return "0"
}
else
{
var doc:NotesDocument = document1.getDocument();
var sUNID = doc.getUniversalID();
return sUNID
}}]]></xp:this.value>
</xp:text>
<xp:scriptBlock
id="scriptBlock1">
<xp:this.value><![CDATA[// Conditionally return an image tag to display an icon in a cell
function displayIcon (value) {
var image = '';
switch (value.toLowerCase()) {
case "open":
image = '<img alt="" src="blueUncheckedCheckBox15.png" />';
break;
case "closed":
image = '<img alt="" src="blueCheckedCheckBox15.png" />';
break;
default:
image = '<img alt="" src="greenChk50.png" />';
break;
}
return image;
}]]></xp:this.value>
</xp:scriptBlock>
</xp:panel>
<xe:widgetContainer
id="widgetContainerHeader">
<xp:panel
style="padding-top:8.0px;padding-bottom:8.0px">
<xp:button
id="button1"
value="Edit"
style="font-weight:bold;font-size:10pt"
rendered="#{javascript:!(document1.isEditable())}">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action>
<xp:changeDocumentMode
mode="edit" />
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button
value="Save"
id="button3"
style="font-weight:bold;font-size:10pt"
rendered="#{javascript:(document1.isEditable())}">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="plContainer">
<xp:this.action>
<xp:actionGroup
condition="#{javascript:validateForm()}">
<xp:saveDocument
var="document1"></xp:saveDocument>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript://Get handle on current doc and see if it is a new doc
var thisDoc:NotesDocument = document1.getDocument();
var tg = thisDoc.getItemValueString("tasksGenerated");
if (tg != "Y") {
//Set flag to Y and save document
thisDoc.replaceItemValue("tasksGenerated","Y")
thisDoc.save(true)
var rspDoc:NotesDocument;
//Loop through all PC Task Docs
var pcTasksView:NotesView = database.getView("(dbAllPCTasks)");
var pcTaskDoc:NotesDocument = pcTasksView.getFirstDocument();
var tmpDoc:NotesDocument;
while (pcTaskDoc != null)
{
//Make new doc and add as response to this doc
rspDoc = database.createDocument();
rspDoc.replaceItemValue("Form","rspPCTask");
rspDoc.replaceItemValue("category",pcTaskDoc.getItemValueString("category"));
rspDoc.replaceItemValue("title",pcTaskDoc.getItemValueString("title"));
rspDoc.replaceItemValue("status","Open");
rspDoc.replaceItemValue("PCBuildParentID",thisDoc.getItemValueString("ID"));
rspDoc.replaceItemValue("PCTaskParentID",pcTaskDoc.getItemValueString("ID"));
rspDoc.replaceItemValue("PCTaskParentUNID",pcTaskDoc.getUniversalID());
rspDoc.replaceItemValue("order",pcTaskDoc.getItemValueInteger("order"));
rspDoc.save();
tmpDoc = pcTasksView.getNextDocument(pcTaskDoc);
pcTaskDoc.recycle();
pcTaskDoc = tmpDoc;
}
}}]]></xp:this.script>
</xp:executeScript>
<xp:openPage
name="$$PreviousPage"></xp:openPage>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button
id="button2"
style="font-weight:bold;font-size:10pt"
value="Close">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="norefresh">
<xp:this.action>
<xp:openPage
name="$$PreviousPage"
target="openDocument" />
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:text
escape="true"
id="computedField3"
style="font-size:14pt;color:rgb(79,79,79);padding-left:px;padding-bottom:px;margin-bottom:px;padding-right:25.0px">
<xp:this.value><![CDATA[#{javascript:document1.getItemValueString("crtDte")}]]></xp:this.value>
</xp:text>
</xp:panel>
</xe:widgetContainer>
<xp:panel
id="plContainer">
<xp:panel>
<xe:widgetContainer
id="widgetContainerData">
<xe:formTable
id="frLocationMaster"
disableErrorSummary="true"
disableRowError="true">
<xp:this.facets>
</xp:this.facets>
<xe:formRow
id="formRow5"
labelPosition="none"
style="padding-bottom:10.0px">
<xp:table
style="width:99%"
border="0"
cellpadding="0"
role="presentation"
cellspacing="0"
id="table4">
<xp:tr>
<xp:td
style="width:80.0px;min-width:120px">
<xp:text
id="cfTitle"
xp:key="header"
style="font-size:14pt;color:rgb(79,79,79);padding-left:px;padding-bottom:px;margin-bottom:px">
<xp:this.value><![CDATA[#{javascript:"PC Build"}]]></xp:this.value>
</xp:text>
</xp:td>
<xp:td
style="width:250.0px">
</xp:td>
<xp:td
style="text-align:right">
<xp:text
escape="true"
id="computedField1"
style="font-size:14pt;color:rgb(79,79,79);padding-left:25.0px;padding-bottom:px;margin-bottom:px">
<xp:this.value><![CDATA[#{javascript:document1.getItemValueString("crtUsr") + " on "}]]></xp:this.value>
<xp:this.rendered><![CDATA[#{javascript:if (#IsNewDoc() == 1) {
return false
} else {
return true;
}}]]></xp:this.rendered>
</xp:text>
<xp:text
escape="true"
id="computedField2"
style="font-size:14pt;color:rgb(79,79,79);padding-left:px;padding-bottom:px;margin-bottom:px;padding-right:px"
value="#{document1.CrtDte}">
<xp:this.converter>
<xp:convertDateTime
type="both"
timeStyle="short" />
</xp:this.converter>
<xp:this.rendered><![CDATA[#{javascript:if (#IsNewDoc() == 1) {
return false
} else {
return true;
}}]]></xp:this.rendered>
</xp:text>
</xp:td>
</xp:tr>
</xp:table>
</xe:formRow>
<xe:formRow
id="formRow1"
labelPosition="none">
<xp:table
style="width:99%"
border="0"
cellpadding="0"
role="presentation"
cellspacing="0"
id="table3">
<xp:tr>
<xp:td
style="width:10%;min-width:120px;">
<xp:label
id="label4"
for="formRow1"
value="Employee Name" />
</xp:td>
<xp:td
style="width:100px">
<xp:inputText
value="#{document1.employeeName}"
id="employeeName1">
<xp:typeAhead
mode="full"
minChars="1"
valueListSeparator=","
ignoreCase="true"
id="typeAhead1">
<xp:this.valueList><![CDATA[#{javascript:var dbname = new Array(#Subset(#DbName(), 1),"names.nsf");
return #DbColumn(dbname,"($PeopleByName)",1);}]]></xp:this.valueList>
</xp:typeAhead>
</xp:inputText>
</xp:td>
<xp:td
style="width:20px">
<xe:valuePicker
id="valuePicker1"
for="employeeName1"
pickerIcon="/picker.png"
dialogTitle="Choose Employee">
<xe:this.dataProvider>
<xe:simpleValuePicker>
<xe:this.valueList><![CDATA[#{javascript:var db:NotesDatabase = session.getDatabase(database.getServer(),"names.nsf");
var viewHandle:NotesView = db.getView("($PeopleByName)");
return viewHandle.getColumnValues(0)
}]]></xe:this.valueList>
</xe:simpleValuePicker>
</xe:this.dataProvider>
</xe:valuePicker>
</xp:td>
<xp:td>
<xp:message
id="message1"
for="employeeName1" />
</xp:td>
</xp:tr>
</xp:table>
</xe:formRow>
<xe:formRow
id="formRow2"
labelPosition="none">
<xp:table
style="width:99%"
border="0"
cellpadding="0"
role="presentation"
cellspacing="0"
id="table1">
<xp:tr>
<xp:td
style="width:10%;min-width:120px;">
<xp:label
id="label1"
for="formRow1"
value="Computer Name" />
</xp:td>
<xp:td
style="width:100px">
<xp:inputText
value="#{document1.computerName}"
id="computerName1">
</xp:inputText>
</xp:td>
<xp:td
style="width:20px">
</xp:td>
<xp:td>
<xp:message
id="message2"
for="computerName1" />
</xp:td>
</xp:tr>
</xp:table>
</xe:formRow>
<xe:formRow
id="formRow3"
labelPosition="none"
rendered="false">
</xe:formRow>
<xe:formRow
id="formRow4"
labelPosition="none"
rendered="false">
</xe:formRow>
</xe:formTable>
</xe:widgetContainer>
</xp:panel>
</xp:panel>
<xp:panel>
<xe:widgetContainer
id="widgetContainer1">
<xp:panel>
<xp:viewPanel
rows="30"
id="viewPanel1"
var="thisEntry">
<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="(dbAllRpPCTasks)">
<xp:this.keys><![CDATA[#{javascript:document1.getItemValueString("ID")}]]></xp:this.keys>
</xp:dominoView>
</xp:this.data>
<xp:viewColumn
columnName="title"
id="viewColumn5"
displayAs="link">
<xp:viewColumnHeader
value="Title"
id="viewColumnHeader5">
</xp:viewColumnHeader>
<xp:eventHandler
event="onclick"
submit="false"
refreshMode="partial"
refreshId="panelDig">
<xp:this.action><![CDATA[#{javascript:viewScope.UNID = thisEntry.getDocument().getUniversalID();
viewScope.parUNID = thisEntry.getDocument().getItemValueString("PCTaskParentUNID");
getComponent('dialog1').show()}]]></xp:this.action>
</xp:eventHandler>
</xp:viewColumn>
</xp:viewPanel>
<xp:panel
id="panelDig">
<xp:this.data>
<xp:dominoDocument
var="document2"
formName="PCTask"
action="editDocument"
documentId="#{javascript:viewScope.parUNID}">
</xp:dominoDocument>
<xp:dominoDocument
var="document3"
formName="rspPCTask"
action="editDocument"
documentId="#{javascript:viewScope.parUNID}">
</xp:dominoDocument>
</xp:this.data>
<xe:dialog
id="dialog1"
style="width:700px;height:600px"
refreshOnShow="true">
<xp:table>
<xp:tr>
<xp:td>
<xp:label
value="Master Title"
id="label2" />
</xp:td>
<xp:td>
<xp:text
escape="true"
id="computedField4"
value="#{document2.title}">
</xp:text>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label
value="Master Task Notes"
id="label3" />
</xp:td>
<xp:td>
<xp:text
escape="true"
id="computedField5">
<xp:this.value><![CDATA[#{javascript:var tmpDoc:NotesDocument = database.getDocumentByUNID(viewScope.parUNID)
tmpDoc.getItemValueString("notes")}]]></xp:this.value>
</xp:text>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label
value="Master Attachments"
id="label5" />
</xp:td>
<xp:td></xp:td>
</xp:tr>
<xp:tr>
<xp:td></xp:td>
<xp:td></xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label
id="label7"
value="Notes" />
</xp:td>
<xp:td>
<xp:inputTextarea
id="inputTextarea1"
style="width:98.0%;height:100px"
value="#{document3.notes}">
</xp:inputTextarea>
</xp:td>
</xp:tr>
</xp:table>
</xe:dialog>
</xp:panel>
</xp:panel>
</xe:widgetContainer>
</xp:panel>
</xp:panel>
<xp:eventHandler
event="onClientLoad"
submit="true"
refreshMode="norefresh">
<xp:this.script><![CDATA[try {
dojo.byId("#{id:employeeName1}").focus();
} catch (e) { }]]></xp:this.script>
</xp:eventHandler>
</xp:view>

To show all rich text field's attachments of "another" document in a fileDowndload control:
add a panel around your fileDownload control,
add a dominoDocument data source to the panel
set attribute documentId to "another" document's UNID
set fileDownload's value to document's rich text field
(in your case the rich text field is called "attachments")
<xp:td>
<xp:panel>
<xp:this.data>
<xp:dominoDocument
var="documentPCTaskParent"
action="openDocument">
<xp:this.documentId><![CDATA[#{javascript:
document.getItemValueString("PCTaskParentID")
}]]></xp:this.documentId>
</xp:dominoDocument>
</xp:this.data>
<xp:fileDownload
rows="30"
id="fileDownload1"
displayLastModified="false"
value="#{documentPCTaskParent.attachments}">
</xp:fileDownload>
</xp:panel>
</xp:td>
BTW tmpDoc.getAttachment("attachments") you used doesn't return all attachments of rich text field "attachments" but would look for an attachment with the file name "attachments" somewhere in document.

I would avoid the file download control if possible. What you likely want to do is just build html links or images to the actual files themselves. So it's mostly a matter of figuring out the correct URL to get to it. Typically these are old school "non XPages" URL's... the classic domino stuff.
Everything I know about doing this I learned form this post: http://www.wissel.net/blog/d6plinks/SHWL-86QKNM

Short answer: you can add tmpDoc as a true document data source (using

Related

Button can be clicked only once on a XPage

I have the following XPage which has one table and only two tr's.
The first one is a button itself which puts into viewScope['showPasswordTr'] boolean true value when clicked first time, when puts false when clicked again.
The second tr has an input which is rendered if viewScope['showPasswordTr']is true.
The problem I've encountered is that I can only click the button only once and it's 100% because of input field present. If I remove it, it works as expected
The second time and so on, the button just freezes and doesn't execute the action specified onclick event. Why is so? And how can I make it work as expected?
Thanks in advance.
EDIT
Well, It's obviously all because of required property set to true... So, should I check the element for emptiness only in the disered control then? Is it a good practice?
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:table id="buttonTable">
<xp:tr id="buttonTr">
<xp:td id="buttonTd">
<xp:button id="authAsPersonButton"
value="This button can be clicked only once" />
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" execId="buttonTable"
refreshId="buttonTable">
<xp:this.action>
<![CDATA[#{javascript:
print("clicked");
if(viewScope['showPasswordTr'])
{
viewScope['showPasswordTr'] = false;
}
else
{
viewScope['showPasswordTr'] = true;
}
}]]>
</xp:this.action>
</xp:eventHandler>
</xp:td>
</xp:tr>
<xp:tr id="passwordLabelTr" rendered="#{javascript:
return viewScope['showPasswordTr'] == true;
}">
<xp:td id="passwordLabelTd">
<xp:text id="passwordText" style="font-size: 14px;">
<xp:this.value>
<![CDATA[#{javascript:
return 'password:';
}]]>
</xp:this.value>
</xp:text>
</xp:td>
<xp:td id="passwordInputTd" align="right">
<xp:inputText id="passwordInput" password="true"
required="true">
</xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
</xp:view>
Add execId="buttonTd" or disableValidators="true" to your eventHandler properties. Then your example works as expected.
I optimized the code a bit (event handling within the button + shorter code for handling viewScope.showPasswordTr):
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:table id="buttonTable">
<xp:tr id="buttonTr">
<xp:td id="buttonTd">
<xp:button id="authAsPersonButton" value="Toggle password field">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="buttonTable" execMode="partial"
disableValidators="true">
<xp:this.action>
<![CDATA[#{javascript:
viewScope.showPasswordTr = !viewScope.showPasswordTr}]]>
</xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:td>
</xp:tr>
<xp:tr id="passwordLabelTr" rendered="#{!!viewScope.showPasswordTr}">
<xp:td id="passwordLabelTd">
<xp:text id="passwordText" style="font-size: 14px;" value="password:" />
</xp:td>
<xp:td id="passwordInputTd" align="right">
<xp:inputText id="passwordInput" password="true"
required="true">
</xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
</xp:view>

Looking for best approach for signature button on xpage

I need a simple button whereby a user clicks to sign off on a document. A single signer per document, but when they click it, it puts their name and the date in two visible fields, and changes the status field.
What is the best approach for this? This is probably drop-dead simple but for some reason I cannot get it working.
They have been forced to log in by this time.
Thanks in advance.
Matt
Try the following:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="document1" formName="test"></xp:dominoDocument>
</xp:this.data>
<xp:panel id="panelMain">
<xp:table>
<xp:tr>
<xp:td colspan="2">
<xp:label value="Main Form" id="label1"></xp:label>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td style="width:100.0px">
<xp:label value="Now" id="label2"></xp:label>
</xp:td>
<xp:td>
<xp:text escape="true" id="computedField1" value="${javascript:return #Now();}">
<xp:this.converter>
<xp:convertDateTime type="both"></xp:convertDateTime>
</xp:this.converter>
</xp:text>
</xp:td>
</xp:tr>
</xp:table>
</xp:panel>
<xp:panel id="panelSignature" style="background-color:rgb(192,192,192)">
<xp:button value="I Agree" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="SignatureTable">
<xp:this.action><![CDATA[#{javascript:
document1.replaceItemValue("SignedDate",#Now());
document1.replaceItemValue("SignedBy",userBean.getDisplayName());}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:table id="SignatureTable">
<xp:tr>
<xp:td colspan="2">
<xp:label value="SignatureTable" id="label3"></xp:label>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td style="width:100.0px">
<xp:label value="SignedBy" id="label6"></xp:label>
</xp:td>
<xp:td>
<xp:inputText id="computedField4" value="#{document1.SignedBy}" readonly="true"></xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td style="width:100.0px">
<xp:label value="SignedDate" id="label5"></xp:label>
</xp:td>
<xp:td>
<xp:inputText id="computedField3" value="#{document1.SignedDate}" readonly="true">
<xp:this.converter>
<xp:convertDateTime type="both"></xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
</xp:panel>
</xp:view>
Judging by this "They have been forced to log in by this time." your problem is in your ACL. Seems, you allow anonymous reading of the document, but in the moment you want to save it, ACL does not allow anonymous users to do that, so Domino asks for their identity.
Set anonymous access to No access level.
Here's a button, but if the user is not logged in and does not have anonymous edit access, then a login dialog will appear. For a signing function, I assume the user must be logged in to sign. document1 is the Xpage data document to be signed.
<xp:button
value="Sign"
id="button1"
styleClass="btn btn-primary">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete">
<xp:this.action>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:
document1.appendItemValue("SignerName", session.getEffectiveUsername();
document1.document1("SignedDate", session.createDateTime(#Now()));
document1.save();
}]]></xp:this.script>
</xp:executeScript>
</xp:this.action>
</xp:eventHandler>
</xp:button>
If you need to update a document without logging in, then in the button, you will have to get the doc with sessionAsSigner and then update.

Can't edit a document launched from a view in a dialog control in xpages

I have an XPages view with the first column as a link to launch the document for that row. I'm launching it in a dialog control and it works just fine, but it won't let me edit the document. I have an edit button on the dialog control to put it in edit mode, but it doesn't seem to work.
There are two datasources, one for the view and one for the document.
XPage:
<?xml version="1.0" encoding="UTF-8"?>
<xc:NewMainForm><xp:this.facets><xc:NewLogin xp:key="facet_Login "></xc:NewLogin>
<xc:FooterContent xp:key="facet_Footer"></xc:FooterContent>
<xc:HomeBodyContent xp:key="facet_Body"></xc:HomeBodyContent>
<xc:MenuContainer xp:key="facet_Menu"></xc:MenuContainer>
<xc:cc_headerRightContent xp:key="facet_HeaderRight">
</xc:cc_headerRightContent>
<xc:cc_headerCenterContent xp:key="facet_HeaderCenter">
</xc:cc_headerCenterContent>
<xc:cc_headerLeftContent xp:key="facet_HeaderLeft">
</xc:cc_headerLeftContent>
<xc:NewLogin xp:key="facet_Login"></xc:NewLogin></xp:this.facets>
</xc:NewMainForm></xp:view>
Custom Control:
<?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"
style="background-repeat:no-repeat;background-position:center center"
xmlns:xc="http://www.ibm.com/xsp/custom">
<xp:this.resources>
<xp:script src="/xspDialog.js" clientSide="true"></xp:script>
<xp:styleSheet href="/Style.css"></xp:styleSheet>
</xp:this.resources>
<xp:panel>
<xp:inputText id="Search" value="#{viewScope.searchString}">
</xp:inputText>
<xp:button value="Search" id="button1"
style="background-color:rgb(57,88,137);color:rgb(255,255,255)">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="viewPanel1">
</xp:eventHandler>
</xp:button>
</xp:panel>
<!-- VIEW PANEL -->
<xp:viewPanel id="viewPanel1" pageName="/ByAcronym.xsp"
viewStyle="width:100%;background-
image:url(Music1+Big+twice+Faded.png);background-repeat:no-
repeat;background-position:center center;border-width:thick"
var="thisentry" rows="27">
<xp:this.facets>
<xp:pager partialRefresh="true" layout="Previous Group Next"
xp:key="headerPager" id="pager1">
</xp:pager>
<xp:viewTitle xp:key="viewTitle" id="viewTitle1"
value="By Title" style="color:rgb(255,128,0);font-weight:bold">
</xp:viewTitle>
<xp:pager partialRefresh="true" layout="Previous Group Next"
xp:key="footerPager" id="pager2">
</xp:pager>
</xp:this.facets>
<xp:this.data>
<xp:dominoView viewName="Songs" var="dsSongs"
ignoreRequestParams="true">
<xp:this.search><![CDATA[#{javascript:return
viewScope.get("searchString")}]]></xp:this.search>
</xp:dominoView>
</xp:this.data>
<!-- VIEWCOLUMN1 -->
<xp:viewColumn columnName="Title" id="viewColumn1"
displayAs="link" style="width: 750px">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="dialog1" id="eventHandler1">
<xp:this.action>
<![CDATA[#{javascript:viewScope.UNID =
thisentry.getDocument().getUniversalID();
getComponent('dialog1').show()}]]>
</xp:this.action>
</xp:eventHandler>
<xp:viewColumnHeader value="Title" id="viewColumnHeader1">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="MusicType" id="viewColumn2">
<xp:viewColumnHeader value="Music Type"
style="width: 250px" id="viewColumnHeader2">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="ComposedBy" id="viewColumn3">
<xp:viewColumnHeader value="Composer"
id="viewColumnHeader3">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="ArrangedBy"
id="viewColumn4">
<xp:viewColumnHeader value="Arranger"
id="viewColumnHeader4">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="Jonra" id="viewColumn5">
<xp:viewColumnHeader value="Jonra"
id="viewColumnHeader5">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn columnName="Seasonal" id="viewColumn6">
<xp:viewColumnHeader value="Seasonal"
id="viewColumnHeader6">
</xp:viewColumnHeader>
</xp:viewColumn>
<xp:viewColumn id="viewColumn7" columnName="Location"
style="width:75px">
<xp:this.facets>
<xp:viewColumnHeader xp:key="header"
id="viewColumnHeader7" value="Location" style="width:750px">
</xp:viewColumnHeader>
</xp:this.facets>
</xp:viewColumn>
<xp:viewColumn id="viewColumn8" columnName="NumberOfCopies"
style="width:10.0px">
<xp:this.facets>
<xp:viewColumnHeader xp:key="header"
id="viewColumnHeader8" value="Number Of Copies"
style="width:750px">
</xp:viewColumnHeader>
</xp:this.facets>
</xp:viewColumn>
</xp:viewPanel>
<!-- DIALOG1-->
<xe:dialog id="dialog1" title="Details">
<xe:dialogContent id="dialogContent1">
<xp:panel
style="width:698.0px;background-
image:url(Music1+Big+twice+Faded.png);background-repeat:no-
repeat;background-position:center center;border-
color:rgb(57,88,137);border-style:solid;border-
width:thin;color:rgb(33,51,80)">
<xp:this.data>
<xp:dominoDocument var="document1"
formName="MusicForm" action="editDocument"
documentId="#{javascript:viewScope.UNID}"
ignoreRequestParams="true">
</xp:dominoDocument>
</xp:this.data>
<xp:table>
<xp:tr>
<xp:td>
<xp:label value="Music Type:"
id="musicType_Label1" for="musicType1"
style="font-weight:bold">
</xp:label>
<xp:br></xp:br>
<xp:inputText value="#{document1.MusicType}"
id="musicType1">
</xp:inputText>
</xp:td>
<xp:td>
<xp:label value="Title:" id="title_Label1"
for="title1" style="font-weight:bold">
</xp:label>
<xp:br></xp:br>
<xp:inputText value="#{document1.Title}"
id="title1">
</xp:inputText>
</xp:td>
<xp:td>
<xp:label value="Composed By:"
id="composedBy_Label1" for="composedBy1"
style="font-weight:bold">
</xp:label>
<xp:br></xp:br>
<xp:inputText value="#{document1.ComposedBy}"
id="composedBy1">
</xp:inputText>
</xp:td>
<xp:td>
<xp:label value="Arranged By:"
id="arrangedBy_Label1" for="arrangedBy1"
style="font-weight:bold">
</xp:label>
<xp:br></xp:br>
<xp:inputText value="#{document1.ArrangedBy}"
id="arrangedBy1">
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label value="Jonra:" id="jonra_Label1"
for="jonra1" style="font-weight:bold">
</xp:label>
<xp:br></xp:br>
<xp:inputText value="#{document1.Jonra}"
id="jonra1">
</xp:inputText>
</xp:td>
<xp:td>
<xp:label value="Season:"
id="seasonal_Label1" for="seasonal1"
style="font-weight:bold">
</xp:label>
<xp:br></xp:br>
<xp:inputText value="#{document1.Seasonal}"
id="seasonal1">
</xp:inputText>
</xp:td>
<xp:td>
<xp:label value="Location:"
id="location_Label1" for="location1"
style="font-weight:bold">
</xp:label>
<xp:br></xp:br>
<xp:inputText value="#{document1.Location}"
id="location1">
</xp:inputText>
</xp:td>
<xp:td>
<xp:label value="Number Of Copies:"
id="numberOfCopies_Label1" for="numberOfCopies1"
style="font-weight:bold">
</xp:label>
<xp:br></xp:br>
<xp:inputText
value="#{document1.NumberOfCopies}"
id="numberOfCopies1">
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td colspan="4">
<xp:messages layout="table"
style="color:red" id="messages1">
</xp:messages>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td colspan="4">
<xp:button id="button5" value="Save">
<xp:this.rendered><![CDATA[#
{javascript:if(document1.isNewNote()){
false
}else{
true
}}]]></xp:this.rendered>
<xp:eventHandler event="onclick"
submit="true" refreshMode="complete"
id="eventHandler5">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript
script="#
{javascript:document1.save()}">
</xp:executeScript>
<xp:openPage
name="/Main.xsp">
</xp:openPage>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button id="button4" value="Submit">
<xp:this.rendered><![CDATA[#
{javascript:if(document1.isNewNote()){
true
}else{
false
}}]]></xp:this.rendered>
<xp:eventHandler event="onclick"
submit="true" refreshMode="complete"
immediate="false"
save="true" id="eventHandler2">
<xp:this.action>
<xp:actionGroup>
<xp:openPage
name="/Main.xsp">
</xp:openPage>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button value="Edit" id="button2"
rendered="#
{javascript:!document1.isEditable()}">
<xp:eventHandler event="onclick"
submit="true" refreshMode="complete"
id="eventHandler3">
<xp:this.action>
<xp:changeDocumentMode
mode="edit" var="document1">
</xp:changeDocumentMode>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button id="button3">
<xp:this.value><![CDATA[#
{javascript:if(document1.isEditable()){
"Cancel"
}else{
"Close"
}}]]></xp:this.value>
<xp:eventHandler event="onclick"
submit="true" refreshMode="complete"
immediate="true"
save="false" id="eventHandler4">
<xp:this.action>
<xp:openPage name="/Main.xsp">
</xp:openPage>
</xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:td>
</xp:tr>
</xp:table>
</xp:panel>
</xe:dialogContent>
</xe:dialog>
</xp:view>
What am I doing wrong?
MJ
"Maximum Internet name and password" on the ACL's Advanced tab can limit access. If that's set to e.g. Reader, the highest access permitted for the application on the web will be Reader access, regardless of the individual's ACL settings. Author would only allow them to create, not edit existing documents that do not have an Authors field etc.

Cannot Save xPage

My XPage will not save any data that I enter into it. The screen just flashes and the document that is open just redisplays. I assume it has something to do with where the buttons to save (Speichern) / cancel (Abbrechen) have been placed but, no matter where I place them they don't work. I am having the same problem with the New button - although I assume if the one error is found the other problem will be solved :)
Any help would be greatly appreciated as I have been looking into this for the whole day!
Here is the code for the page layout control:
<?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">
<xe:applicationLayout id="applicationLayout1">
<xe:this.facets>
<xp:callback facetName="facetLeft" id="facetLeft" xp:key="LeftColumn">
</xp:callback>
</xe:this.facets>
<xp:callback facetName="facetMiddle" id="facetMiddle">
</xp:callback>
<xe:this.configuration>
<xe:simpleResponsiveConfiguration navbar="true" invertedNavbar="true" fixedNavbar="fixed-top"
navbarText="Thomas Vogel Dokumentation" pageWidth="fluid">
<xe:this.navbarAppLinks>
<xe:pageTreeNode label="Neu" page="/xpNewDocument.xsp"></xe:pageTreeNode>
<xe:loginTreeNode enabled="true" title="Abmelden" label="Abmelden"></xe:loginTreeNode>
</xe:this.navbarAppLinks>
</xe:simpleResponsiveConfiguration>
</xe:this.configuration>
</xe:applicationLayout>
</xp:view>
Here the code for the menu:
<?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">
<xe:navigator id="navigator1">
<xe:this.treeNodes>
<xe:pageTreeNode label="nach Titel" page="/xpByTitle.xsp"></xe:pageTreeNode>
<xe:pageTreeNode label="nach Kategorie" page="/xpByCategory.xsp"></xe:pageTreeNode>
<xe:pageTreeNode label="nach Ersteller_in" page="/xpByCreatedBy.xsp"></xe:pageTreeNode>
<xe:pageTreeNode label="nach Datum" page="/xpByDate.xsp"></xe:pageTreeNode>
</xe:this.treeNodes>
</xe:navigator></xp:view>
And finally the for the EditDocument page:
<?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">
<xp:this.data>
<xp:dominoDocument var="document1" formName="fmDoc" action="editDocument">
</xp:dominoDocument>
</xp:this.data>
<xc:ccPageLayout>
<xp:this.facets>
<xc:ccMenu xp:key="facetLeft"></xc:ccMenu>
<xp:panel xp:key="facetMiddle">
<xp:table>
<xp:tr>
<xp:td>
<xp:label value="Titel" id="titel_Label1" for="titel1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText value="#{document1.Titel}" id="titel1">
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label value="Datum" id="dokDatum_Label1" for="dokDatum1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText value="#{document1.dokDatum}" id="dokDatum1">
<xp:dateTimeHelper id="dateTimeHelper1">
</xp:dateTimeHelper>
<xp:this.converter>
<xp:convertDateTime type="date" dateStyle="short">
</xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label value="Kategorie" id="label3" for="kategorie1">
</xp:label>
</xp:td>
<xp:td>
<xp:comboBox id="kategorie1" value="#{document1.kategorie}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var currDB:NotesDatabase = database;
var profileDoc:NotesDocument=currDB.getProfileDocument("configDatabase","");
var docUID=profileDoc.getItemValueString("kategorieDok");
var categoryDoc:NotesDocument = currDB.getDocumentByUNID(docUID);
var categories = categoryDoc.getItemValueString("kategorie");
#Explode(#Text(categories), ";")
}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label value="Anhänge" id="label1" for="fileUpload1">
</xp:label>
</xp:td>
<xp:td>
<xp:fileUpload id="fileUpload1" value="#{document1.anhaenge}" useUploadname="true"></xp:fileUpload>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td>
<xp:label value=" " id="label2" for="fileDownload1">
</xp:label>
</xp:td>
<xp:td>
<xp:fileDownload rows="5" id="fileDownload1" displayLastModified="false" value="#{document1.anhaenge}"
hideWhen="true" displayType="false" displayCreated="false" allowDelete="true">
</xp:fileDownload>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td colspan="2">
<xp:inputRichText id="inputRichText1" value="#{document1.body}">
</xp:inputRichText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td colspan="2">
</xp:td>
</xp:tr>
</xp:table>
<xp:button value="Speichern" id="button2">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="false">
<xp:this.action>
<xp:actionGroup>
<xp:saveDocument var="document1"></xp:saveDocument>
<xp:openPage name="$$PreviousPage"></xp:openPage>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button value="Abbrechen" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action>
<xp:actionGroup>
<xp:openPage name="$$PreviousPage"></xp:openPage>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:panel>
</xp:this.facets>
</xc:ccPageLayout>
</xp:view>

In one of the buttons I noticed this part immediate="false" save="false"
save should be set to true, I think.
I may have missed it but you should ALWAYS have a displayErrors control. There could be a conversion error or something that you wouldn't otherwise see. You should also think about adding the XPages Log Reader as that can expose other error messages.

XPage - Refreshing Repeat control

I have button in a xpage which creates a document and refreshes a repeat control. All is working fine except the repeat control is showing the newly added document at the top of the table (IMG1).
But after refresh the xpage again, the repeat control renders the table properly (IMG2)
Repeat Code
<xp:panel>
<xp:table style="width:100.0%">
<xp:tr>
<xp:td style="font-weight:bold">
Hardware
</xp:td>
<xp:td style="font-weight:bold">
Quantity
</xp:td>
<xp:td style="font-weight:bold">
Asset Tag No
</xp:td>
<xp:td style="font-weight:bold">
Previous User
</xp:td>
<xp:td>
</xp:td>
</xp:tr>
<xp:repeat id="rpHardware" rows="30" var="clHardwares">
<xp:this.value>
<![CDATA[#{javascript:var docMain:NotesDocument = compositeData.docOnboarding.getDocument();
var vwApp:NotesView = database.getView("lkupHardwaresByParentID");
vwApp.getAllDocumentsByKey(docMain.getUniversalID(),true)}]]>
</xp:this.value>
<xp:tr>
<xp:td>
<xp:text escape="true" id="cfHWName">
<xp:this.value>
<![CDATA[#{javascript:clHardwares.getItemValueString("REQ_HW_Name")}]]>
</xp:this.value>
</xp:text>
</xp:td>
<xp:td>
<xp:text escape="true" id="cfHWQuantity">
<xp:this.value>
<![CDATA[#{javascript:clHardwares.getItemValueString("REQ_HW_Quantity")}]]>
</xp:this.value>
</xp:text>
</xp:td>
<xp:td>
<xp:text escape="true" id="cfHWAssetTagNo">
<xp:this.value>
<![CDATA[#{javascript:clHardwares.getItemValueString("REQ_HW_AssetTagNo")}]]>
</xp:this.value>
</xp:text>
</xp:td>
<xp:td>
<xp:text escape="true" id="cfHWPreviousUser">
<xp:this.value>
<![CDATA[#{javascript:clHardwares.getItemValueString("REQ_HW_PreviousUser")}]]>
</xp:this.value>
</xp:text>
</xp:td>
<xp:td>
<xp:link escape="true" text="Edit" id="link4">
<xp:eventHandler event="onclick"
submit="true" refreshMode="complete">
<xp:this.action>
<![CDATA[#{javascript:viewScope.put("selHardware",clHardwares.getNoteID());
getComponent("dlgAddHardware").show();}]]>
</xp:this.action>
</xp:eventHandler>
</xp:link>
<xp:link escape="true" id="link5" text="Delete">
</xp:link>
</xp:td>
</xp:tr>
</xp:repeat>
</xp:table>
</xp:panel>
Have you tried setting the repeat's "removeRepeat" property to TRUE? This removes unwanted div controls created from the repeat after the control's job is done.
(repeat >> All Properties >> basics)
EDIT:
forgot to mention that your button cannot perform a partial refresh on the repeat itself if that property is set to TRUE. Instead give your surrounding table or an aditional panel its own id which you can use to perform the necessery update
Did you refresh your view after creating the new document?
database.getView("ViewName").refresh();

Resources