Quick Search
Social Sites
Lotus Community


Entries in xpages (14)

Wednesday
Jul142010

Forcing a file name when downloading a dynamically generated csv file

Over the last couple of weeks I've been working on a customisation project using IQJam as a starting point and then making it better fit a particular customer's requirements. It's worth mentioning as I finally had the justification to spend a little time investigating a problem which has been bugging me.

One of the features I added to IQJam was the ability to export data to Excel, a common enough feature that you've been able to do in Domino for ever. Simply print data out to the browser in simple HTML format and change the content-type of the page to "application/vnd.ms-excel". That's not the point of this posting really.

The problem I've been trying to work around is that if your user is using Excel 2007 or later (I'm only on the beta of Office 2010 but it still seems to be a problem for me anyway) and you use the printing HTML technique, Excel raises an error for the user when they load the page, something like:

The file you are trying to open, 'name.ext', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?

According to various technotes and blog posts there is no work around for this, it is a deliberate security feature of Excel. Fair enough I can live with this, though it's not acceptable to the end user, so instead of generating an Excel file I reverted to generated CSV formatted data.

The thing I learned from my investigations into the Excel problem was that there is this header which you can add to the data being generated which tells the browser that the page being opened is actually a file attachment and what the name of the file you want to download should be. So in my example, I'm able to create a unique file name every time the page is generated and also specify that it should be saved as a CSV file, not .XSP which is what it would be thanks to the page being loaded being an XPage. See this example:

try{
    var exCon = facesContext.getExternalContext();
    var writer = facesContext.getResponseWriter();
    var response = exCon.getResponse();
    response.setContentType("text/csv");
    response.setHeader("Content-disposition", "attachment; filename=export_" + DateConverter.dateToString(@Now(), "yyyyMMddhhmm") + ".csv");
    response.setHeader("Cache-Control", "no-cache");
    writer.write(getCSVBody());
    writer.endDocument();
    facesContext.responseComplete();
    writer.close();
}catch(e){
    _dump(e);
}

So this server side javascript sits in the afterRenderResponse of my XPage and is using the "web agents XPages style" technique which Stephan first documented to generate non HTML content from an XPage. The key line for this blog post is where the "Content-disposition" header is set, hopefully you can see where the filename is being created (I'm also using Tommy Valand's DateConverter SSJS code to get the current date / time formatted into a nice string).

Anyway, not a new technique looking at the dates on some of the internet postings out there, but a new one on me and worth passing on I thought.

Tuesday
May182010

Lotus UK Power of Business Applications

Darren Adams has already mentioned this day on 16th June, but I thought I'd just make sure that people know about it as well.

Basically what Darren has organised is a day all about Lotus application development in the real world. So I'm going to speak a little about the history of IdeaJam, where we are and hot we got here. Then in the afternoon I'm back on my favourite hobby horse; XPages development. This time the title for the session is "Rejuvenating Domino Web Applications with XPages".

There looks like there's some really great content during the day, so if you have anything to do with Domino applications (that's development, implementation, management, or anything else really, this isn't an overly techie day) then it will probably be worth you coming along.

And best of all, it's free. You just need to register here.

Wednesday
Feb102010

XPages101 done. (for now)

Yesterday, Ben Poole and myself presented the XPages101 course which I have designed over the last couple of months to be an introduction to developing with XPages.

Overall it seemed to go pretty well, the timings need some work, I went a little fast at some points which may have left a few people overwhelmed at the fire hose of information we got through in a short period of time! That will not happen again now that I understand how it all hangs together a bit more.

The feedback from the attendees was really gratifying...

Question Score
Overall, how would you rate the course? 95% (between Excellent and Good)
How was the course material? 86.67% (between Excellent and Good)
How was the presentation style? 86.67% (between Excellent and Good)
Would you recommend the course to your colleagues / nerdy friends? Yes: 100%

 

Obviously there's always room for improvement and there were some great feedback comments as well...

"A real eye opener for me as I've not looked XPages prior to the course."

"Excellent value for money. Pitched just right for the first steps into XPages."

"It gave me a very good understanding of XPages under the bonnet."

"It was great being here, great course, the XPages start I was looking for."

One of the things which I had consciously not done was provide lots of handout materials. The aim was to reduce the costs of the course as much as possible. From the feedback it seems people would have been happy to pay extra to get more paper based materials. So I think in future iterations of the course we'll change that around.

The other area where a couple of people expressed an interest was for an "intermediate" course. This leaves me in a bit of a quandary, as I'm not sure I know what intermediate is. So if you have any thoughts I'd love to hear them.

Overall though, as I said earlier, it was a great day. Good fun for me, and hopefully useful to everyone else.

Monday
Oct262009

Taking Notes Podcast Episode 100

Yesterday, Bruce and Julian were kind enough to invite Peter Presnell, Declan Lynch and myself to have a bit of a chat about XPages on the land mark 100th episode of the Taking Notes Podcast. The chat itself seemed to go OK, but even if you're not interested, you should listen to the podcast for the first 4 minutes if nothing else. 

Rob Novak managed to organise the Lotus Community (like herding cats at the best of times) to record their own individual congratulations for Bruce and Julian. We get to enjoy the fruits of his work at the start of the podcast.

So go and take a listen. And here's to another 100 episodes of a great Lotus tradition.

Tuesday
Oct062009

Domino Designer is Free!

I can't imagine why you've not seen this news, but just in case, with the release of Notes / Domino 8.5.1 next Monday, Domino Designer will now be free.

This is huge news for the platform, as it means that anyone can download and have a play with 8.5.1 which is the first really good version of Domino Designer on Eclipse. It means that you can have a play with XPages without having to worry about CALs. And I'd really recommend taking that look, whereas XPages in 8.5.0 were very much a "dot zero" release, with 8.5.1 we have a vastly improved dev environment and hugely increased performance and stability on the server side.

If you're in any doubt about what you can achieve with XPages in a relatively short amount of time (i.e. less than it took us to develop the first version of IdeaJam), then have a look at http://IQJam.net, the first commercially available application developed specifically for Domino 8.5.1 using XPages.