Xpages viewPanel open selected Document in Dialog - dialog

I have been trying to open a dialog from viewPanel. This dialog is opened There is no problem here but I want to load selected document in viewPanel. When I try to do it. Which document I click It does not matter. The latest(at the bottom) document is always loaded in Dialog. My problem is (I could not solve) how to get selected document in viewPanel into Dialog. If There is an example how to do it or If someone can explaing the way I need to follow please. I really appreciate that.
UPDATE: I have listes all of document in a table then When i double click on a document which opens dialog box.
<xp:table id="viewPanela" styleClass="xspRepeatTable" cellpadding="0" cellspacing="0" style="width:98%"> <xp:tr styleClass="xspHeaderRow">
<xp:td style="width:2%"></xp:td>
<xp:td>
<xp:label value="Title" id="label2"></xp:label></xp:td>
<xp:td><xp:label value="Abteilung" id="label3"></xp:label>
</xp:td>
</xp:tr>
<xp:repeat id="repeatList" value="#{javascript:dominoView}" var="ordnerData" rows="10" indexVar="repeatIndex">
<xp:tr id="tr1"><xp:td></xp:td><xp:td><xp:div id="div1"><xp:this.style> <![CDATA[#{javascript:var level = ordnerData.getIndentLevel();
if(level != null && level > 0){
return "padding-left:" + (level * 10) + "px !important";}else{return ""; }}]]></xp:this.style>
<xp:text escape="true" id="computedField3"><xp:this.value><![CDATA[#{javascript:return " " +ordnerData.getColumnValue('$92')}]]></xp:this.value></xp:text></xp:div></xp:td><xp:td><xp:text escape="true" id="computedField4" value="#{javascript:ordnerData.getColumnValue('$95')}"></xp:text>
</xp:td>
<xp:eventHandler event="ondblclick" submit="false">
<xp:this.script><![CDATA[var docid="{javascript:ordnerData.getDocument().getUniversalID()}";var link=""; var typee='#{javascript:viewScope.docUNID = ordnerData.getDocument().getUniversalID()}';
return XSP.openDialog('#{id:inPlaceDialog1}') ]]></xp:this.script> </xp:eventHandler> </xp:tr> </xp:repeat>
<xp:tr styleClass="xspPagerRow"><xp:td colspan="4" align="right" style="width:100%"> <xp:pager xp:key="headerPager" for="repeatList" id="pagerTop" partialRefresh="true" style="font-weight:inherit;margin-right:0.0px" layout="SeparatorPage Status FirstArrow Separator PreviousArrow Separator SeparatorPage Group Separator NextArrow Separator LastArrow"> </xp:pager>
</xp:td></xp:tr></xp:table>
UPDATE 2: Here is the dialog code that I try to load the document into
<xe:dialog id="inPlaceDialog1" title="Edit User">
<xp:panel>
<xp:this.data>
<xp:dominoDocument var="document1" formName="Reports"
action="editDocument" ignoreRequestParams="true">
<xp:this.documentId><![CDATA[#{javascript:viewScope.docUNID}]]></xp:this.documentId>
</xp:dominoDocument>
</xp:this.data>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="card-header bg-primary header-elements-inline">
<h5 class="modal-title">
<xp:text id="docUNID" value="#{viewScope.docUNID}"
escape="false">
</xp:text>
<xp:text escape="false" id="computedField1">
<xp:this.value><![CDATA[#{javascript:var txt = "YENİ RAPOR"; print(viewScope.docUNID);
if (viewScope.docUNID!=null)
txt = document1.getItemValueString("StatuText");
return txt;}]]></xp:this.value>
</xp:text>
</h5>
<div class="header-elements">
<div class="list-icons">
<div class="">
</div>
</div>
</div>
</div>
<div class="modal-header text-white header-elements-inline">
</div>
<xp:div styleClass="modal-body" id="divBody">
<h6 class="font-weight-semibold"></h6>
<!-- <input type="text" name="" id="txtId"></input> -->
<xp:div styleClass="form-group">
<xp:label value="Rapor Türü:" id="label1"
styleClass="text-uppercase col-form-label font-weight-bold">
</xp:label>
<xp:radioGroup id="RaporTuru" enabledClass="form-control border-primary">
<xp:this.value><![CDATA[#{javascript:var key = viewScope.docUNID;
if (key!=null)
{
var viewName = database.getView("viewReportsUnids")
var doc:NotesDocument = viewName.getDocumentByKey(key, true);
if (doc!=null)
{
return doc.getItemValueString("RaporTuru");
}
}}]]></xp:this.value>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:try
{
var rListe:Array = [];
rListe[0] = "Giriş Hareketleri";
rListe[1] = "Çıkış Hareketleri";
rListe[2] = "Giriş/Çıkış Hareketleri";
rListe[3] = "Güncel Stok Raporu";
return rListe;
}
catch(e)
{
logError(e.toString(),
session.getEffectiveUserName(),
facesContext.getExternalContext().getRequest().getRequestURL(),
this.getParent().getId(),
"xspFrmRapor");
}}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="divBody">
</xp:eventHandler>
</xp:radioGroup>
</xp:div>
<xp:div styleClass="form-group">
<xp:label value="Zaman Aralığı:" id="label4"
styleClass="text-uppercase col-form-label font-weight-bold">
</xp:label>
<xp:radioGroup id="RaporTipi" value="#{document1.RaporTipi}"
enabledClass="form-control border-primary">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:try
{
var rListe:Array = [];
rListe[0] = "Tümü";
rListe[1] = "Tarih Aralığı";
return rListe;
}
catch(e)
{
logError(e.toString(),
session.getEffectiveUserName(),
facesContext.getExternalContext().getRequest().getRequestURL(),
this.getParent().getId(),
"xspFrmRapor");
}}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="divBody">
</xp:eventHandler>
</xp:radioGroup>
</xp:div>
<xp:div styleClass="form-group">
<xp:label value="Lokasyon (Şantiye):" id="label6"
styleClass="text-uppercase col-form-label font-weight-bold">
</xp:label>
<xp:comboBox id="Lokasyon" value="#{document1.Lokasyon}"
styleClass="form-control">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:return "";}]]></xp:this.value>
</xp:selectItems>
<xp:selectItems id="selectItems6">
<xp:this.value><![CDATA[#{javascript:var rList = #DbColumn(sessionScope.personel_db_Path, "viewLokasyon01", 1);
return rList;}]]></xp:this.value>
</xp:selectItems>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:return "TÜMÜ";}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xp:div>
<xp:div styleClass="form-group">
<xp:label value="Stok Kategorisi:" id="label7"
styleClass="text-uppercase col-form-label font-weight-bold">
</xp:label>
<xp:checkBoxGroup id="StokKategori" value="#{document1.StokKategori}"
enabledClass="form-control">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var rList:java.util.Vector = new java.util.Vector();
rList.add("Parça");
rList.add("İşçilik");
rList.add("Yakıt");
rList.add("Yağ ve Adblue");
rList.add("Lastik");
return rList;}]]></xp:this.value>
</xp:selectItems>
</xp:checkBoxGroup>
</xp:div>
<xp:div styleClass="form-group">
<xp:label value="Başlangıç Tarihi:" id="label8"
styleClass="text-uppercase col-form-label font-weight-bold">
</xp:label>
<br></br>
<xe:djDateTextBox id="baslangicTarihi"
value="#{document1.baslangicTarihi}">
<xe:this.converter>
<xp:convertDateTime type="date" dateStyle="short">
</xp:convertDateTime>
</xe:this.converter>
<xe:this.dojoAttributes>
<xp:dojoAttribute name="placeholder" value="01.01.2022">
</xp:dojoAttribute>
</xe:this.dojoAttributes>
</xe:djDateTextBox>
</xp:div>
<xp:div styleClass="form-group">
<xp:label value="Bitiş Tarihi" id="label10"
styleClass="text-uppercase col-form-label font-weight-bold">
</xp:label>
<br></br>
<xe:djDateTextBox id="bitisTarihi" value="#{document1.bitisTarihi}"
styleClass="border-teal">
<xe:this.converter>
<xp:convertDateTime type="date" dateStyle="short">
</xp:convertDateTime>
</xe:this.converter>
<xe:this.dojoAttributes>
<xp:dojoAttribute name="placeholder" value="01.01.2022">
</xp:dojoAttribute>
</xe:this.dojoAttributes>
</xe:djDateTextBox>
</xp:div>
</xp:div>
</div>
</div>
</xp:panel>
</xe:dialog>

