Posts

Showing posts from 2012

Chris Maki's Blog: Annotated JAXB Classes

Interesting, but JAXB sometimes is not able to use its own generated .java files. So, if you see the error javax.xml.bind.JAXBException: "your.package" doesnt contain ObjectFactory.class or jaxb.index the following post might be your solution: Chris Maki's Blog: Annotated JAXB Classes

Setting up HTTPS support for WAMP

If you use WAMP to get local PHP server, you might run into issues to set up the HTTPS. The following step-by-step tutorial indeed helped me, and I think it would be useful to re-post it. Recently I had to run a website with several https links under local server for testing and I had to configure the Open SSL server that comes with WAMP server. I'm sure it would be helpful for you as well. First thing first, we need to create that self-signed SSL certificate, so go to DOS command prompt (Start menu -> Run -> cmd). ext, we need to navigate to the directory that contains the openssl executive file which is located in folder C:\wamp\bin\apache\apache2.2.11\bin by default. In order to go there, we need to type the command as follows. Code: Select all cd\wamp\bin\apache\apache2.2.11\bin After press Enter, your prompt should change as follows Code: Select all c:\wamp\bin\apache\apache2.2.11\bin> From there, we begin to create the self-signed SSL certificate and

jQuery 2.0, planned for early 2013, will drop the support for IE6-7-8

Sky High Code: jQuery 2.0 ends WinXP support - Good. Interesting article, interesting news from jQuery! It is seriously great step for jQuery to stop the support of IE8,7,6, depicting overall programmers opinion about these versions. As what jQuery officials have explained on ( source ), all those hooks used to fix oldIE compatibility issues made the jQuery run slower for modern browsers. Minding the percentage of IE6-7-8 users, this is a logical step forward. Luckily, starting from early 2013, when this change is planned, would mean adding a simple condition checking whether browser is IE8- and loading jQuery1.9, and otherwise loading jQuery2.0. I could imagine a issues that people using CDN and latest jQuery versions would come up with, if they forget to make the correct condition switch. However, 1) If my clients aren't willing to stay current, then it's time for me to find new clients I dont think everyone can change their clients like that. Even suggesting to

Google Developers Blog: Better Web Templating with AngularJS 1.0

I have tried out a bit AngularJS. I have to say I am sad to get to know it so late, because it could have been of grate use for certain html form related project. I really like the dynamic web templating of AngularJS, as you it makes the overall code very neat and easy to read. Source: Google Developers Blog: Better Web Templating with AngularJS 1.0 : By MiÅ¡ko Hevery , Google AngularJS team AngularJS lets you write web applications as if you had a smarter browser.  It lets you extend ...

A pew-pew manifesto...

Interesting discussion about Javascript by Bernd Paradies from Adobe. JavaScript is not suitable for large web apps

Compile Error: WSDLException, faultCode=CONFIGURATION_ERROR...

I found the best solution for such errors when using Spring WS. So, if you see errors like:  WSDLException, faultCode=CONFIGURATION_ERROR... Take a look at this url

Nicely categorized list of java libraries/utilities/frameworks

For up-to-date frameworks/utilities/libraries, this truly deserves it's name, ultimate collection! source Further, there are very nice tutorials/examples in there as well!

Turn off the windows automatic updates

I am one of those people who don't like to turn off their PCs. Yea, really nice waste of energy, I know... Usually work PC is the place when always something is running overnight, either some sort of calculations, parsing, simulations or any other nerdy stuff are performed. The most annoying part, when you work on windows, are the automatic updates. It can restart your PC by itself just to apply just installed updates. "§$%&%$ windows! The disable such a stupid option, Go to Start, Run "gpedit.msc" to bring up the group policy editor. Then navigate to the folder Local Computer Policy ->Computer Configuration ->Administrative Templates ->Windows Components ->Windows Update There are two settings and both will work, so it's your choice. Either enable No auto-restart for schedule Automatic Updates installations or set Re-prompt for restart with scheduled installations to a long time interval, like 1440 minutes. I prefer the first on

Runtime Error:class loading constraint violated

Webapp reports the following error every time it tries to poll the sql server: Uncaught exception thrown in one of the service methods of the servlet: dispatcher. Exception thrown : org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.VerifyError: class loading constraint violated (class: com/microsoft/sqlserver/jdbc/SQLServerResultSet method: updateNClob(ILcom/microsoft/sqlserver/jdbc/NClob;)V) at pc: 0 And it worked in the local environment, but not on the test server. SOLUTION: Go to test server WAS Integration Solutions Console, Applications->Enterprise Applications, and then click on your application Within Detail Properties, press, Class loading and update detection and there switch the Class loader order from Classes loaded with parent class loader first to Classes loaded with application class loader first. If you had it already set, then your issue is different then mine. Core explanation of the this error i

Parsing the Logical expression

