问题
There are 2 datasources: Cdoc
( the doc. content ) and the Pdoc
( inside a dialog ).
These 2 datasources are linked together based on the Cdoc'UNID
.
My main view panel is like this:
[_A_common_field] from Cdoc1 and all Pdocs from Cdoc1 ( this column is categorized )
Cdoc1
Pdoc 1 from Cdoc1
Pdoc 2 from Cdoc1
[_A_common_field] from Cdoc2 and all Pdocs from Cdoc2 ( this column is categorized )
Cdoc2
Pdoc 1 from Cdoc2
How can I compute the target property from my viewPanel1
considering the fact that I want Pdoc
to be opened in the dialog ( as it was created ) and Cdoc
to be opened in the 'clasical' mode as it was when the target
property wasn't added ?
回答1:
This answer assumes you are trying to open up the selected document from the view panel in the dialog. (In essence, open a dialog with the values from document listed in an embedded view)
forward
More than likely I would just open the document in another window and be done with it. But if you want to open this in a dialog, fine. If you define the data source in the dialog itself, be warned that I personally have had issues with such approaches in the past and I think that the datasources should be defined in the xpage view level.
answer
1. Do not allow any links in the view.
2. Have a checkbox available in the view.
3. Add a button where you will get the NoteID of the selected document, also making sure that a document was selected.
var vwpnl = getComponent("homeViewPanel");
var docIDArray = vwpnl.getSelectedIds();
if(docIDArray.length != 1){
view.postScript("alert('"+MessageController.getMessageForCurrentUser("msg_SelectOneDocument") +"')");
return;
}
var firstID = docIDArray.length > 0 ? docIDArray[0] : "";
return firstID;
(you can ignore the MessageController as that is one of my helper classes for language specific user messages.)
4 use that noteID (whether in viewScope or not) in the calculation of the data source in the dialog making certain that dialog has the correct settings, like refreshing etc.
EDIT
The good part about keeping this approach (performance aside) in your toolbox is that once you get a handle on the document itself, you can compute anything. using the noteID just to set a dialog property is just one example. You could create a document object and use the values to do anything you want, including opening another page, other actions, basically whatever you want. It might not be the best option for your current use case (you did not really specify your use case), but for future readers it will hopefully be a help.
回答2:
You dont need the view panel target function. Try with a dataView (xe:dataview) where:
[_A_common_field]
is for categorieColumn
Cdoc1
is for summaryColumn
and the System will create the OpenLink for Cdoc
<xe:dataView id="dataView2" columnTitles="true"
pageName="/Cdoc_Write.xsp" rowStyleClass="xspHtmlTrView"
openDocAsReadonly="true" collapsibleDetail="true"
collapsibleRows="true" var="viewEntry">...
Then create a new customControl (CC) and paste it into Details section.
Into the CC you need a table with 3 Columns and a Repeat-Control. With xe:repeat you will create the PDoc's into a tr like this:
<xp:table>
<xp:repeat rows="30" id="repeatResults" var="resultDoc"
repeatControls="false" first="0" indexVar="indexResults">
<xp:this.value><![CDATA[#{javascript:if (viewEntry.isDocument()){
var strUniqueID = viewEntry.getDocument().getItemValueString("Cdoc'UNID");
if(null != strUniqueID & ""!=strUniqueID) {
var teamsView = database.getView("All_PDocs4Cdoc");
return teamsView.getAllDocumentsByKey(strUniqueID);
}
}}]]></xp:this.value>
<xp:tr>
<xp:td >Pdoc[j] from Cdoc[i]</xp:td>
<xp:td > modal or tooltip dialog link</xp:td>
<xp:td > Dialog - Form</p:td>
</xp:tr>
</xp:repeat>
</xp:table>
The 2nd column ist for the link to open the PDoc into a Dialog -> see XPages Extension Library Demo / in Context Dialog.
The 3rd. td contain the hide dialog form for Pdoc.
BTW the 1st. td contains Values from Pdoc[j] e.g. Subject
回答3:
As per what I understand from your question, this is what I will do, please correct me if I am wrong or missing anything here:
<?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:dominoView var="dominoView" viewName="ADR2"
search="#{javascript:param.searchValue}" dataCache="full">
</xp:dominoView>
</xp:this.data>
<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="label1"></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:image id="image1" style="width:12px" url="#{javascript:return findImage(ordnerData.getColumnValue('aIcon'));}"></xp:image></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:link id="link1">
<xp:this.rendered><![CDATA[#{javascript:ordnerData.getChildCount() > 0}]]></xp:this.rendered>
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="viewPanela" immediate="true">
<xp:this.action><![CDATA[#{javascript:ordnerData.toggleExpanded()}]]></xp:this.action>
</xp:eventHandler>
<xp:image id="image5" alt="Toggle Row">
<xp:this.url><![CDATA[#{javascript:if(ordnerData.isExpanded()){
return("/tree_minus.gif");
}else{
return("/tree_plus.gif");
}}]]></xp:this.url>
</xp:image>
</xp:link>
<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 typ="#{javascript:ordnerData.getDocument().getItemValueString('aTyp')}";
link='xx_openPageN.xsp?aTyp='+typ+'&action=openDocument&documentId='+docid;
window.open(link,'New','width=1000, height=650, left=250px, top=250px, menubar=no, resizable=0, scrollbars=yes');
]]></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>
</xp:view>
Explanation
I have a simple dominoView as a viewSource which in your case would be a categorized view with Cdoc and Pdoc as response document. To determine the current clicked document , there is a simple javascript you can use:
if(level != null && level > 0)
return "Is a PDoc with document id "+ordnerData.getDocument().getUniversalID();
else
return "Is a CDoc with document id "+ordnerData.getDocument().getUniversalID();
Now, this allows you to perform different computation on different document. If you see my example, I just open a new window with the respective document in edit mode. You can have conditions based on your requirement here (eg. PDoc in a dialog and CDoc in a window). Please let me know if anything is not clear or missing. Sorry for being late on this. Hope this solves your problem.
来源:https://stackoverflow.com/questions/24423030/xpages-on-click-event-from-view-panel-column-pop-up-dialog-forms-from-views