XPages: file download control shows wrong created and modified date - xpages

The XPages file download control shows wrong created and modified date
I have an XPages application running on a Domino 8.5.3 FP6 Server and I have to deal with the following known bugs:
LO68445: XPAGE: IN FILE DOWNLOAD CONTROL, CREATED COLUMN SHOWS DOCUMENT CREATED DATE, MODIFIED COLUMN SHOWS DOCUMENT MODIFIED DATE
LO61249: CUSTOMER | THE FILE DOWNLOAD CONTROL DOESN'T DISPLAY THE DATE ST AMP OF THE FILE ATTACHED
Take a look at the following screenshots:
First Step: Upload attachment ("added on" date is correct, because upload was done after the document creation)...
Second Step: Reopen the same document (as you can see the "added on" date is the same as the creation date of the document and that's wrong)...
Thanks in advance for any solution, workaround or alternative!

SOLUTION (WORKAROUND):
After some investigations, I have found a possible workaround. The only thing you have to do is to override the createdValue attribute of the xp:fileDownload control:
<xp:fileDownload id="fileDownload" indexVar="fileIndex" var="fileData"
hideWhen="false" value="#{currentDocument.Body}" sizeTitle="Size"
fileNameTitle="Filename" createdTitle="Added on">
<xp:this.createdValue><![CDATA[#{javascript: //workaround
if (fileIndex == 0 && #Attachments() <= 1) return #AttachmentModifiedTimes();
else return #AttachmentModifiedTimes()[fileIndex];}]]></xp:this.createdValue>
</xp:fileDownload>
Any further solutions, workarounds are welcome!

Related

Google file picker Recent tab

I got a Google drive picker item on my web app. Looking at Google Docs I find out the it display one option tab called "Recent".
Following the documentation at https://developers.google.com/picker/docs/reference I couldn't find any reference to this tab mode, only found "Recently Picked" for files I recently picked from the picker, but I'm looking to emulate this function.
My current code is
new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.enableFeature(google.picker.Feature.SUPPORT_TEAM_DRIVES)
.setAppId(appId)
.setOAuthToken(oauthToken)
.addView(new google.picker.DocsView().setIncludeFolders(true).setOwnedByMe(true))
.addView(new google.picker.DocsView().setIncludeFolders(true).setOwnedByMe(false))
.addView(new google.picker.DocsView().setStarred(true).setLabel('Starred'))
finally after reading the documentation of Google picker and the google groups dedicated to it, I figured out that there is no preset or config for recent uploaded files and even trying to build a custom view with google.picker.view, the query field is quite limited and didn't allow the option to sort the files.
After reading the javascript code of docs.google.com for the file picker I found few variables that are accessible in the moment when you call the method .addView(). This field are:
El: is the filter type for the document type.
mc: this old the whole view configuration and fields. Example: mc.query is equivalent for the View.setQuery.
xd: this field manage the View title in the top nav tab title.
While this method is a bit hacky, is the only option I got in the meantime to replicate the "recent" view tab from google docs. Here is the code I used:
let recentView = new google.picker.DocsView();
recentView.xd = 'Recent';
recentView.mc.sortKey = 15;
let picker = new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.enableFeature(google.picker.Feature.SUPPORT_TEAM_DRIVES)
.setAppId(appId)
.setOAuthToken(oauthToken)
.addView(new google.picker.DocsView().setIncludeFolders(true).setOwnedByMe(true))
.addView(new google.picker.DocsView().setIncludeFolders(true).setOwnedByMe(false))
.addView(new google.picker.DocsView().setIncludeFolders(true).setStarred(true).setLabel('Starred'))
.addView(recentView)
.addView(new google.picker.DocsUploadView().setIncludeFolders(true))
.setDeveloperKey(developerKey)
.setCallback(onFilePickerCB)

Lotus Notes : How to limit the extension file type in the dialog box of the rich text lite field using thumbnails only?

Here is my problem: i have a rich text lite field, used to store a contact photo. Parameter of this field is:
- only allow for thumbnail with an image attachment name (mandatory) = ContactPhoto
Parameter of the Rich Text Lite
When the user clicks on it, a standard import dialog box (managed automatically by Notes) is open and all images type can be selected as shown here :
ScreenShot of the import dialog box
With the following code, I'm able to check the size of the photo:
Set uidoc=ws.CurrentDocument
Call uidoc.Refresh(True,True)
Set doc=uidoc.Document
oneKB = 1024
PhotoTrouve = False
Forall i In doc.Items
If i.type = Attachment Then
Set emb = doc.GetAttachment(i.values(0))
If emb.source="ContactPhoto" Then
PhotoTrouve = True
If emb.filesize > (50 * oneKB) Then
strError="The size of the photo should be less than 50 Kb."
End If
End If
End If
End Forall
If PhotoTrouve= False Then
strError="Photo is mandatory."
End If
But this is not enough. I also need to check if this is well a .jpg file. The problem is that, as this is a thumbnail, its name is ContactPhoto, without any extension and i don't know how to get the original extension of the file selected by the user (seems not to be possible).
So my question is : is it possible to force the standard dialog box of the "thumbnail rich text lite" field in order that it proposes only .jpg extension file type to the user ? How to ?
Or if not, do you know a solution to check that the original file is well a .jpg file ?
Note : even if I name the attachment CPhoto.jpg (instead of ContactPhoto) by example, the user can select all type of images, not only a jpg. The photo is saved in $FILE of the document under the name of CPhoto.jpg but I don't think that the file is finally a real .jpg format. And I absolutely need a jpg image as my final objective is then to export that image in an xml file, with the good format of jpg.
Thanks a lot for your replies and help.
Karen
You will have to translate it from C#, but code to check the file contents to see if it is a jpg can be found in this answer to a previous question on this site.

xpages how to open/save a file from a link

Is there any chance I can open or save an existing file after clicking a link from an xpage?
My scenario: A link to an attachment ( an excel file ) so all users when clicking the link, they will have the possibility to open or save the file.
My app works both on Lotus Client and web.
Thanks for your time
I assume (from your comments) that you are looking for a way to store one certain Excel file somewhere and to give users access to this file with a link.
You can achieve that this way:
Store your Excel file in your database at Resources / Files (e.g. as "sample.xls")
Create a link in your XPage pointing to this file just with the name (e.g. "sample.xls")
<xp:link escape="true" value="sample.xls">Excel sample file</xp:link>
Users can open or download this file in browser or XPiNC clicking on link.
You need to set proper content type. For an existing file you would need to make your own service (XAgent) to alter it. Or you can try to set it for the link.
And bear in mind, that action associated to content type is configured in browser - so every user has it's own.
If you just want to make the file available normally, Knut's answer is about what you want: store the file as a File Resource in the database and link to it on the XPage. I would add one adjustment, though: start the URL in the "value" property with a "/", e.g.
<xp:link value="/sample.xls" text="Excel sample file"/>
The reason for this is to ensure that the generated link is always relative to the NSF, not the XPage - without it, you'd have a problem if you open the XPage with a link like "/someView/someDocKey" (with display-XPage-instead in the form) or if you happen to include extra path info after the XPage (e.g. "/foo.nsf/somePage.xsp/some/path/info").
But if you mean that you want to cause the browser to display the Save File dialog instead of whatever its normal behavior would be (e.g. IE opening the Excel file in the window), the core of the solution is the Content-Disposition header. If this header is set to tell the browser the file is an "attachment", then the browser will prompt the user (or do whatever its normal file-download routine is) instead of opening inline.
Depending on how the file is stored, the solution will either be fairly easy or not-impossible-but-sort-of-a-pain:
If it's a file attached to a document, I believe that the normal control generates links to an attachment-download service that adds this header normally.
If it's not (e.g. it's a file resource), then Frantisek's advice comes into play: you'd have to write your own shim XAgent or servlet that writes this header and then spits out the file's contents.
While the latter is doable, it's a pain, and so I'd suggest trying to wrangle your attachment into a normal document if at all possible. For example, if it's attached to a document in a hidden view, you could do something like:
<xp:panel>
<xp:this.data>
<xp:dominoDocument var="attachmentDoc" action="openDocument" ignoreRequestParams="true">
<xp:this.documentId><![CDATA[${javascript:
database.getView("SomeLookupView").getFirstEntry().getUniversalID()
}]]></xp:this.documentId>
</xp:dominoDocument>
</xp:this.data>
<xp:fileDownload value="#{attachmentDoc.Body}"/>
</xp:panel>

Xpages fileupload control and mime types

I have a problem uploading an image to a form field using the built in xpages fileuploader control. The form field the image is saved to is configured like explained in this blog post by Mats Knutsen: http://devxpages.blogspot.com/2011/03/display-picture-from-rich-text-field.html . I Also plan to display the image in an xpage using the template described in the blog post, like this (http://server/MyDatabase.nsf/viewunid/docunid/imageField/M2?OpenElement).
I know my fileuploader control points to the correct field in the form, since i can see the image in the document using the Lotus Notes Client after the document is created. However; the picture can not be viewed using "http://server/MyDatabase.nsf/viewunid/docunid/imageField/M2?OpenElement" at this point.
On the other hand, if I delete the field contents (the image) from the document field in the client, go back to the xpage with the fileuploader control, and uploads the image a second time, it works perfectly, and the image can be viewed using the url mentioned above.
When I access field properties after the first upload, the Data Type of my field is set to Rich Text.
The second time I upload the same image to the same field in the same document, the field properties Data Type is set to MIME Part, as it probably should have gotten the first time around as well.
Does anyone know why my file uploader control does not work the first time i upload the image, but when I edit the docuement and upload the image a second time, everything seems to be ok?
I would try to avoid uploading images into the RichText in the first place. Would it break your application if you resort to uploading the image as a regular attachment? You then can reference it using .../$File/imgfilename.jpg (using the file name used during upload - retrieved by #AttachmentNames)

Change Edit Control Block (ECB) Link URL in SharePoint

Is there a way to dynamically change the hyperlink associated with an ECB menu in WSS 3.0? For instance, I have a list with 2 fields. One field is hidden and is a link, the other is the title field which has the ECB menu. The title field currently links to the item's view page - but we want it to link to the link-field's url. Is that possible?
UPDATE - 5/29/09 9AM
I have this so far. See this TechNet post.
<script type="text/javascript">
var url = 'GoTo.aspx?ListTitle='+ctx.ListTitle;
url += '&ListName='+ctx.listName;
url += '&ListTemplate='+ctx.listTemplate;
url += '&listBaseType='+ctx.listBaseType;
url += '&view='+ctx.view;
url += '&';
var a = document.getElementsByTagName('a');
for(i=0;i<=a.length -1;i++)
{
a[i].href=a[i].href.replace('DispForm.aspx?',url);
}
</script>
This gives me a link like so (formatted so it's easier to see):
GoTo.aspx
?ListTitle=MyList
&ListName={082BB11C-1941-4906-AAE9-5F2EBFBF052B}
&ListTemplate=100
&listBaseType=0
&view={9ABE2B07-2B47-4390-9969-258F00E0812C}
&ID=1
My issue now is that the row in the grid gives each item the ID property above but if I change the view or do any filtering you can see that the ID is really just the row number. Can I get the actual item's GUID here?
If I can get the item's ID I can send it with the list ID to an application page that will get the right URL from field in the list and forward the user on to the right site.
I think the easiest solution and one I use regularly to modify default sharepoint functionality without having to install server side code is to inject some javascript onto the page to make the necessary modifications.
The Content Editor webpart is ideal for this if you don't want to edit the page source itself. Together with the IE Developer Toolbar or Firebug to inspect the elements you want to edit you should be able to achieve what you need with just a couple of lines of javascript.
Let me know if you need any further detail on getting this work.
The title/link to edit menu is a computed field - basically a combination of the title and item id. If you look at the definition of the field (off the top of my head I think it's in fields.xml) you should be able to create a modified version in your schema.xml that uses the url field in its RenderPattern.
Following up on Tom's answer, you can use the SharePoint Solution Generator in VseWss 1.3 to generate a Visual Studio solution that can re-create your list. You will faint when you see the huge amount of XML that the views use in the schema.xml file but you will see the render pattern that Tom referred to and you should be able to get a general idea of how to modify it to suit your needs.
Gotta love SharePoint. Where small customizations means "take what I give you or rewrite it from scratch"

Resources