Pages

Saturday, November 17, 2012

Problem downloading Microsoft Powerpoint 2007 document from domino server 8.5

A while ago I was presented with a seemingly trival and strange issue. The issue stated something like, a user was able to download a .pptx file from a domino website and when opened it is always blank, were as other users were able to download the .pptx file and view its contents with out issues. I thought to my self, am I an astrologer and have I sinned enough to be tested with such an issue that if I would like to get serious about it, I might laugh my self to de***.

Yes it was funny, and I did all sorts of checking like is the user trying to preview the file on lotus notes which I knew would fail or does the user's machine really have Microsoft office installed and many such tests came back negative. I knew I am approaching/at the verge of the dangerous scenario - "Laughing myself to de***", i.e. get serious.

Know what?, I did really found something serious. Once again I am humbly reminded that one can never know everything.

It is a kind of a well known bug which was well documented as well. A rare phenominan with IBM lol. :P
http://www-01.ibm.com/support/docview.wss?uid=swg21412063

It helped me find something that I was looking for a long time, a list of all the commonly used mime type. Wonderful:O..

The abstract of what I understood from the documentation is as follows
In some cases, the browser identifies the attachment as a zip file.

Symptom : The user may be prompted to download the file locally, even though the file type is associated with the correct application in their browser.

Cause : This issue occurs because the MIME types for Microsoft Office 2007 formats are not listed in the Web Server metabase on the Domino server (httpd.cnf).

Currently, when a HTTP request is made for an unknown file type, the server returns a Content-Type of "application/octet-stream" in the response, instead of the appropriate Office 2007 MIME type.

Resolving the problem
This issue is now fixed in Lotus Notes and Domino 8.5.1 FP4 and 8.5.2.

Fix details: SPR# JBEN7WRHM7

Refer to the Upgrade Central site for details on upgrading Notes/Domino.

To resolve the issue in a previous release, IBM recommends performing the following actions to add the Office 2007 MIME types to your current Web Server metabase (httpd.cnf):

1) Shutdown the HTTP process by issuing the following command on the Domino server console: tell http quit

2) Open the httpd.cnf file (located in the Domino Data directory) using a text editor, such as Notepad. In order to edit this type of file on most operating systems, it will be necessary to launch the editor first and then open using the file menu from within the editor.

3) Copy the Office 2007 MIME types below and paste them into the httpd.cnf file (Note: When inserted, each line below should begin with either the hash symbol "#" or "AddType")


#
# Microsoft Office 2007 formats
#
AddType .docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
AddType .dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
AddType .xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
AddType .xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
AddType .pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
AddType .potx application/vnd.openxmlformats-officedocument.presentationml.template
AddType .ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow

Note: The above list only includes the most commonly used Office 2007 MIME types. For a complete list of the document types addressed by SPR # JBEN7WRHM7 (including other extensions that may be needed in your environment), please refer to the following Microsoft documentation:
http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/05/08/office-2007-open-xml-mime-types.aspx

4) Restart the HTTP task by issuing the following command on the Domino server console: load http

Friday, July 20, 2012

text-transform in css

We knew it all along and yet, we forget their existence -- it must have been quoted by some big person or else let me own the patent for it. I always have issues with this

Now I just rediscovered it with the text-transform property in CSS. oh pls, God Bless Me

This does relatively reasonable job which is very appreciable. I find many instances in which I could have used it in the past and yet, I never did.

Following is a simple illustration of how to use this and what it does

I am applying the following style on the forth comming statements which are typically html paragragh tags

p.uppercase {text-transform:uppercase;}
p.lowercase {text-transform:lowercase;}
p.capitalize {text-transform:capitalize;}



This is some text.The class of this para is "uppercase"

This is some text..The class of this para is "lowercase"

This is some text..The class of this para is "capitalize"

!important in css

It reads like not important, but it means totally the other way. I got curious when I first encountered this property in CSS. It has really took a long time for me to discover this property.

After going through the details of this property, in order to make my understanding simler, it is some what like the final keyword in Java. Dont take my word for granted, its just a persection. I am just trying to put things together to explain the stuff.

Following is a simple explanation of the same

