xpages deleted selected documents: other actions - view

a xpages contain view, and a button with simple action: deleted selected documents
the question: how to insert another action before deleting process, because I need to delete documents on other database.
The docs will be deleted on other database have the same subject the documents will be deleted in view
How to insert another action for it?
Thank you

You need to define the desired number of actionGroups. Something like this:
<xp:button value=" My Button" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action>
<xp:actionGroup>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript://your code in javascript - before the delete method]]>
</xp:this.script>
</xp:executeScript>
</xp:actionGroup>
<xp:actionGroup>
<xp:actionGroup>
<xp:deleteSelectedDocuments view="viewPanel1"
message="Confirm?">
</xp:deleteSelectedDocuments>
</xp:actionGroup>
</xp:this.action>
</xp:button>

You can use the the following code to get a handle to the selected documents in view. No you can delete documents in an other database and after that you can delete the document.
var docIds = getComponent("view1").getSelectedIds()
for(var i=0; i< docIds.length; i++){
var doc:NotesDocument = database.getDocumentByUNID(docIds[i]);
//Manipulating other documents
doc.removePermanently(true)
}

Related

Xpages filter and sort data in a repeat control?

I have a repeat control which displays a list of Attachments, which are saved as response documents to the current document. Right now I just see all the main docs and response docs in a list. How do I 1) Filter the view to only to include the response docs and not main docs? 2) Filter the view to only include responses to the current document?
I tried using the Filter by column value on the datasource, but I can't figure it out.
My Xpage datasources are "document1" document and "Requirements" view
<xp:dominoView var="Atts" viewName="Requirements">
</xp:dominoView>
<xp:repeat id="AttsContainer" rows="100"
var="Attachments" repeatControls="true" value="#{Atts}">
<xp:panel id="AttsPanel">
<xp:table style="width:100.0%;border-width:thin;border-color:rgb(0,0,0);border-style:solid">
<xp:tr>
<xp:td style="width:234.0px">
<xp:text escape="true"
id="computedField1" value="#{Attachments.AttName}">
</xp:text>
</xp:td>
<xp:td><xp:text escape="true" id="computedField2">
<xp:this.value><![CDATA[#{javascript:var doc:NotesDocument = Attachments.getDocument();
var sUNID = doc.getUniversalID();
sUNID}]]></xp:this.value>
</xp:text></xp:td>
<xp:td>
<xp:link escape="true"
id="link2">
<xp:this.text><![CDATA[#{javascript:Attachments.getColumnValue("Files")}]]></xp:this.text>
<xp:this.value><![CDATA[#{javascript:var doc:NotesDocument = Attachments.getDocument();
var sUNID = doc.getUniversalID();
ATT = Attachments.getColumnValue("Files");
"/bid.nsf/0/" + sUNID + "/$FILE/" + ATT}]]></xp:this.value></xp:link></xp:td>
</xp:tr>
</xp:table></xp:panel>
From the top of my head:
Create a view showing only the documents created with the response's form.
Disable the "show response documents in a hierarchy" property
Add a categorized first column with this formula: #Text($ref)
That gives you a view where all responses are categorized by their parents unid. You use that view in the data source and set the categoryFilter the the unid of the main document.

Xpages radio button validation by groupName?

I have radio buttons in a table with the same groupName.
Is there a relatively simple way to validate this field upon submitting the form without using CCJS?
<xp:td>
<xp:radio id="radio120" groupName="R_1" value="#{document1.R_1}" selectedValue="1"></xp:radio>
</xp:td>
<xp:td>
<xp:radio id="radio120" groupName="R_1" value="#{document1.R_1}" selectedValue="2"></xp:radio>
</xp:td>
With regular Radio Button Group controls, I use validateRequired with an errorMessage control to display a message.
<xp:radioGroup styleClass="A2" style="border:0px;" value="#{document1.Necktie}" layout="pageDirection" id="Necktie">
<xp:this.validators>
<xp:validateRequired message="REQUIRED!"></xp:validateRequired>
</xp:this.validators>
<xp:selectItem itemLabel="No" id="selectItem13"></xp:selectItem>
<xp:selectItem itemLabel="Yes" id="selectItem14"></xp:selectItem>
</xp:radioGroup>
<xp:message id="message10" for="Necktie"></xp:message>
Use the data source document1 on server side to find out if one of your radio buttons was selected.
Test for document1.getItemValueString("R_1"). If it is empty set an error message and return false. Otherwise save the document.
<xp:button value="Save" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:
if (document1.getItemValueString("R_1") == "") {
facesContext.addMessage(null,
new javax.faces.application.FacesMessage("select a radio"));
return false;
}
document1.save();
}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:messages id="messages1" />
Fair enough... In that case, outside of doing something with CSJS, I'm not too sure....
Not sure if this is going to help, but have a look at this post by Marky Roden:
https://xomino.com/2012/03/10/checking-xpages-radio-buttons-have-been-selected-with-jquery/
I haven't been doing any development work for 4/5 weeks as year end comes up so my brain isnt really working like it should.....

