xpages, save all documents in a repeat panel - xpages

I'm trying out a simple xpage that fetches a parent document (form fParent) and a few child documents (form fChild) via view vChildren. I can get the children as read only via a normal view control but these are read-only and I'd like to bind the children to documents so the save/submit button makes changes to both the parent and child documents.
In the repeat control, I'm binding the variable rowData to a DocumentCollection object which I'm assuming is iterated over and returns a Document object for each item (this seems to work as the xpage displays the correct number of custom controls). I understand from the HCL documentation that in order for the save action to be able to make changes to the child documents I need to add a document data source which I have done in the custom control.
The issue I have is that document2 in the custom control is picking up the parent form data and not the child form data (the note IDs for each child are the same as the parent which makes me think this is the case).
What am I doing wrong? Code below and thanks in advance.
xPage for the parent
<?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 formName="fParent" var="document1" />
<xp:dominoView
var="view1" viewName="vChildren"
categoryFilter="#{document1.Key}">
</xp:dominoView>
</xp:this.data>
Name
<xp:inputText id="inputText2" value="#{document1.Name}"></xp:inputText>
<xp:br></xp:br>
Key 
<xp:text escape="true" id="computedField1" value="#{document1['Key']}">
</xp:text>
<xp:br></xp:br>
<xp:repeat id="repeat1" rows="30" var="rowData">
<xp:this.value><![CDATA[#{javascript:
var key = currentDocument.getItemValueString("key");
return database.getView('vChildren').getAllDocumentsByKey(key);}
]]>
</xp:this.value>
<xc:ccChildDoc></xc:ccChildDoc>
</xp:repeat>
<xp:button id="button1" value="Save" save="true" type="submit"></xp:button>
</xp:view>
Custom control for each child document
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" binding="#{rowData}">
<xp:this.data>
<xp:dominoDocument
formName="fChild" var="document2"
action="editDocument" computeWithForm="both"
documentId="#{javascript:rowData.getNoteID();}">
</xp:dominoDocument>
</xp:this.data>
<xp:panel>
Note id: 
<xp:text escape="true" id="computedField1" value="#{javascript:document2.getNoteID();}">
</xp:text>
<xp:br></xp:br>
Comment 
<xp:inputText id="inputText1" value="#{document2.Comment}" readonly="false">
</xp:inputText>
<xp:br></xp:br>
Field2 
<xp:inputText id="inputText2" value="#{document2.Field2}" readonly="false">
</xp:inputText>
<xp:br></xp:br>
<hr />
</xp:panel>
</xp:view>

Try adding ignoreRequestParams="true" to your data source for the child document.
This parameter tells XPages to ignore the documentId parameter in the URL for the child document data source and the child data source should then use documentId="#{javascript:rowData.getNoteID();}".

Related

XPages Tag cloud

