Posts

Showing posts from January, 2012

trim() not supported by IE7 and IE8

Funny fact, trim function is not supported by IE7 and IE8. Ok, it is supported, but through jQuery trim function. So, when you have something like this: jQuery(...).attr().trim() , this trim() function stops having any relation to jQuery, as the attr() would return String type, which method would be then trim(). Since IE7 and IE8 do not support trim() method within String type, you should use instead jQuery.trim(jQuery(...).attr()) or if you don't wanna use jQuery (whyyyy?), you can simply implement the trim function youself. if(typeof String.prototype.trim !== 'function') { String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); } } http://www.blogger.com/img/blank.gif source 1 source 2

Testing developments for different versions of Internet Explorer

I found excellent article on development environments different IE versions review, made By Addy Osmani Article can be found here I usually tend to take all the context from the page into this blog to make sure it exist also after the page disappears (you will be surprised how fast link gets changed, wither due to change of the link itself, or to site being closed down due to whatever reasons). This time I'll give it a risk. Just as a summary, for fast and simple testing, use F12 development mode, and for more detailed test, use the virtual machines and IECollection (you have to get yourself licensed versions of Windows (XP, Vista, and 7)), or use the Windows Virtual PC VHDs (read Notes, max 90 days of being able to permanently save any changes, made on the images). As a long time user of Virtual machines, I do like to use virtual machines, like VMware or VirtualBox , but still, the easiest way so far is to use F12 developer mode button on IE, and set the browser vers

tabindex browser compatibility issue

When creating form, take care of the way how the fields are passed on when key is pressed. It is usually solved via tabindex, being set as an attribute to the form fields. However, if some of the elements in the following set {A, AREA, BUTTON, INPUT, OBJECT, SELECT, and TEXTAREA} are not tabindexed, browsers will behave differently upon them. Internet Explorer will make them first in the order, and then those which are tabindexed, and Firefox would do opposite. Therefore you can either put to not tabindexed elements very large value (up to 32545), so they are shown always the last, or put tabindex="-1". I personally would not use the latter case, as it is not valid value for tabindex in its defition, so the browsers might change the way they behave upon it in the future. Some more details about it, I have found pretty nice article: http://www.codestore.net/store.nsf/unid/BLOG-20060706

Triggering event in a Form/Javascript

Sometimes the values you put in the form through any kind of way except user interaction are not triggering change event upon which some other parts of the form behave. In order to forcefully trigger the even, you can use jQuery. jQuery('YOUR_SELECTOR').trigger('change'); or simply $('YOUR_SELECTOR').trigger('change'); My Advice. ALWAYS use jQuery rather than any custom made functions, since jQuery is guaranteed to be web browser compatible! And it is cool and easy!

Problem of Spring using ISO9968-1 instead of UTF8

After a long search for a solution, a friend of mine gave me this solution. Put on top of each jsp file the following two lines: <%@ page contentType="text/html; charset=UTF-8" %> <%@ page pageEncoding="UTF-8" %>

Get the current path of the web project - alternative way

This alternative way to get absolute path for some of the things, is useful when you need to read or write a some project related file and use it later again. File file=new File( .class.getClassLoader().getResource("WEB-INF/").getFile()); System.out.println("path is:"+file.getAbsolutePath());

Prevent JAXB from creating JAXBElements

I had some annoying trouble with updating JAXB1.0 code into JAXB2.0 code, among which the one of the things is the generation og JAXBElements instead normal type, like JAXBElements instead of simple double. This is due to fact that JAXB wants to define cases of elements in XSD with minOccurs="0" and nillable="true". If you don't care about such issue, then you can prevent JAXB from creating the JAXBElements in a following way: Add to your command line generation -b addCFG.xjb where addCFG.xjb is this file: xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"> source :

Process Explorer

(Windows related) There is a nice additional utility from Microsoft, for regulating problems/stuff in windows. This utility is sort of a advanced version of task manager, just muuuch better. It's called the Process Explorer , and it has number many additional features among which these are probably most interesting for regular users: - Actual view of all the applications that are running - list of handles opened - this is especially useful when some of programs have closed the connection opened towards peripherals, like removable media (USB stick, flash stick, camera, etc.)