XPages. Hide column in DataTable

I'm trying to hide a column in the dataTable, but not working. Hiding only header. In example I try hide first column. Domino 9.0.1.
I was mistaken or is it a bug?
I know about the "display: none" for the column, but I have a lot of data, and not rendered column save my local performance
<xp:dataTable id="dataTable1" rows="30" var="item">
<xp:this.value><![CDATA[#{javascript:var collection = [];
for( var i = 0; i < 10; i++ ) {
var obj = {};
obj.name = "Name" + i;
obj.key = "Key" + i;
collection.push( obj );
}
return collection;}]]></xp:this.value>
<xp:column id="column1" rendered="false">
<xp:this.facets>
<xp:span xp:key="header">Name</xp:span>
</xp:this.facets>
<xp:text escape="true" id="computedField1"
value="#{item.name}">
</xp:text>
</xp:column>
<xp:column id="column2">
<xp:this.facets>
<xp:span xp:key="header">Key</xp:span>
</xp:this.facets>
<xp:text escape="true" id="computedField2" value="#{item.key}"></xp:text>
</xp:column>
</xp:dataTable>
I can confirm I get exactly the same behavior out of this. I agree that I would expect the entire column to not render, but that's apparently not its behavior. I've always viewed the xp:dataTable control as a slightly dressed up xp:repeat, but not with as much window dressing as an xp:viewPanel control and the Domino Designer wiki page on xp:dataTable isn't exactly helpful for any of the specifics and my Mastering XPages 2nd ed. also doesn't go too far into detail on xp:dataTable.
It's also worth noting that also setting the rendered property on your xp:text field still builds out the first cell in each row, regardless of the first <th> being suppressed. I'm guessing there's something in the way the xp:dataTable control builds out the HTML elements that's funky.
My recommendation would be to switch to an xp:repeat control, which will give you more control over the entire process. Adapting your code, it would go somewhat like this:
<xp:table>
<xp:tr>
<xp:td>Name</xp:td>
<xp:td>Key</xp:td>
</xp:tr>
<xp:repeat
id="repeat1"
rows="30"
var="item">
<xp:this.value><![CDATA[#{javascript:var collection = [];
for( var i = 0; i < 10; i++ ) {
var obj = {};
obj.name = "Name" + i;
obj.key = "Key" + i;
collection.push( obj );
}
return collection;}]]></xp:this.value>
<xp:tr>
<xp:td
rendered="false">
<xp:text
escape="true"
id="computedField1"
value="#{item.name}">
</xp:text>
</xp:td>
<xp:td>
<xp:text
escape="true"
id="computedField2"
value="#{item.key}">
</xp:text>
</xp:td>
</xp:tr>
</xp:repeat>
</xp:table>
Do note that to also set the rendering property of the cell being used as the header label (in place of a <th> it will render as a <td>), you'll need to manage that property visibility separately.

onChange event does not fire if there is field level validation