I did not use rowAttributes to open document from the viewPanel. I put the code which opens modal behind a column(I used the first column in the viewPanel) and in the dialog that is beeing opened from the viewPanel I have a Panel with datasourse. Document ID of Datasource is viewScope.DocUNId. When i click on a documetn (Selected document from viewPanel) I assing selected document's UniqueId to viewScope.docUNID and then It works very well..

Related

XPages: checkbox (groups) looses their value(s) when changing to edit mode

Crazy effect: I open a (previously saved) doc in read mode: Everthing is ok. When I change it into edit mode: All checkboxes are emptied. The other items (inputText, inputTextarea) on the xpage keep their values.
The effect doesn¨t occur when I open the page for the first time (of my browser session), but after that it happens every time.
code snippet:
<xp:panel id="pNewDoc" styleClass="panel panel-default">
<xp:this.data>
<xp:dominoDocument var="dshare" formName="dshare"
action="openDocument"
databaseName="webapp/peoplesearch/dshare.nsf">
<xp:this.documentId><![CDATA[#{javascript:viewScope.myUnid}]]></xp:this.documentId>
</xp:dominoDocument>
</xp:this.data>
<xp:this.rendered><![CDATA[#{javascript:viewScope.ShowDoc == "1"}]]></xp:this.rendered>
<div class="panel-heading">
<xp:label value="Desk Sharing Freigabe" id="label7"
for="inputText1" styleClass="panel-title">
</xp:label>
</div>
<xp:div styleClass="panel-body">
<div class="row hvrow">
<xp:label value="Owner" id="label2"
styleClass="col-sm-2 col-md-2">
</xp:label>
<xp:div styleClass="col-sm-4 col-md-4">
<xp:inputText id="inputText4"
value="#{dshare.anOwner}"
defaultValue="#{javascript:#UserName()}" disabled="true">
</xp:inputText>
</xp:div>
<xp:label value="Tel." id="label6"
styleClass="col-sm-2 col-md-2">
</xp:label>
<xp:div styleClass="col-sm-4 col-md-4">
<xp:inputText id="inputText5"
value="#{dshare.dsPhoneNumber}">
<xp:this.defaultValue><![CDATA[#{javascript:var
dbArray = [""];
dbArray.push("webapp/peoplesearch/psuser_20160610.nsf")
#DbLookup(dbArray,"lookupFullname",#UserName(),"OfficePhone")}]]></xp:this.defaultValue>
</xp:inputText>
</xp:div>
</div>
<div class="row">
<xp:label value="Von bis" id="label1"
styleClass="col-sm-2 col-md-2">
</xp:label>
<xp:div
styleClass="col-sm-4 col-md-4 form-inline">
<xp:inputText id="inputText1"
value="#{dshare.dsFrom}" style="width:45%">
<xp:dateTimeHelper id="dateTimeHelper3">
</xp:dateTimeHelper>
<xp:this.converter>
<xp:convertDateTime type="date"
dateStyle="short">
</xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
 - 
<xp:inputText id="inputText2"
value="#{dshare.dsTo}" style="width:45%">
<xp:dateTimeHelper id="dateTimeHelper4">
</xp:dateTimeHelper>
<xp:this.converter>
<xp:convertDateTime type="date"
dateStyle="short">
</xp:convertDateTime>
</xp:this.converter>
</xp:inputText>
</xp:div>
<xp:label value="Zeitspanne" id="label3"
styleClass="col-sm-2 col-md-2">
</xp:label>
<xp:div styleClass="col-sm-4 col-md-4">
<xp:checkBoxGroup id="checkBoxGroup1"
value="#{dshare.dsPeriod}">
<xp:selectItem itemLabel="Vormittag"
itemValue="V">
</xp:selectItem>
<xp:selectItem itemLabel="Nachmittag"
itemValue="N">
</xp:selectItem>
</xp:checkBoxGroup>
</xp:div>
</div>
<div class="row">
<xp:label value="Details" id="label9"
styleClass="col-sm-2 col-md-2">
</xp:label>
<xp:div styleClass="col-sm-10 col-md-10">
<xp:inputTextarea id="inputTextarea1"
style="width:100%" rows="5" value="#{dshare.dsDetails}">
</xp:inputTextarea>
</xp:div>
<xp:label value="Status" id="label10"
styleClass="col-sm-2 col-md-2">
</xp:label>
<xp:div styleClass="col-sm-4 col-md-4">
<xp:checkBox text="aktiv" id="checkBox1"
value="#{dshare.dsStatus}" checkedValue="activ"
uncheckedValue="inactiv" defaultChecked="true">
</xp:checkBox>
</xp:div>
</div>
</xp:div>
<div class="panel-footer" style="text-align:right">
<xp:button value="Bearbeiten" id="btEdit" type="submit"
rendered="#{javascript:!dshare.isEditable()}">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" immediate="false" save="false"
refreshId="pNewDoc" execMode="partial" execId="pNewDoc">
<xp:this.action>
<xp:changeDocumentMode mode="edit"></xp:changeDocumentMode>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button value="Speichern" id="btSave" type="submit"
rendered="#{javascript:dshare.isEditable()}">
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" immediate="false" save="false"
refreshId="pDSall" execMode="partial" execId="pDSall">
<xp:this.action><![CDATA[#{javascript:viewScope.ShowDoc = "0"
qsave(dshare);}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
</div>
</xp:panel>
Your button has the property type="submit":
<xp:button
value="Bearbeiten"
id="button2"
type="submit"
rendered="#{javascript:!dshare.isEditable()}">
...
It is responsible for your issue.
Just delete type="submit" and your check boxes will work with setting edit mode by partial refresh:
<xp:button
value="Bearbeiten"
id="btEdit"
rendered="#{javascript:!dshare.isEditable()}">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
immediate="false"
save="false"
refreshId="pNewDoc"
execMode="partial"
execId="pNewDoc">
<xp:this.action>
<xp:changeDocumentMode mode="edit"></xp:changeDocumentMode>
</xp:this.action>
</xp:eventHandler>
</xp:button>

Custom control inside repeat can't see rowData in one custom property, but work in other

I have following custom control:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.beforePageLoad><![CDATA[#{javascript:compositeData.id = this.getId();
if (!compositeData.body_class) {compositeData.body_class='panel-body'};
if (!compositeData.panel_id) {compositeData.panel_id='section'+compositeData.id};}]]></xp:this.beforePageLoad>
<xp:panel>
<xp:this.styleClass><![CDATA[#{javascript:"ccSectionPanel panel " + compositeData.panel_class + ""}]]></xp:this.styleClass>
<xp:this.attrs>
<xp:attr name="id">
<xp:this.value><![CDATA[#{javascript:compositeData.panel_id}]]></xp:this.value>
</xp:attr>
</xp:this.attrs>
<xp:panel styleClass="panel-heading" style="cursor:pointer;">
<xp:this.attrs>
<xp:attr name="id">
<xp:this.value><![CDATA[#{javascript:compositeData.panel_id + "_heading"}]]></xp:this.value>
</xp:attr>
<xp:attr name="href">
<xp:this.value><![CDATA[#{javascript:"#" + compositeData.panel_id + "_section"}]]></xp:this.value>
</xp:attr>
<xp:attr name="data-toggle" value="collapse"></xp:attr>
</xp:this.attrs>
<xp:link escape="true" styleClass="panel-title"
text="#{javascript:compositeData.titleBarText}">
<xp:this.attrs>
<xp:attr name="id">
<xp:this.value><![CDATA[#{javascript:compositeData.panel_id + "_title"}]]></xp:this.value>
</xp:attr>
</xp:this.attrs>
<xp:this.id><![CDATA[${javascript:compositeData.panel_id + "_title"}]]></xp:this.id>
</xp:link>
</xp:panel>
<xp:panel>
<xp:this.styleClass><![CDATA[#{javascript:"panel-collapse collapse" + (compositeData.initClosed ? "" : " in")}]]></xp:this.styleClass>
<xp:this.attrs>
<xp:attr name="id">
<xp:this.value><![CDATA[#{javascript:compositeData.panel_id + "_section"}]]></xp:this.value>
</xp:attr>
</xp:this.attrs>
<xp:panel
styleClass="#{javascript:compositeData.body_class}">
<xp:callback facetName="panelBody" id="panelBody"></xp:callback>
</xp:panel>
<xp:panel rendered="#{javascript:compositeData.footer}"
styleClass="panel-footer">
<xp:callback facetName="panelFooter" id="panelFooter"></xp:callback>
</xp:panel>
</xp:panel>
</xp:panel>
</xp:view>
I use it in a repeat control:
<xp:repeat id="repeat1" rows="30" value="#{view1}"
var="repEntry" indexVar="index" repeatControls="false">
<xp:panel>
<xp:this.data>
<xp:dominoDocument var="doc"
action="openDocument"
documentId="#{javascript:repEntry.getNoteID()}"
ignoreRequestParams="true">
</xp:dominoDocument>
</xp:this.data>
<xc:ccSectionPanel initClosed="false"
panel_class="#{javascript:repEntry.getColumnValue('class')}"
footer="#{javascript:sessionScope.isAdmin}"
rendered="#{javascript:repEntry.getColumnValue('Status') == '1' || sessionScope.isAdmin}">
<xc:this.titleBarText><![CDATA[#{javascript:repEntry.getColumnValue('Title') + (repEntry.getColumnValue('Status') != '1' ? ' (скрыто)' : '')
}]]></xc:this.titleBarText>
<xp:this.facets>
<xp:panel xp:key="panelFooter">
<xp:button value="Редактировать"
id="button2" styleClass="btn btn-xs">
<i
class="glyphicon glyphicon-pencil">
</i>
<xp:eventHandler event="onclick"
submit="true" refreshMode="complete">
<xp:this.action>
<xp:openPage
name="/index.xsp" target="editDocument"
documentId="#{javascript:repEntry.getNoteID()}">
</xp:openPage>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button
value="#{javascript:repEntry.getColumnValue('Status') != '1' ? 'Показать' : 'Скрыть'}"
id="button3" styleClass="#{javascript:'btn btn-xs'}">
<i
class="#{javascript:repEntry.getColumnValue('Status') != '1' ? 'glyphicon glyphicon-eye-open' : 'glyphicon glyphicon-eye-close'}">
</i>
<xp:eventHandler event="onclick"
submit="true" refreshMode="partial" disableValidators="true"
refreshId="content">
<xp:this.action><![CDATA[#{javascript:if (repEntry.getColumnValue('Status') == '1') {
doc.replaceItemValue('Status','0');
doc.replaceItemValue('Author',sessionScope.User.UserName);
doc.save();
} else {
doc.replaceItemValue('Status','1');
doc.replaceItemValue('Author',sessionScope.User.UserName);
doc.save();
}}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:text escape="false"
id="computedField2" styleClass="btn btn-xs">
<xp:this.value><![CDATA[#{javascript:'<i class="glyphicon glyphicon-user"></i>' + repEntry.getColumnValue('Author') + ' <i class="glyphicon glyphicon-time"></i>' + repEntry.getColumnValue('$1')
}]]></xp:this.value>
</xp:text>
</xp:panel>
<xp:panel xp:key="panelBody">
<!-- <xp:this.data>
<xp:dominoDocument var="doc" action="openDocument"
documentId="#{javascript:repEntry.getNoteID()}"
ignoreRequestParams="true">
</xp:dominoDocument>
</xp:this.data> -->
<xp:inputRichText
id="inputRichText2" value="#{doc.Body}" readonly="true"
rendered="false">
</xp:inputRichText>
<xp:text escape="false"
id="computedField1">
<xp:this.value><![CDATA[#{javascript:doc.getDocument().getFirstItem("Body").getMIMEEntity().getContentAsText(); }]]></xp:this.value>
</xp:text>
</xp:panel>
</xp:this.facets>
</xc:ccSectionPanel>
</xp:panel>
</xp:repeat>
When i set cumputed properties,
It works, but when i set panel_id to something relative to repEntry or doc, it throws error (repEntry is undefined). I can set "Create controls at page creation", but then I lose advantages of partial refresh.
The main question, why one costom property can work with repEntry, but other can't?
The answer comes down to when the property gets calculated. Compute it and add a print statement in the SSJS code and you'll see. IDs need to be calculated when the components get loaded, so at the earliest part of the processing. And most importantly this is when it's generating a single abstract set of components, not associated to a particular row entry, because it's not yet built the collection. Think of it like creating an abstract class before creating objects from it.

Visibility property not working as expected on XPage

Based upon the value/selection in a radiobutton group control I want to display another div containing an edit box control.
The code does not work as expected. Although the scope variable is set, the div never appears again when the visibility is set to false and I change the radiobutton selected value to Yes.
What am I doing incorrect?
<div class="form-group">
<label class="control-label col-sm-4">Membership</label>
<div class="col-sm-8">
<xp:radioGroup value="#{employeeBean.employee.stafMember}" binding="#{stafMember}"
id="stafMember">
<xp:selectItem itemLabel="Yes" />
<xp:selectItem itemLabel="No" />
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="stafMemberDept" disableValidators="true">
<xp:this.action><![CDATA[#{javascript:var thisVal = getComponent("stafMember").getValue();
viewScope.put("stafMember", thisVal);}]]></xp:this.action>
</xp:eventHandler>
</xp:radioGroup>
</div>
</div>
<xp:div styleClass="form-group"
id="stafMemberDept">
<xp:this.rendered><![CDATA[#{javascript:var thisVal = viewScope.get("stafMember");
if(thisVal=="Yes"){
return false;
}
else if (thisVal == "No"){
return true;
}
else{
return false;
}}]]></xp:this.rendered>
<!-- just some fields to test the value of the radio group -->
<xp:text escape="true" id="computedField1"
value="#{javascript:stafMember.getValue()}">
</xp:text>
<xp:text escape="true" id="computedField2">
<xp:this.value><![CDATA[#{javascript:getComponent("stafMember").getValue()}]]></xp:this.value>
</xp:text>
<xp:text escape="true" id="computedField3">
<xp:this.value><![CDATA[#{javascript:"v" + viewScope.get("stafMember") + "v"}]]></xp:this.value>
</xp:text>
<label class="control-label col-sm-4"
style="font-size: 75%">
Department:
</label>
<div class="col-sm-8">
<xp:inputText id="inputText1"></xp:inputText>
</div>
</xp:div>
You need to refresh a component that stays in the component tree in order to show/hide components. So surround your stafMemberDept div with annother div that you then refresh:
<xp:div id="divToBeRefreshed">
<xp:div styleClass="form-group" id="stafMemberDept">
<xp:this.rendered>
<![CDATA[#{javascript:var thisVal = viewScope.get("stafMember");
if(thisVal=="Yes"){
return false;
}
else if (thisVal == "No"){
return true;
}
else{
return false;
}}]]>
</xp:this.rendered>
<!-- just some fields to test the value of the radio group -->
<xp:text escape="true" id="computedField1" value="#{javascript:stafMember.getValue()}">
</xp:text>
<xp:text escape="true" id="computedField2">
<xp:this.value>
<![CDATA[#{javascript:getComponent("stafMember").getValue()}]]>
</xp:this.value>
</xp:text>
<xp:text escape="true" id="computedField3">
<xp:this.value>
<![CDATA[#{javascript:"v" + viewScope.get("stafMember") + "v"}]]>
</xp:this.value>
</xp:text>
<label class="control-label col-sm-4" style="font-size: 75%">
Department:
</label>
<div class="col-sm-8">
<xp:inputText id="inputText1"></xp:inputText>
</div>
</xp:div>
</xp:div>

Xpages: Dynamic View Panel - Sorting

In my dynamic view panel, I need to have sortable columns. Problem is when sorting a column it resubmits the XPage and whole content is refreshed. Is there a way to achieve sorting only on the dynamic view panel without submitting whole page? Also, I want to hide this control if selected view is empty.
Here is my code:
<xp:panel id="searchPanel">
<xp:table styleClass="table table-condensed" style="width:auto">
<xp:tr>
<xp:td style="border-top:0px" styleClass="text-nowrap" id="searchColumn">
<xp:inputText id="inputText1" value="#{viewScope.searchterm}" styleClass="form-control"></xp:inputText>
<xp:link escape="true" text="" id="searchLink">
<i class="fa fa-search" style="margin-left:5px"></i>
<xp:eventHandler event="onclick" refreshMode="partial" immediate="false" submit="true" refreshId="ddPanel">
<xp:this.action><![CDATA[#{javascript:var pager:com.ibm.xsp.component.xp.XspPager = getComponent("pager");
pager.gotoFirst();}]]></xp:this.action>
</xp:eventHandler>
</xp:link>
<xp:link escape="true" text="" id="clearSearchLink">
<i class="fa fa-times" style="margin-left:5px"></i>
<xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="ddPanel" onComplete="showHideTableToggle()">
<xp:this.action><![CDATA[#{javascript:viewScope.remove("searchterm");}]]></xp:this.action>
<xp:this.script><![CDATA[dojo.byId(getID("inputText1")).value=""]]></xp:this.script>
</xp:eventHandler>
</xp:link>
</xp:td>
<xp:td style="border-top:0px;padding-left:20px">
<xp:link escape="true" id="addButton" onclick="return false;" styleClass="btn btn-primary" style="color:rgb(255,255,255)" text="Add">
<i class="fa fa-plus" style="margin-right:5px"></i>
<xp:eventHandler event="onclick" submit="false" refreshMode="complete">
<xp:this.script><![CDATA[XSP.openDialog(getID('contentDialog'),'',{"docID":"","newDoc":"false"});]]></xp:this.script>
</xp:eventHandler>
</xp:link>
</xp:td>
</xp:tr>
</xp:table>
<xp:panel id="ddPanel">
<xe:dynamicViewPanel id="mainView" width="100%" dataTableStyleClass="table table-bordered table-condensed table-hover" rows="10" var="myView"
showColumnHeader="true" customizerBean="com.hcl.igdm.PickerViewBeanMainViews" partialRefresh="true" refreshId="ddPanel"
>
<xe:this.data>
<xp:dominoView var="mainDataView" dataCache="nodata">
<xp:this.viewName><![CDATA[#{javascript:sessionScope.showView.split("~")[0]}]]></xp:this.viewName>
</xp:dominoView>
</xe:this.data>
<xe:this.rowAttrs>
<xp:attr name="onClick">
<xp:this.value><![CDATA[#{javascript:return "javascript:myJSFunction();"}]]></xp:this.value>
</xp:attr>
</xe:this.rowAttrs>
</xe:dynamicViewPanel>
<xp:pager layout="Previous Group Next" partialRefresh="true" id="pager" for="mainView" title="Pager"></xp:pager>
</xp:panel>
It's a long time ago this question was placed... but maybe the answer can help other people.
You can put the dynamicViewPanel into a 'dynamic content' container (from ExtLib) with partial events attribute set to true. This will convert the full update events into partial refresh events.
<xe:dynamicContent partialEvents="true">
...
</xe:dynamicContent>

Xpages display attachment in dialog box from another document

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

Resources