Pages

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 :)

Tuesday, January 3, 2012

Bugs: "Element or Navigator is invalid" error when using NotesRichTextNavigator


-->
Let me dive straight into the point.  Assume that I have few document say five documents with a rich text item in each one of it and all of them are created using same form. So don’t bother about minor variations like missing document items etc… To make things simple let me say that these five documents are design equivalent.

Now let me say that I don’t put any values inside the richtext field in 3 document alone. So on the contrary I have values on all the 4 remaining documents.


Now assume that I have the following sort of code in an agent


On Error Goto errhandler
                …….’some code               
                Set dc=db.UnprocessedDocuments
                Set doc=dc.GetFirstDocument
                Set richStyle = session.CreateRichTextStyle
                richStyle.PassThruHTML = true
                                
                While Not doc Is Nothing
                                itr=itr+1
                               
                                Set richText=doc.GetFirstItem("myRtField")
                                Set rtnav=richText.CreateNavigator
                                                               
                                Call rtnav.FindFirstElement(RTELEM_TYPE_TEXTRUN)
                                Call richText.BeginInsert(rtNav)                   ---------------------à>> when itr=3 this line will error out with error number 4506
                                Call richText.AppendStyle(richStyle)
                                'Call rtnav.GetLastElement(RTELEM_TYPE_TEXTRUN )
                                Call richText.EndInsert
                                Call richText.Update
                                'Call doc.Save(True, False)
                                Set richText=Nothing
                                Set rtnav=Nothing
                                Set doc=dc.GetNextDocument(doc)
                                Print Cstr(itr) & " doc processed"
                Wend
                Exit Sub
errHandler:
                If Err=4506 Then Goto skiploop
                Print Error & " *** occured on line *** " & Cstr(Erl) &"*** with error number *** " & Cstr(Err)
                Exit Sub




As you may understand the since the rich text field in the third document is empty an error with number 4506 will occur.


You can say that one can handle this scenario by using some thing like “IF rtnav Is Nothing Then goto SkipLoop” etc… but it did not work so I managed to loop the control back in my error handler section.


And guess what, the object rtnav becomes unusable. I simply does not set any right values the next time the loop executes and does not accept any values. And so the following error occurs




And alas… the code breaks. Complier does not even make it to the error handler.


So sad L


I think I know a work around for that. So stay tuned