Do you have any idea how can I use xp:fileDownload control in a xp:repeat control ?
I binded xp:repeat control to view. So I am available to get NotesViewEntry per line.
But I didnt get attachments using var variable in xp:fileDownload control.
I placed xp:repeat in xp:panel and created data document in panel object. I placed fileDownload control inside this panel. And binded document data source to fileDownload.
Not worked !
Have an idea ?
I have 10 documents and every document has one more attachment. I want to show these files using filedownload control.
<xp:this.data>
<xp:dominoView var="viewReviews" viewName="vwLookupGoruslerHepsi"></xp:dominoView>
</xp:this.data>
<xp:repeat id="repeat1" value="#{viewReviews}" var="viewEntry">
<xp:table style="width:100%;border:1px solid #ddd;margin-bottom:5px;"
cellpadding="2">
<xp:tr valign="top">
<xp:td rowspan="5" style="width:250px">
<xp:text id="computedField9" tagName="h4" escape="true">
<xp:this.value><![CDATA[#{viewEntry["GorusBildirecek_CN"]}]]></xp:this.value>
</xp:text>
</xp:td>
</xp:tr>
<xp:tr valign="top">
<xp:td>
<xp:panel id="panelGorusEkler">
<xp:this.data>
<xp:dominoDocument var="docGorus" formName="frmGorus"
action="openDocument" documentId="#{javascript:viewEntry.getNoteID()}">
</xp:dominoDocument>
</xp:this.data>
<xp:text escape="true" id="computedField1"
value="#{docGorus.GorusBildiren_OU1_NAME}">
</xp:text>
<xp:fileDownload rows="30" id="fileDownload3"
var="rowFile" indexVar="rowIndex" value="#{docGorus.Ekler}">
</xp:fileDownload>
</xp:panel>
</xp:td>
</xp:tr>
</xp:table>
</xp:repeat>
Thanks
Alternative Solution fileDownloadLinks in xp:repeat Control
Alternative way to solve this need.
I added a column which includes #AttachmentNames values. (Column Name : $Ekler)
<xp:tr valign="top">
<xp:this.rendered><![CDATA[#{!empty viewEntry["$Ekler"]}]]></xp:this.rendered>
<xp:td>
<xp:repeat id="repeat2" value="#{viewEntry.$Ekler}" var="embeddedFile">
<xp:link escape="true" id="link1" style="margin-right:10px">
<xp:this.text><![CDATA[#{javascript:var aSizes:Array = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
var embedFile:NotesEmbeddedObject = viewEntry.getDocument().getAttachment(embeddedFile);
var calcnr:Number = Math.floor(Math.log(embedFile.getFileSize())/Math.log(1024));
var fSize = (embedFile.getFileSize()/Math.pow(1024, Math.floor(calcnr))).toFixed(2)+" "+ aSizes[calcnr];
return embedFile.getName() + " (" + fSize + ")"}]]></xp:this.text>
<xp:this.value><![CDATA[#{javascript:"/" + facesContext.getExternalContext().getRequestContextPath() + "/xsp/.ibmmodres/domino/OpenAttachment/" + facesContext.getExternalContext().getRequestContextPath() + "/" + viewEntry.getDocument().getUniversalID() + "/Ekler/" + embeddedFile;}]]></xp:this.value>
</xp:link>
</xp:repeat>
</xp:td>
If you're using a dominoDocument datasource, I'm pretty sure you'll need to set ignoreRequestParam="true" if you're passing a documentId in. Otherwise it looks to the query string parameter. Then the file download should work.
For the second option, is the column set to show multiple values as separate entries? If the repeat is receiving a comma-delimited string value, it won't work: repeats expect a collection, not a single string. Check to make sure your columnValues() property of the NotesViewEntry is multi-value. Even then, I'd expect it to fail if there's only one attachment.
Rather than using a column value, pass the repeat the NotesEmbeddedObject collection retrieved directly from viewEntry.getDocument(). Each element in your repeat will then be a NotesEmbeddedObject.
Related
I'm using Classic ASP to add a note function to the table that is displaying rows from a database. The inserted row will save to the database saved Remarks but the following code isn't working.
<%
Dim fRemark
fRemark = Request.Form("Remarks")
Dim rsIntra,MyQryItr2
set cnIntra = Server.CreateObject("ADODB.Connection")
set MyQryItra2 = server.CreateObject ("ADODB.Recordset")
set rsIntra = Server.CreateObject("ADODB.Recordset")
MyQryItra2 = "select Remarks from [PurchaseOrderTrackInfo]"
rsIntra.Open MyQryItra,strRMSIDMcn
if rsIntra.eof then
MyQryItr2 = "insert into [PurchaseOrderTrackInfo] Remarks values N'" & fRemark & " '; "
cast(Remarks as int)
cnIntra.Execute MyQryItr2
else
rsIntra.close
set rsIntra = Nothing
set rsIntra = server.CreateObject("ADODB.Recordset")
MyQryItr2 = "UPDATE [PurchaseOrderTrackInfo] SET Remarks = N'" & fRemark & " '; where Remarks = rowID;"
end if
set rsIntra=Nothing
strConnDB= "Driver={SQL Server};Server=GB;Database=PurchaseOrderTrackInfo;UID=madfox;PWD=;"
%>
<td colspan="10" bordercolor=#3399ff bgcolor=#FFFF99 align="center">
<font face="Arabic Transparent" size="1" color="#800080"></font>
<form action=UpdatePO1.asp method=post >
<textarea name="Remarks" cols="20" rows="2" ><%=fRemark%></textarea>
<input type="submit" class="btn1" value="save" name="finish"/>
<input type="hidden" name="rowID" value="ID" />
</td>
</form>
<%
you never execute your update query. also your update statement does not seem to be valid as you are using the column Remarks as storage for the Remark and as row id. consider adding a rowid column to you table and use the following update statement
MyQryItr2 = "UPDATE [PurchaseOrderTrackInfo] SET Remarks = N'" & fRemark & " ' where rowId =" & rowID
cnIntra.Execute MyQryItr2
Since your code is vulnerabe to SQL injection, you should look up parameterized queries.
I am trying to set some html contents to a variable so i can perform some if statements. But I get this instead:
Fail #<Watir::Browser:0x00000004440b98>
It looks like my variable isnt set to text i want to set.
my html:
<label class="col-lg-12 control-label ng-binding" ng-show="productionReport.Status == 2 && productionReport.ReadyForPublishDate" style="">Text 1</label>
My Watir code:
msgText = 'Text 1'
msgText2 = #browser.label(:xpath, '/html/body/div[1]/div[3]/div/div/div/div/div/form/div/div/div[2]/label')
if (msgText == msgText2)
puts 'Pass' "#{msgText2}"
else
puts 'Fail' "#{msgText2}"
end
The problem is that msgText2 (ie #browser.label) is being set to a Watir::Label element rather than its text.
To get the text of the label, you need to call the text method. For example:
msgText2_element = #browser.label(:xpath, '/html/body/div[1]/div[3]/div/div/div/div/div/form/div/div/div[2]/label')
msgText2 = msgText2_element.text
I have the following in an ascx file:
<asp:DataList ID="dtlTabs" runat="server" RepeatDirection="Horizontal" EnableViewState="False" CellPadding="0">
<ItemTemplate>
<asp:HyperLink ID="hlTab" NavigateUrl='<%# Eval("Url")%>' Tag='<%# Eval("Key") %>' Text='<%# Eval("Title") %>' runat="server"></asp:HyperLink>
</ItemTemplate>
</asp:DataList>
Instead of iterating through it as a datalist, can I print only Title of item 3 ? I'm not sure how to pick just one item from the dtlTabs and print it.
Got it:
Dim dt As Data.DataSet = DirectCast(dtlTabs.DataSource, Data.DataSet) ' Cast the datasource back into a dataset
Dim dr As Data.DataRow = dt.Tables(0).Rows(4) ' Take the fourth row from the first table
Response.Write(dr("Title")) ' Output the text
I have a csv file (sample)
Firm,Code,Server
Adsuar,BZ,RKASP01
Ahlers,AU,RKASP02
Andrews,CW,RKASP02
Armbrecht,AS,RKASP02
Barron,ZZ,RKASP01
Beckman,BI,RKASP02
and am trying to find a way in vbscript to have a single select box on my website that lists the values of column A, and then populate two variables with the contents of column B and C in the same row.
I have what I need to read the csv file and can loop through the file and echo all the contents, however I'm having some trouble finding where to go from here. Any suggestions on where I can start would be appreciated.
The code I have currently is
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("\\rkaspctl01\n$\wwwroot\dev\clients.csv", 1)
do while not (objTextFile.AtEndOfStream)
arrStr = Split(objTextFile.ReadLine, ",")
strFirm = arrStr(0)
strCode = arrStr(1)
strServer = arrStr(2)
Loop
objTextFile.close
Thanks
Patrick Stoddard
Start putting your data in a key/value pair (dictionary) where the key is the value from column A, the value is an array containing the values from column B and C:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("\\rkaspctl01\n$\wwwroot\dev\clients.csv", 1)
Set objFirmDict = CreateObject("Scripting.Dictionary")
do while not (objTextFile.AtEndOfStream)
arrStr = Split(objTextFile.ReadLine, ",")
objFirmDict.Add arrStr(0), array(arrStr(1), arrStr(2))
Loop
objTextFile.close
Now you can populate your listbox with the keys from the dictionary.
Pseudocode:
firmListbox = document.getElementById("firmSelect")
For each firm in objFirmDict.Keys
Set newOption = document.createElement("option")
newOption.text = firm
newOption.value = firm
firmListbox.Add newOption, Nothing
Next
When an option is selected, update the two variables with the correct text.
On you webpage:
<input type="select" id="firmSelect" onchange="vbscript:firmSelectChange me.Value">
The onchange event calls the firmSelectChange sub. This has to retrieve the two variables from the dictionary. Please note: The dictionary must have a global scope for the document.
Pseudocode for this handling sub:
Sub firmSelectChange(value)
dataArr = objFirmDict.Item(value)
code = dataArr(0)
server = dataArr(1)
End Sub
You can use TDC (Tabular Data Control).
<HTML>
<HEAD>
<TITLE>TDC Example</TITLE>
<OBJECT ID="dataTDC" CLASSID="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME="TextQualifier" VALUE="">
<PARAM NAME="FieldDelim" VALUE=",">
<PARAM NAME="DataURL" VALUE="data.csv">
<PARAM NAME="UseHeader" VALUE="true">
</OBJECT>
</HEAD>
<BODY>
<TABLE DATASRC="#dataTDC" BORDER="1" CELLSPACING="0">
<THEAD>
<TR>
<TD><B>Firm</B></TD>
<TD><B>Code</B></TD>
<TD><B>Server</B></TD>
</TR>
</THEAD>
<TR>
<TD><SPAN DATAFLD="Firm"></SPAN></TD>
<TD><SPAN DATAFLD="Code"></SPAN></TD>
<TD><SPAN DATAFLD="Server"></SPAN></TD>
</TR>
</TABLE>
</BODY>
</HTML>
Output result:
Given the following HTML code snippet; after finding the link by ID, how would you select the checkbox in the same paragraph?
For example if I wanted to select the checkbox associated with the link with ID="inst_17901-1746-1747".
The order of the paragraphs in the DIV is not consistent between sessions so I cannot select it by index or ID of the checkbox.
<div id="inst-results">
<p>
<input id="inst-results0-check" type="checkbox">
<a class="ws-rendered" id="inst_17901-1746-1747" title="!!QA Data 2/DOOR FURNITURE/316 Stainless - Altro Range"><img src="http://yr-qa-svr2/Agility/ACMSImages?type=objectType&objectTypeID=32"> <span>!!QA Data 2/DOOR FURNITURE/316 Stainless - Altro Range</span></a>
</p>
<p>
<input id="inst-results1-check" type="checkbox"><a class="ws-rendered" id="inst_17882-1746-1747" title="!!QA Data/DOOR FURNITURE/316 Stainless - Altro Range"><img src="http://yr-qa-svr2/Agility/ACMSImages?type=objectType&objectTypeID=32"> <span>!!QA Data/DOOR FURNITURE/316 Stainless - Altro Range</span></a>
</p>
</div>
I figured out this solution working off the text of the link, but Zeljko solution is much better.
$browser.div(:id,"inst-results").ps.each { |para|
if para.link.text == "!!QA Data/DOOR FURNITURE/316 Stainless - Altro Range" then
para.checkbox.set
break
end
}
If there is only one checkbox in the paragraph with the link:
browser.link(:id => "inst_17901-1746-1747").parent.checkbox.set
Works with watir-webdriver, not sure if it would work with other Watir gems.