I have found a few similar questions to this in stackoverflow but nothing exactly matches. I am attempting to amend an Xpages project where the search results are shown in a Dynamic View Panel. The first column of the search results is a link that opens the record in the same page. What I want to do is have this link open the record in a seperate page. It is the "Dynamic" part of the view that is confusing I think as there is no "Column Name" or "Column View" to add in a window.open or a target="_blank" that I can see. How would I go about this please?
The relevant section of the XPage only has the following;
<xp:panel id="maincontentpanel">
<xe:dynamicViewPanel rows="30" id="dynamicViewPanel1" width="100%">
<xe:this.data>
<xp:dominoView viewName="(keywordsUser)" var="view">
</xp:dominoView>
</xe:this.data>
</xe:dynamicViewPanel>
</xp:panel>
When viewing the source in HTML the clickable column shows the following;
<tr>
<td class="xspColumnViewStart">
<a id="view:_id1:cc4cconeuilayout:OneUIMainAreaCallback:dynamicViewPanel1:0:_id6:_internalColumnLink"
href="*routetoourrecord*";action=editDocument"
class="xspLinkViewColumn">2014</a>
</td>
Dynamic View Panel has a property "target" in All Properties where you can select "_blank". This should add the attribute target="_blank" to the links in first column. But, unfortunately, this works in Notes client only.
So, there is no property we just can set. Luckily, rendered links have an own class "xspLinkViewColumn" (see your source HTML example). With dojo.query we can get all elements with this class and add the target attribute on client side.
Just add following event code to your XPage:
<xp:eventHandler
event="onClientLoad"
submit="false">
<xp:this.script><![CDATA[
dojo.query(".xspLinkViewColumn").attr("target", "_blank");
]]></xp:this.script>
</xp:eventHandler>
All links will get the attribute target="_blank" this way and documents will be opened in a new browser tab.
Just to let know the code does not to work with the Bootstrap theme.
Instead you can use
dojo.query('[id$="_internalColumnLink"]').attr("target", "_blank");
Related
I am trying to delete the selected item in the Xpages repeat control, but it does not work. Please help?
Here is my code in the repeat control section
<xp:repeat id="repeat1" rows="30" var="eachQuestion" value="#{questions}"
indexVar="rowIndex">
<tr>
<td>...</td>
<td> <xp:link styleClass="btn btn-danger" id="deleteLink">
<xp:eventHandler event="onClick"
action="#{javascript:eachQuestion.getDocument().remove(true);}"
submit="true"
refreshMode="partial"
refreshId="listContainer" />
<i class="fa fa-lg fa-trash-o" />
</xp:link> </td>
</tr>
</xp:repeat>
Here is what I can see in the client page, generated html and JS code:
XSP.addOnLoad(function() {
XSP.attachPartial("view:_id1:repeat1:0:_id44","view:_id1:repeat1:0:deleteLink", null, "onClick", function(){}, 2, "view:_id1:listContainer");
When I click the delete link icon, nothing happened.
I realized function(){} nothing in there.
Is there anything wrong or I have to implement the method in the Java code to handle this deletion?
Thanks,
You just have to change "onClick" to "onclick" in your code and it will work.
Case sensitivity does matter in Xpages. So, your code to delete a document is right but the event "onClick" doesn't gets executed at all.
You don't say what "questions" is. I assume it's a view. The code looks right to me. You certainly do NOT need Java to delete a document from a rpw in a repeat control.
I would ignore the client side stuff. That's server generated. It's supposed to be empty I think. The server knows what to do.
First check the database ACL. Make sure the user has delete access. I'd also add a Display Errors control on the page. If it's not deleting due to a validation issue it should show there. Then I'd go to OpenNTF and get the XPages Log Reader control. It's a small xpages database that let's you see errors more easily.
I'd start with those ideas.
By the way that's not a good way to do a table in a repeat control. It should be producing invalid HTML. You should use Facets. That is NOT your problem though.
I have been given an XPages project which I did not develop. The project has a OneUILayout that includes a Search Bar "facet". Is it possible to code a filter into the search bar facet so that retrieved records are omitted that have a field with a certain value. I have very little experience with XPages. The search results are output to a OneUI_searchpage.xsp where an edit box displays the search string then a dynamic View Panel shown the retrieved records. I have attached the source code for these two items below. Thank you
<xp:label value="Search String:" id="label1"></xp:label>
<xp:inputText id="inputText1" value="#{param.search}"></xp:inputText>
<xp:panel id="maincontentpanel">
<xe:dynamicViewPanel rows="30" id="dynamicViewPanel1"
width="100%">
<xe:this.data>
<xp:dominoView viewName="ContractsFlatByYear"
var="view">
<xp:this.search><![CDATA[#{javascript:return
param.search;}]]></xp:this.search>
</xp:dominoView>
</xe:this.data>
</xe:dynamicViewPanel>
After some consultation with stwissel below, I amended the application to have a check box on the search results xpage with it checked by default and created an additional view for the same output. One view to show cancelled contracts and one to omit cancelled contracts. The relevant Xpage section now looks like as follows;
<xp:checkBox text="Omit Cancelled Contracts"
id="OmitCancelled" defaultChecked="true" checkedValue="True"
uncheckedValue="False" style="padding-left:5.0em" value="#
{viewScope.viewSel}">
<xp:eventHandler event="onchange" submit="true" refreshMode="partial"
refreshId="dynamicViewPanel1"></xp:eventHandler>
</xp:checkBox>
<xp:panel id="maincontentpanel">
<xe:dynamicViewPanel rows="30" id="dynamicViewPanel1"
width="100%" partialRefresh="true">
<xe:this.data>
<xp:dominoView var="view">
<xp:this.viewName>
<![CDATA[#{javascript:var cancelledYesNo = viewScope.viewSel
= getComponent("OmitCancelled").getValue();
if(cancelledYesNo == "True"){
viewName = "ContractsFlatByYear"}
else {
viewName = "ContractsFlatByYearandCancelled"}}]]>
</xp:this.viewName>
<xp:this.search><![CDATA[#{javascript:return param.search;}]]
></xp:this.search>
</xp:dominoView>
</xe:this.data>
</xe:dynamicViewPanel>
This appears to work but I have the check box onChange event to apply a partial refresh on the dynamicviewpanel but only refreshes when I click on the dynamicviewpanel itself
The search bar facet only captures what you want to search and sends it to the specified XPages for processing.
You have 2 options:
Alter the facet to send the additional condition to the search page
Alter the search function in the search page (the one the query gets posted to) to filter that (if it is static).
Be aware: filtering in code is not a security feature (in case you were intending that). There's reader and author fields for that.
XPages in its core is JSF with some specialities around Domino. You might want to check out my article series on them.
Update
Based on the code snippet, your can get the desired result quite fast. Edit the view selection formula and add & conContractStatus <> "cancelled". You need to check first if that view is used elsewhere to show canceled contracts too. If that is the case, copy the view (eg add Active behind the name) and make the changes there.
Update 2
Your code doesn't return a value and you don't need to get to the component
<xp:this.viewName>
<![CDATA[#{javascript:return (viewScope.viewSel=="True") ? "ContractsFlatByYear" : "ContractsFlatByYearandCancelled";}]]>
</xp:this.viewName>
Let us know how it goes
I have an Xpage that has instructions for users to get a widget into their Sidebar. I was going to send out the instructions in an email but I thought I should just embed it in an Xpage. Everything works, but I would like to have the file in the Xpage and have the users have the ability to drag and drop it right into My Widgets. I cannot see how to do this.
So far I have saved the file as a file resource. How can I connect that resource to a control in the Xpage?
Could I embed a view in the Xpage?
Or a Link?
<xp:fileDownload rows="30" id="fileDownload1"
displayLastModified="false">
</xp:fileDownload>
<xp:link escape="true" text="Link" id="link1"
target="_blank">
</xp:link>
</xp:td>
Just create a link to the file resource. Here's an example (assuming that your file resource is called widget.xml):
<xp:link escape="true" text="Link to widget" id="link1" value="/widget.xml"></xp:link>
The user should then be able to drag and drop that link to the My Widgets sidebar.
I'm using the Extension Library and XPages to build a web based workflow application. One feature is to prompt a dialog and select the next approver before submitting it forward.
For new documents, the dialog appears, and it also appears when in read mode. It never opens for a saved document. I need it to work in SSJS, though the dialog does open in CSJS. Here is some of the code:
xpMain.xsp contains two custom controls: ccButtons and ccWFloDialogs.
ccButtons "Submit" button:
getComponent('dlgNextOwner').show();
ccWFloDialogs "dlgNextOwner" dialog:
<xe:dialog id="dlgNextOwner" title="Select Supervisor">
<xe:formTable id="ftDlgNextOwner" formTitle="Select Supervisor"
formDescription="You may select a different supervisor."
disableErrorSummary="true">
<xp:this.facets>
<xe:formRow id="formRow1" xp:key="footer" for="txtWFloNextOwner"
labelWidth="125px">
<xp:inputText id="txtWFloNextOwner" style="width:200px"
value="#{viewScope.nextOwner}">
</xp:inputText>
<xe:namePicker id="npNextOwner" dialogTitle="Select Supervisor"
for="txtWFloNextOwner">
<xe:this.dataProvider>
<xe:dominoNABNamePicker addressBookSel="all-public"></xe:dominoNABNamePicker>
</xe:this.dataProvider>
</xe:namePicker>
</xe:formRow>
</xp:this.facets>
</xe:formTable>
</xe:dialog>
In CSJS, I can use the following code and it successfully opens the dialog:
XSP.openDialog("#{id:dlgNextOwner}");
I'm also using Mark Hughes' picklist from the extension library, and if I remove the panel which contains the control and data source, the dialog shows up in SSJS! The code is in a custom control, although, if it's directly in the XPage, the problem is the same. Here is the code for the panel:
<xp:panel
id="vendorDiv">
<xp:this.data>
<xp:dominoView
var="nvVend"
viewName="V_Vend"
ignoreRequestParams="true"
databaseName="other/lookupdb.nsf"
startKeys="#{javascript:viewScope.srchVend}">
</xp:dominoView>
</xp:this.data>
<xe:formTable
id="ftGetVendor"
disableErrorSummary="true"
labelPosition="above">
<xe:formRow
id="frVendor"
for="cfVendorName"
label="Name of the Vendor:">
<xp:text
escape="true"
id="cfVendorName"
value="#{currentDocument.VendorName}"
style="width:200px">
</xp:text>
<xc:viewpicklist
rowsPerPage="15"
buttonImage="./add.png"
tableClass="tablecellgreen"
headerClass="headerclass"
rowClass="odd, even"
searchBar="false"
searchButtonText="Search"
searchButtonClass="button2"
searchBarClass="headerclass"
pagerStyleFirst="navbutton1"
pagerStylePrevious="navbutton2"
pagerStyleCurrent="navbutton4"
pagerStyleNext="navbutton2"
pagerStyleLast="navbutton3"
typeAheadBar="true"
select="Column"
onReturn="Set Scope Value"
bottomBarClass="bottomround headerclass"
cancelButtonText="Cancel"
cancelButtonClass="button2 floatthisright"
type="Single Value"
finishButtonText="Finish"
finishButtonClass="button2 floatthisright"
multiSelectButtonAddImg="./add.png"
multiSelectButtonRemoveImg="./delete.png"
picklistButtonClass="button"
openDialogWith="Link"
picklistLinkImg="./add.png"
multiSelectLinkAddImg="./add.png"
multiSelectLinkRemoveImg="./delete.png"
selectWith="Link"
clearSearchImg="./cross.png"
SelectCellWidth="30px"
dialogID="dlgVend"
dialogTitle="Select a Vendor"
dialogWidth="80%"
refreshID="vendorDiv"
ssjsSelectFunction="getVendorInfo"
varName="viewScope.vendorInfo"
datasrc="nvVend"
selectColumn="4"
linkImg="./add.png"
typeAheadVar="viewScope.srchVend">
<xc:this.viewColumn>
<xp:value>0</xp:value>
<xp:value>1</xp:value>
<xp:value>2</xp:value>
<xp:value>3</xp:value>
</xc:this.viewColumn>
</xc:viewpicklist>
</xe:formRow>
<xe:formRow
id="frVendorStatus"
for="cfVendorStatus"
label="Vendor Registration Status:">
<xp:text
escape="true"
id="cfVendorStatus"
value="#{currentDocument.VendorStatus}">
</xp:text>
</xe:formRow>
<xe:formRow
id="frVendorCountry"
for="cfVendorCountry"
label="Country Name:">
<xp:text
escape="true"
id="cfVendorCountry"
value="#{currentDocument.VendorCountry}">
</xp:text>
</xe:formRow>
</xe:formTable>
</xp:panel>
The requested vendor information populates the fields, without any problem or errors. However, something here seems to prevent dialogs from opening up using SSJS.
Can anyone see anything obvious I'm missing? The data source is in the panel, ignoreRequestParams is true (otherwise it doesn't work).
The main data source is in the entire XPage context. I tried to add the ccWFloDialog custom control outside the main panel, and change the data source to the panel, but that didn't work.
Any ideas?
Forget the dialog for now. This is probably data source related. Suggest you get it working just on the xpage first. With visible fields. then maybe use the rendered property to get it working on the xpage similar to how the dialog would appear. Once you have that working then you should be good to apply to dialog. This idea is to just take the dialog out of the equation first to make sure it works normally.
Instead, I decided to open the dialogs using CSJS, instead of SSJS. I've changed some of logic, and will have a bit more to do to finish this part of the project. Thanks to all!
Is there any way to open the document in a new browser tab when the link in a view panel is clicked?
You have two options. one is the way that Tim explained. And another, you can compute the view column value as link. There you can use the _new or _blank property.
Simply say, View Column can be given as a HTML. There you can compute the page with html href tag.
"target" is one of the properties of the view panel component. If you specify "_blank" (as Ferry suggested) as the value of that property, it should apply it to the link for each row. But bear in mind, you're ultimately at the mercy of the end user's browser settings. One user may get a new tab, another may get an entirely new window, and yet another might get nothing because the link was treated as a popup and blocked.
This is a browser setting only. You only have to put target="_blank" in the link.
After trying this I decided against using it for a number of reasons but want to post the procedure below to implement it.
On the view column Display tab select computed value and enter a formula as follows:
var _row:NotesXspViewEntry = viewEntry;
var _unid = _row.getUniversalID();
return "<a href='0/" + _unid + "?OpenDocument' TARGET='_new'>" + _row.getColumnValue("RequestNum") + "</a>"
On the Display Tab select HTML.
Just adding another option to the mix.
If you set Column Display as 'hidden' you can then put a standard link control in the column. E.g. if the desired column link text was a 'First Name' column, which opened a new tab to the page 'Person.xsp'
<xp:viewColumn columnName="firstName" id="vcFirstNameCol" displayAs="hidden">
<xp:viewColumnHeader value="First Name" id="vchFirstName"></xp:viewColumnHeader>
<xp:link escape="true" text="#{javascript: rowData.getColumnValue('firstName');}" id="link1" value="Person.xsp"
target="_blank">
<xp:this.parameters>
<xp:parameter name="documentId" value="#{javascript:rowData.getUniversalID();}"></xp:parameter>
<xp:parameter name="action" value="openDocument"></xp:parameter>
</xp:this.parameters>
</xp:link>
</xp:viewColumn>