I would to show the tagcloud value individually in each line. Like a list
value1
value2
value3
...
...
..
This is my code. Everytime I choose a value from the list, the display list also got filtered.
This code work in XPNIC without a problem. In the browser I am having the problem as stated above.
<xp:section id="section2" header="Web" type="wide">
<xp:panel>
<xp:this.data>
<xp:dominoView var="view2" viewName="TagCloudActiveCategories" expandLevel="1">
</xp:dominoView>
</xp:this.data>
<xp:repeat id="repeat2" rows="30" value="#{view2}" indexVar="indexVar" var="rowData">
<xe:list id="list2" styleClass="lotusList">
<xp:link escape="true" id="link1" value="/allDocumentsByTag.xsp">
<xp:this.text><![CDATA[# {javascript:rowData.getColumnValues()[0];}]]></xp:this.text>
<xp:this.parameters>
<xp:parameter name="categoryFilter">
<xp:this.value><![CDATA[# {javascript:getComponent("link1").getText();}]]></xp:this.value>
</xp:parameter>
</xp:this.parameters>
<xp:eventHandler event="onclick" submit="true" refreshMode="norefresh"></xp:eventHandler>
</xp:link>
</xe:list>
</xp:repeat>
</xp:panel>
</xp:section>
Any help is very welcome. Thank you in advance.
As far I can see you are using URL parameters to filter your view. This parameter is used by EVERY view datasource on your XPage, even the datasource of your tag cloud.
Add the property ignoreRequestParams=true to your tag cloud view, this should solve the problem.
<xp:this.data>
<xp:dominoView var="view2" viewName="TagCloudActiveCategories" expandLevel="1" ignoreRequestParams="true">
</xp:dominoView>
</xp:this.data>

Rich text field in custom control with composite data

I am developing an xpages application and use 1 custom control where I have a rich text field on it.
The source document is on the main page.
The rich text field has it value via compositeData.
I pass the document and the field name.
In the CC I address the rich text field as
compositeData.DataSource[compositeData.Fieldname]
Where DataSource my document1 is and Fieldname the name of the rich text field on the notes document.
All works except inserting an image in the rich text and removing attachments.
I did find a lot of information about this but not a real solution.
Dit anybody ever found a solution for this?
Regards,
Peter
Here is the code:
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">
<xp:panel>
<xp:label id="label1" value="Title:"></xp:label>
<xp:inputText id="inputText1">
<xp:this.value><![CDATA[#{compositeData.DataSource[compositeData.Title]}]]></xp:this.value>
</xp:inputText>
<xp:br></xp:br>
<xp:inputRichText id="richtext">
<xp:this.value><![CDATA[#{compositeData.DataSource[compositeData.Field]}]]></xp:this.value></xp:inputRichText>
<xp:fileUpload id="fileUpload1">
<xp:this.value><![CDATA[#{compositeData.DataSource[compositeData.Field]}]]></xp:this.value>
</xp:fileUpload>
<xp:fileDownload rows="30" id="fileDownload1"
displayLastModified="false" allowDelete="true">
<xp:this.value><![CDATA[#{compositeData.DataSource[compositeData.Field]}]]></xp:this.value>
</xp:fileDownload>
</xp:panel>
</xp:view>
XPAGE using the CC
<?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"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.data>
<xp:dominoDocument var="document1" formName="testform"></xp:dominoDocument>
</xp:this.data>
<xe:applicationLayout id="applicationLayout1">
<xp:panel>
<xp:button id="button1">
<xp:this.value><![CDATA[Save & Close]]></xp:this.value>
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<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:br></xp:br>
<xc:cc DataSource="#{javascript:document1}" Field="Body" Title="Title">
</xc:cc>
</xp:panel>
<xe:this.configuration>
<xe:bootstrapResponsiveConfiguration></xe:bootstrapResponsiveConfiguration>
</xe:this.configuration>
</xe:applicationLayout>
<xp:this.navigationRules>
<xp:navigationRule outcome="xsp-success" viewId="$$PreviousPage"></xp:navigationRule>
</xp:this.navigationRules>
</xp:view>
I use the following in a custom control. Notice that I use a different syntax for the value parameter for xp:inputRichText than for the upload and download controls - and that the value parameter is computed on page load ($) instead of dynamically (#):
<xp:inputRichText id="richtext" value="${javascript:'#{document.' + compositeData.fieldName + '}';}"></xp:inputRichText>
<xp:fileUpload id="fileUpload" value="#{document[compositeData.fieldName]}"></xp:fileUpload>
<xp:fileDownload id="fileDownload" value="#{document[compositeData.fieldName]}"></xp:fileDownload>

XPage fileDownload1 control becomes editable on page full refresh?

Why fileDownload1 control becomes editable (delete file attachment icon appears next to fileDownload control) when I just refresh the page. Here is my code where I use a button to refresh the page (just for the example)
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete"></xp:eventHandler>
</xp:button>
<xp:this.data>
<xp:dominoDocument var="document1" formName="myXpage"
databaseName="${javascript:sessionScope.SUPPORT_DB_FILE}"
action="openDocument">
</xp:dominoDocument>
</xp:this.data>
<xp:fileDownload
id="fileDownload1"
rows="30"
displayLastModified="false"
displayType="false"
displayCreated="false"
hideWhen="true"
allowDelete="true"
value="#{document1.MyBodyRTF}">
</xp:fileDownload>
I tried to replicate what you're describing, but am having trouble doing so. I created a new XPage and modeled it after your sample code.
Notable differences:
I never see the trash icon
I had to compute the UNID of some document with an attachment in the appropriate field
I set both the DB name and UNID in beforePageLoad
I noticed an interesting change in the UI behavior (see animated gif below)
I'm not sure what you're running into without having more source code to be able to view, but I can confirm that what I tried doesn't reproduce the result you're describing.
XPage source:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.beforePageLoad><![CDATA[#{javascript:sessionScope.myDbName = database.getFilePath();
var vw:NotesView = database.getView("SomeForms");
var first:NotesDocument = vw.getFirstDocument();
sessionScope.myFirstDoc = first.getUniversalID();
first.recycle();
vw.recycle();}]]></xp:this.beforePageLoad>
<xp:this.data>
<xp:dominoDocument
var="document1"
action="openDocument"
formName="SomeForm"
databaseName="${javascript:return sessionScope.myDbName;}"
documentId="${javascript:return sessionScope.myFirstDoc;}" />
</xp:this.data>
<xp:fileDownload
rows="30"
id="fileDownload1"
displayLastModified="false"
value="#{document1.SomeAttachments}" />
<xp:button
value="Refresh"
id="button1">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete" />
</xp:button>
</xp:view>

MultipleField Value in repeat Control with Pager

what i want to do is If a field has more than 20 values How can i list values in a repeat control with pager component and editBox or computedField.
Only 20 records should be listed for per page. a Pager should help me to show all values page by page..
this field is listed in a dialogBox. here is the my Code below. If someoen did it and it is possible to share it. Appreciate that..
<xe:dialog id="dialogHistory" title="Tarihçe">
<xp:panel>
<xp:pager id="pager1" for="repeat1">
<xp:pagerControl type="First" id="pagerControl1"></xp:pagerControl>
<xp:pagerControl type="Previous" id="pagerControl2"></xp:pagerControl>
<xp:pagerControl type="Group" id="pagerControl3"></xp:pagerControl>
<xp:pagerControl type="Next" id="pagerControl4"></xp:pagerControl>
<xp:pagerControl type="Last" id="pagerControl5"></xp:pagerControl>
</xp:pager>
<xp:repeat id="repeat1" rows="1" first="1" var="col" indexVar="index">
<xp:this.value><![CDATA[#{javascript:var cVal = document1.getValue("history"); return cVal;}]]></xp:this.value>
<xp:inputText id="inputText1" multipleSeparator="#{javascript:#NewLine();}">
<xp:this.value><![CDATA[#{javascript:var cVal = document1.getValue("history");
return cVal;}]]>
</xp:this.value>
</xp:inputText>
</xp:repeat>
</xp:panel>
</xe:dialog>
The trouble is that you're referring back to the document, not the values of the field in the inputText.
<xp:repeat id="repeat1" rows="20" var="col" indexVar="index">
<xp:this.value><![CDATA[#{javascript:var cVal = document1.getValue("history"); return cVal;}]]></xp:this.value>
<xp:inputText id="inputText1" value="#{col}">
</xp:inputText>
</xp:repeat>
However, I think this will only display them in inputText. I don't think that it binds them to the field, so I don't think it would allow you to change the values.
Exactly according to the code,It is difficult to Point the issue but the same xpage code,If it would help you in any case.
Code:
<?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="testing">
</xp:dominoDocument>
</xp:this.data>
<xp:br></xp:br>
<xp:repeat id="dateRepeatControl" rows="5" var="r" indexVar="i"
first="0">
<xp:this.value><![CDATA[#{javascript:var v:java.util.Vector = new java.util.Vector();
v.add('Date1');v.add('Date2');v.add('Date3');v.add('Date4');v.add('Date5');v.add('Date6');
v.add('Date7');v.add('Date8');v.add('Date9');v.add('Date10');v.add('Date11');v.add('Date12');
;v.add('Date13');v.add('Date14');
return v;}]]></xp:this.value>
<xp:br></xp:br>
<xp:div id="checkDiv">
<xp:text escape="true" id="computedField1"
value="#{javascript:r}">
</xp:text>
</xp:div>
<xp:br></xp:br>
</xp:repeat>
<xp:pager partialRefresh="true" id="pager1"
for="dateRepeatControl">
<xp:pagerControl id="pagerControl1" type="First"></xp:pagerControl>
<xp:pagerControl id="pagerControl2" type="Previous"></xp:pagerControl>
<xp:pagerControl id="pagerControl3" type="Next"></xp:pagerControl>
<xp:pagerControl id="pagerControl4" type="Last"></xp:pagerControl>
<xp:pagerControl id="pagerControl5" type="Separator"></xp:pagerControl>
</xp:pager>
</xp:view>
This is an xpage having a repeat control with 5 values of a vector to be repeated at one page and pages helps it to go next.You can use this xpage to get the working repeat control with the pager.

Xpages Dynamic dojo dialog control

I have a list of products (created using a repeat control) and wish to click on a particular product and bring up a dialog with further information about that particular product. I don't really want to generate dijit.dialog thing for every single product on that page, so how can I do this dynamically possibly using AJAX and partial refresh.
A similar non xpages example can be seen here: http://www.replacementkeys.co.uk/window?dir=asc&limit=12&mode=grid&order=position - where you hover over an image and a quick view button comes up, which then dynamically loads the content for that product.
Any ideas would be truly appreciated.
We build the dialog outside the repeat control and then the action that launches or shows it also sets a viewScope variable that is used UNID for the data source in the dialog. Just make sure you refresh the contents of the dialog as you open it...
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.data>
<xp:dominoView var="promptView" viewName="dlgBoxes">
</xp:dominoView>
</xp:this.data>
<xp:panel>
<xp:repeat id="repeat1" rows="30" value="#{promptView}" var="promptEntry">
<xp:panel tagName="div">
<xp:text escape="true" id="computedField1" value="#{promptEntry.dlgName}">
</xp:text>
 
<xp:button value="details" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
var pe:NotesViewEntry = promptEntry;
viewScope.put("dlgDocUnid", pe.getUniversalID());
getComponent("dialog1").show();
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</xp:panel>
</xp:repeat>
</xp:panel>
<xe:dialog id="dialog1" keepComponents="false" partialRefresh="true">
<xe:this.title><![CDATA[#{javascript:
var unid = viewScope.get("dlgDocUnid");
if(!unid) return "";
var doc:NotesDocument = database.getDocumentByUNID(unid);
return doc.getItemValueString("dlgName");}]]></xe:this.title>
<xp:panel>
<xp:this.data>
<xp:dominoDocument var="dlgDoc" formName="dlgBox" action="openDocument">
<xp:this.documentId><![CDATA[#{javascript:viewScope.get("dlgDocUnid");}]]></xp:this.documentId>
</xp:dominoDocument>
</xp:this.data>
<xp:text escape="true" id="computedField2" value="#{dlgDoc.Title}">
</xp:text>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:text escape="true" id="computedField3" value="#{dlgDoc.dlg}">
</xp:text>
</xp:panel>
</xe:dialog>
</xp:view>
Happy coding
/Newbs
You can combine your repeat control with the Extension Library dialog control in order to be able to launch a dialog when the user clicks on the individual row. Chris Toohey has created an excellent article called Popup Dialog Forms from Views in XPages that demonstrates this.

Resources