Sometimes you need to parse the logical expression. I have made for my own purposes the regular expression which would distringuish all important tokens from the logical expression: ([\(!\s]*)[\s]*([^<=\s]+)[\s]*(<>|!=|==|<=|>=|<|>)[\s]*([^\s&|\)]*)[\s]*([\)]*)(&&|\|\|)? or as java string: "([\\(!\\s]*)[\\s]*([^<=\\s]+)[\\s]*(<>|!=|==|<=|>=|<|>)[\\s]*([^\\s&|\\)]*)[\\s]*([\\)]*)(&&|\\|\\|)?" this would give for  !(! (one== 56) && two>45) || !three!=funny the following solution Regular Expression ([\(!\s]*)[\s]*([^<=\s]+)[\s]*(<>|!=|==|<=|>=|<|>)[\s]*([^\s&|\)]*)[\s]*([\)]*)(&&|\|\|)? as a Java string "([\\(!\\s]*)[\\s]*([^<=\\s]+)[\\s]*(<>|!=|==|<=|>=|<|>)[\\s]*([^\\s&|\\)]*)[\\s]*([\\)]*)(&&|\\|\\|)?" Replacement $1fieldValue(\"$2\")$3$4$5$6 groupCount() 6

A useless, but nice Excel trick

To show just the fields in the worksheet which are useful, and hide all the rest of the fiels, To Hide Rows Select row whereyour data finishes Press Ctrl + Shift + Down Arrow Key Move mouse pointer over the row numbers, Right Click, Hide To Hide Columns Select Column 21 Press Ctrl + Shift + Right Arrow Keys Move mouse pointer over the column numbers/letters, Right Click, Hide

jQuery print example

This is just a small update of BenNadel 's great post on printing the part of the page using jQuery/Javascript. The code is placed here

Encoding troubles UTF-8 in Eclipse/Rational Application Developer...

Uh, I never understood at all what is the reason for all these encoding types! I had to do some modifications on a custom made JavaEE project which uses velocity template engine. I ended up having a lots of encoding problems. Now I want to write sort of a step by step instruction how fix it. Ok, so let's start. Sooo, you have troubles with your spring/javaEE eclipse project. Several steps to take a look: 1) Check here: Window -> Preferences -> General -> Workspace -> Text file encoding - set to UTF-8 This setting will let even your new files to be encoded in UTF-8. It is usual cause of troubleshttp://www.blogger.com/img/blank.gif 2) under Window -> Preferences search for encoding keyword and set everything you see to UTF-8 (this does not help too much, but sometimes is useful) 3) If your files are created outside eclipse project, check whether they are written/saved in UTF-8 coding. Notepad++ has a nice feature that is able to show you encoding of y

Samsung Galaxy S2 tip

It seems that Samsung is using by default the fast dormancy, a new technology which tries to save your battery life by turning your phone completely connection less if no activity is detected. This is cool, right? Not really, since in order for this to work, network provider has to support it as well, which makes the completely opposite effect, by draining the phone battery and still make phone disconnected when idle (e.g. no SMSes received). To disable this (my strong suggestion), do the following: *#*#9900#*#* and then choose disable fast dormancy and then Exit . I have tested this already for 1 month, and it works pretty fine, and battery life is extended definitely by some 20%-30%. Summary: - it prolongs/extends the battery life - it solves the issue of phone being completely disconnected at times Sources:http://www.blogger.com/img/blank.gif Source More about fast dormancy: Here Some other codes are also interesting, which I haven't tested yet (but will t

When you need to host a specific file on your spring application...

... and you don't want to disturb server configuration, as it would mean you need to make this setting on every new server you deploy your application. Simply add to web.xml something like this: <mime-mapping><extension>jnlp</extension> <mime-type>application/x-java-jnlp-file</mime-type> </mime-mapping> <mime-mapping><extension>jar</extension> <mime-type>application/java-archive</mime-type> </mime-mapping> Hope this helps anyone else. I was always rechecking Spring Security filters and always forgetting about the supporter MIME types...

Using AJAX call to send custom post data from the form

This was my solution and probably there are the better ones: jQuery.ajax({ url : //URL type: 'post', data: {'data' : JSON.stringify(data)}, dataType: 'html', cache: false, async : false, error: function (jqXHR, textStatus, errorThrown) { document.open(); document.write(res); document.close(); }, success: function (result) { document.open(); document.write(result); document.close(); } }); It is interesting to note that replacing whole html page via jQuery('html').html(result); does not work in IE9. Summary: if you wanna replace the whole page with newly html-formatted result, you have to use document.open();document.write(NewHTMLDocAsString);document.close(); instead of jQuery('html').html(result);

Javascript Prototype, sort of a object inheritance

Very cool thing to know about javascript: http://msdn.microsoft.com/en-us/scriptjunkie/ff852808

Javascript comparison operators

I came across very nice short explanation of the differences between == and === comparison operators. I have copied this into my blog just in case the post gets deleted from stackoverflow for whatever reason. The identity (===) operator behaves identically to the equality (==) operator except no type conversion is done, and the types must be the same to be considered equal. Reference: Javascript Tutorial: Comparison Operators The == operator will compare for equality after doing any necessary type conversions . The === operator will not do the conversion, so if two values are not the same type === will simply return false. It's this case where === will be faster, and may return a different result than ==. In all other cases performance will be the same. To quote Douglas Crockford's excellent JavaScript: The Good Parts , JavaScript has two sets of equality operators: === and !== , and their evil twins == and != . The good ones work the way you would expect.

When IE doesnt parse the received XML AJAX response...

Take care that configured dataType of your ajax call is set to 'xml' instead fo 'html' or 'json', since otherwise IE will interpret it as XML.

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