Guess that I'm using the following code to style my paragraphs in my document
p {color:#0000ff}  --> should apply blue color to my paragraphs
p {color:#000000}--> should apply black color to my paragraphs and will override my previous blue style for para tags

Eventually all my paragraphs will be black in color

To ensure that certain things dont get overrided, let me say i do the following (!important atlast),
p {color:#0000ff !important;}
p {color:#000000;}


This is my target paragraph. Note that I am blue in color

This is an unexpected property that I least expected to find in CSS :).
But be warned, this is not java, so let me say the following, as far as I have tested, the !important tag is a bit tricky and is jerking around a bit as well. Its because, say I do the following

p {color:#ff0000;}
  some paras
p {color:#0000ff !important;}
  some paras
p {color:#000000;}
  some paras

Now all the "some paras" that I am refering to will be in blue color. So no matter where you declare !important property for styles, it gets applied to entire document. Thats ridiculous and will definetely be useful some times. But I am scared of it.

Again Diamond cuts Diamond and !important overrides !important - Wow howz my moral of the story (cool down plz)

p {color:#0000ff !important;}
p {color:#00ff00 !important;}

This will ensure that all your para tags are green in color. Hope you get the picutre, if not dont expect me to explain further, try it out :).

Friday, May 11, 2012

Forcing browser compatibility in IE

I happened to stumble upon this concept long back and due to some reason which I don't remember, I lost interest in it. After a long time when I checked my archives, I came across this concept again and thought its time I put it to good use. I as most developers do, believe, IE is the browser that is a gift for the developers. Its so buggy that you can forget why your wife threw a stick at you the same morning :).

And to add to the recipe we have different versions of IE which again are different from each other in behavior. Or at least that what I believe as far as I have worked with it. Stories apart, I will come to the point,

I just found some one talking about how to force IE8 to work like IE7 when working with XPages.That article was exhaustive, and I have lost track of it. But I do have parts of it documented there and there for my understanding.

All you got to do is put the following code in beforeRenderResponse event: 
// first option uses compatibility mode, second option too but stronger
// X-UA-Compatible: IE=7
// X-UA-Compatible: IE=EmulateIE7
if (context.getUserAgent().isIE(8, 8)) {
  var exCon = facesContext.getExternalContext();
  var response = exCon.getResponse();
  response.setHeader("X-UA-Compatible", "IE=EmulateIE7");
}

Understanding Compatibility View

Before displaying a standards-mode Web page, Internet Explorer 8 checks to see if the domain name of the Web site appears in the Compatibility View List. If so, the site is displayed using Compatibility View. If not, and the page contains no other direction, Internet Explorer 8 displays the page in Internet Explorer 8 Standards mode.
When a standards-based Web page is displayed in Compatibility View, the following changes occur.
Pages are displayed in IE7 mode rather than IE8 mode.
In the user-agent string, the browser identifies itself as MSIE 7.0 instead of MSIE 8.0.
Conditional comments and version vectors recognize the browser as Internet Explorer 7, rather than Internet Explorer 8.
These changes help ensure that users can still use Web sites that do not fully support the features of Internet Explorer 8.
Please note that the X-UA-COMPATIBLE header has greater precedence than Compatibility View. If a Web site is on the Compatibility View List and a page on that site includes an X-UA-COMPATIBLE header telling Internet Explorer 8 to display a page in IE8 mode, the page is displayed in Internet Explorer 8 Standards mode. This allows Web developers to support Internet Explorer 8 Standards mode on an incremental basis

Javascript to identify the compatibility mode


engine = null;
if (window.navigator.appName == "Microsoft Internet Explorer")
{
   // This is an IE browser. What mode is the engine in?
   if (document.documentMode) // IE8
      engine = document.documentMode;
   else // IE 5-7
   {
      engine = 5; // Assume quirks mode unless proven otherwise.
      if (document.compatMode)
      {
         if (document.compatMode == "CSS1Compat")
            engine = 7; // standards mode
      }
   }
   // The engine variable now contains the document compatibility mode.
}


To specify a document mode for your Web pages, use the META element to include an X-UA-Compatible http-eqiv
header in your Web page. The following example specifies EmulateIE7 mode compatibility.
    
   
      My Web Page</< span>title></div><div>      <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /></div><div>   </< span>head></div><div>   <body></div><div>      <p>Content goes here.</< span>p></div><div>   </< span>body></div><div></< span>html></div><div><br></div><div>    </div><div><br></div><div>The content attribute specifies the mode for the page; for example, to mimic Internet Explorer 7 beha vior, specify IE=EmulateIE7.</div><div>Likewise, specify IE=5, IE=7, or IE=8 to select one of those compatibility modes. You can also specify IE=edge to tell Internet Explorer 8 to use the</div><div>highest mode available. </div><div><br></div></div>

Saturday, May 5, 2012

Google Search - Context Menu Addin For Internet Explorer



Create a html filed named say “GoogleSearch.htm” in a location say “D:\Lotus Notes\tools\MyIEPlugins”
Now code the html file with the following code and save it
<script language="JavaScript">
  var parentwin = external.menuArguments;
  var doc = parentwin.document;
  var sel = doc.selection;
  var rng = sel.createRange();
  var str = new String(rng.text);

  if(0 < str.length)
  {
    window.open("https://www.google.co.in/#hl=en&q="
      + str, "_blank");
  }
</script>
Now open your registry editor and traverse to the following key “HKCU\software\microsoft\Internet Explorer\MenuExt”
Now create a key named “&Google Search”
  
Now on the right side change the (Default) attribute’s value to the location of your html file that we created in the beginning
Now create a new DWord named “Contexts” and specify its value as 0x10.
Now start or restart your internet explorer.
Open a web page or your choice. Select some text and right click on it. Voila you will find some thing like the following

This will bring up a new window with the google search for the selected text as illustrated by the following screen shot


Likewise you can do it for Live Search as well. All you got to do is tweak your url a bit
"http://search.live.com/results.aspx?q="      + str
Hope this helps J

Friday, April 20, 2012

Overloading functions in Lotusscript

At times I find it difficult with out the ability to over load functions in lotusscript. The following way just helped me do it. Since I dont do this often its like new to me every time I do this :)

Sub new(key As Variant)
     Select Case Typename(key)
     Case "STRING":
           your code for this type
     Case "INTEGER"

          your code for this type
     Case "NOTESDOCUMENT"
          your code for this type
     Case Else
         your code for this
End Select
We have to be wary about the usage of such functions though. One stuff that I found was Typename(Nothing) is object. I least expected that.

I dont think using overloaded functions in lotusscript is a time saver. As a matter of fact I found this and just dropped the idea of using it after trying to use it :P. Cos man..., it was a head ache to me. I couldn't have a dynamic parameter list like how we can do in javascript and definetly can't match the way we do it in java or C or C++ anyway.

So I felt crippled when using this idea. However, this must help in some scenarios. Hope you find this in one such case :)

Thursday, April 12, 2012

Issues adding document items dynamically through lotusscript - "Field is too large (32k) or View's column & selection formulas are too large"

I had a very tough time completing a particular job which involved huge amount of document data through lotusscript. I had to debug through thousands of lines of code which were scattered across multiple agents and script libraries. Honestly I got screwed. Not because of the volume of code I was going through but because of the limitation of the notes documents that wont accept summary data beyond a certain limit - roughly around 60000+ bytes, may be 64 K.

I encountered this because, I wanted to print debug statements to understand the flow and was going though a lot of problems in getting them accumulated in a single document. I tried splitting the data between sever different fields, appendItemValue, richtext etc.. But none seemed to help me as desired. It was then that I identified the forgotten concept of the summary and non summary items. My Research towards this concept gave me an answer with in seconds. I found the following in the ibm site.(lost track of the url :< )

The idea is to save the data to the document and make the items as non summary items. That was the simple answer to what I thought was a so very complicated problem
"Field is too large (32k) or View's column & selection formulas are too large"

Or, in a LotusScript agent the following error message corresponding to error code 4000 occurs:

"Notes error: Field is too large (32k) or View's column & selection formulas are too large"



description of this fix:

Notes/Domino 6.x and later have the following limits regarding Summary fields: 32k per field, 64k per document. Relative to memos: The limit for sending to individual names and locally expanded groups is 15k. In addition, the above restrictions still apply as regards other fields in the memo.

Except for rich text fields, fields are typically flagged as "summary" by default; you can change this with the NotesItem.IsSummary property, but it will be reset to the default if the document is edited using a form that contains that field. Non-text fields (numbers, date-times) are also summary fields, so these limits apply to them also.

Hope this helps :)

Tuesday, February 21, 2012

Microsoft Outlook Collection of Constants

Ever seen a vb code which says something like

"Set MyItem = MyOlApp.CreateItem(olAppointmentItem)" or "MyRequiredAttendee.Type = olRequired"

and had a tough time figuring out what those constants starting with ol stand for when implementing them in your technology. I had my share of head ache to find the nice simple solution for it

http://msdn.microsoft.com/en-us/library/aa210886(v=office.11).aspx

Go through the site and you may find it useful. Microsoft guys can atleast give a flow chart showing the relations between the various objects in the Object Model documentation. Atleast more developers can understand em and support microsoft.

Thanks to the awesome work by John Coolidge. You would definitely be impressed. Take a look at the his work

A sample Calendar file

Following is a content of a fully functional calendar file


BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
PRODID:-//ORG//LN//LS
BEGIN:VEVENT
SUMMARY:My Subject!
DESCRIPTION:My Description content
UID:D70C88D5-E5A1-48EC-84A4-D05DBD5CD8F6-99
DTSTART:20120218T160000
DTEND:20120218T163000
LOCATION:My Location
END:VEVENT
END:VCALENDAR

This is a really nice concept that I liked very much. If you search for info on "ical" files you will get to browse nice sweet pages including the wikepedia which has nice demonstrations/explations on what this does.

I had a scenario where I had to tinker people's outlook calendar from lotus notes. Using ical files were a really nice option. Atleast I did not find another nicer solution. Once these files are sent to users with the necessary values in it, you can have users open them and save them to their calendars.

A nice way like how xml shall mediate between different platforms. ical - I believe this will work with all major calendars. I know it works for Lotus Notes and Outlook. Yet to test on other web-based stuffs like Google Calendars. Let me know if you test them.

:)

Friday, February 17, 2012

Creating simple downloadable text file using lotusscript

Create an agent with the following Lotusscript code in it.

Print "Content-Type:application/octet-stream"

Print "Content-Disposition: Attachment;filename=""sampleDownloadAbleFile.txt"""
Print "this text is from the server"
Print "this has not been saved any where in the server"

Save the agent preview it on the web. You will be able to download a text file



Hope this helps :)