Below is the source of a very simplified XPage. It has a radio button group with two choices and an onchange event that sets viewScope.vsCompanies depending on the value selected. Then there is a field called Title that I have made Required. If I click on the radio button it changes from Contract to Lease and back but the onchange event never fires. Instead I get a warning that the Title is required. I only want the validation to fire when the document is being submitted so the onchange works. Do I have to make every one of the validations conditional on the submit being pressed, which seems like a lot of additional work. I could set a viewScope when the submit button is pressed and make it only required if that viewScope is true.
Sorry missed adding the code ps clientsideValidation is disabled
<xp:this.data>
<xp:dominoDocument var="CLDoc"
databaseName="Client Apps\LGI\XPages\LGIContracts-Leases.nsf"
formName="frmCL">
</xp:dominoDocument>
</xp:this.data>
<xp:this.properties>
<xp:parameter name="xsp.client.validation" value="false" />
</xp:this.properties>
<xp:br></xp:br>
<xp:messages id="messages1"></xp:messages>
<xp:radioGroup id="radioGroup1" value="#{CLDoc.Type}">
<xp:selectItem itemLabel="Contract"></xp:selectItem>
<xp:selectItem itemLabel="Lease"></xp:selectItem>
<xp:eventHandler event="onchange" submit="true"
refreshMode="partial" refreshId="comboBox1">
<xp:this.action><![CDATA[#{javascript:if (CLDoc.getValue("Type") == "Contract"){
viewScope.vsCompanies = ["A","B","C"];
return;
break;
}else{
viewScope.vsCompanies = ["X","Y","Z"];
return;
break;
}}]]></xp:this.action>
</xp:eventHandler>
</xp:radioGroup>
Company
<xp:br></xp:br>
<xp:comboBox id="comboBox1" value="#{CLDoc.Company}">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:viewScope.vsCompanies}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
<xp:br></xp:br>
Title
<xp:br></xp:br>
<xp:inputText id="inputText1" style="width:392.0px" value="#{CLDoc.Title}"
required="true">
<xp:this.validators>
<xp:validateRequired message="Title is required"></xp:validateRequired>
</xp:this.validators>
</xp:inputText>
I believe if you go to the Events you are able to disable validators for that event.
[edit]
I found a duplicate question here. xpages validation on field having onChange script
Looks like the event handler has the following parameter
disableValidators="true"

Clickable link in RadGrid column

I have a RadGrid where a column in the grid holds a URL. When a put a value in the column I can see the URL but the URL is not clickable (to go to the URL). How can I make the URL clickable?
Here is a rough example of what I'm doing now:
DataTable table = new DataTable();
DataRow row = table.Rows[0];
row["URL"] = "http://www.google.com";
grid.DataSource = table;
In addition I'd really like to show specific text instead of the URL. Something similar to Link in HTML. Is there anyway to do this?
Have you tried the GridHyperLinkColumn? Below is a detailed example.
<telerik:GridHyperLinkColumn FooterText="HyperLinkColumn footer" DataTextFormatString="Search Google for '{0}'" DataNavigateUrlFields="CompanyName" UniqueName="CompanyName" DataNavigateUrlFormatString="http://www.google.com/search?hl=en&q={0}&btnG=Google+Search" HeaderText="HyperLink<br/>Column" DataTextField="CompanyName"></telerik:GridHyperLinkColumn>
You can also view the demosite to see how it works.
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx
Add all the columns manually in the ascx page and make the column you want to contain the hyperlink a GridTemplateColumn:
<telerik:GridTemplateColumn
UniqueName="TemplateLinkColumn"
AllowFiltering="false"
HeaderText="URL">
<ItemTemplate>
<asp:HyperLink ID="Link" runat="server"></asp:HyperLink>
</ItemTemplate>
</telerik:GridTemplateColumn>
Make sure that your grid has an OnItemDataBound method:
<telerik:RadGrid
ID="RadGrid"
runat="server"
AutoGenerateColumns="False"
OnItemDataBound="RadGrid_ItemDataBound" >
In your OnItemDataBound method set the field to the URL:
protected void RadGrid_ItemDataBound(object aSender, GridItemEventArgs anEventArgs)
{
//Get the row from the grid.
GridDataItem item = anEventArgs.Item as GridDataItem;
GridTableCell linkCell = (GridTableCell)item["TemplateLinkColumn"];
HyperLink reportLink = (HyperLink)reportLinkCell.FindControl("Link");
// Set the text to the quote number
reportLink.Text = "Google";
//Set the URL
reportLink.NavigateUrl = "http://www.google.com";
//Tell it to open in a new window
reportLink.Target = "_new";
}
You will also need to check for the correct type, as follows;
if (anEventArgs.Item.GetType().Name != "GridDataItem")
{
return;
}

Resources