"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - Martin Fowler
Tuesday, March 13, 2012
How do I submit a Chinese characters in Struts?
The Chinese characters "UTF-8" encoding not able to work with the above code. The magic trick is on the "TilesRequestProcessor", change
< controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" / >
to
< controller processorClass="com.fabiolee.struts.tiles.RequestProcessor" / >
in the "struts-config.xml" and add in the below class "RequestProcessor.java".
Then it will work nicely.
Thursday, September 8, 2011
Facebook Page Tab Height Scrollbar
If the body content of a html page to be added as a facebook page tab is longer than the usual facebook page height, we want to remove the vertical scrollbar and show the complete html page, here is a simple solution:
Saturday, March 1, 2008
div height error on IE6
IE6 again, "height.html" is an example code of div height error on IE6.
This code running no problem on IE7 & Firefox, but when it reach IE6, the height change to 20px.
Same case as my previous post, I look for Mr Google again. This time I get some post said:
1) IE6 height will have some white space if image is smaller then 12px, we need to set line-height to 0px.
2) IE6 height will have some white space if image is smaller then 20px, we need to set line-height to 0px & set a smaller font-size.
So, my code end up like "height_ie6_fix.html".
Finally, it work perfectly on IE6, IE7 & Firefox browsers.
This code running no problem on IE7 & Firefox, but when it reach IE6, the height change to 20px.
Same case as my previous post, I look for Mr Google again. This time I get some post said:
1) IE6 height will have some white space if image is smaller then 12px, we need to set line-height to 0px.
2) IE6 height will have some white space if image is smaller then 20px, we need to set line-height to 0px & set a smaller font-size.
So, my code end up like "height_ie6_fix.html".
Finally, it work perfectly on IE6, IE7 & Firefox browsers.
Monday, February 25, 2008
padding + height problem on Firefox
I though I was facing an error on Firefox browser when using padding & height attributes together in a CSS class. But I was error, in the end, it is still IE browser problem.
Let take an example "height_without_doctype.html"
When we run this code, it will display different output on Firefox & IE.
Firefox height = padding-top + height = 50px + 50px = 100px
IE height = height = 50px
After I find Mr Google, it point me to this url which is perfectly solve my above problem.
The solution is simple, just add in a DOC type, then IE will follow a common standard same as Firefox.
So, the code changed to "height_with_doctype.html"
Both browsers work the same now.
Let take an example "height_without_doctype.html"
When we run this code, it will display different output on Firefox & IE.
Firefox height = padding-top + height = 50px + 50px = 100px
IE height = height = 50px
After I find Mr Google, it point me to this url which is perfectly solve my above problem.
The solution is simple, just add in a DOC type, then IE will follow a common standard same as Firefox.
So, the code changed to "height_with_doctype.html"
Both browsers work the same now.
Friday, February 22, 2008
Javascript Menu Navigation
Recently I research on how to implement a javascript menu navigation. At the beginning, I was thinking of use library to make one. But there are so many different request coming in until I decided to develop my own javascript menu navigation.
Here is the sample code that I write (3 levels menu navigation):
During testing on this sample code, I find out that IE6 having some different behavior then IE7 & Firefox on onmouseout() function. If possible, avoid to use that function.
Here is the sample code that I write (3 levels menu navigation):
During testing on this sample code, I find out that IE6 having some different behavior then IE7 & Firefox on onmouseout() function. If possible, avoid to use that function.
Wednesday, February 20, 2008
XML DOM
I really want to fuck off this thing, facing too much problem on it, finally fully understand it now.
Recently I alway need to read xml data, by using jsp, javascript, asp, ...... Element, Node, NodeList alway come out from XML DOM. I hate them very much.
Different browsers have different DOM parsing, when the code work on IE, it didn't mean it will work on Firefox. I need to test on both browsers for so many times only I can confirm the code is working fine.
The important thing to take note when using XML DOM:
"The best way to only process element nodes is to iterate through the child nodes and only process those with a node type of 1".
Recently I alway need to read xml data, by using jsp, javascript, asp, ...... Element, Node, NodeList alway come out from XML DOM. I hate them very much.
Different browsers have different DOM parsing, when the code work on IE, it didn't mean it will work on Firefox. I need to test on both browsers for so many times only I can confirm the code is working fine.
The important thing to take note when using XML DOM:
"The best way to only process element nodes is to iterate through the child nodes and only process those with a node type of 1".
Saturday, February 9, 2008
Encoding the Request Parameters
Recently I just faced some problem with Ajax implementation, here is an answer I found for the problem:
"When developing a traditional Web application you don't have to worry about encoding the form data because the Web browser performs this operation automatically when the user submits the data. In the case of an Ajax application, however, it's your job to encode the request parameters. JavaScript provides a very useful function named escape() that replaces any character that cannot be part of a URL with %HH where HH is the hexadecimal code. For example, any space character is replaced with %20."
The problem is very simple, when we make a http call to any url, we should encode the request parameters. I think I faced this similar problem when doing J2ME http call as well.
This code when make a http call, the result url will become:
http://www.abc.com/testing.asp?title=Title 1&content=Content body
Do you notice what problem with this url? Ya, the white space. From server side, the title & content text will received wrongly. (White space missing)
In order to correct it, we must add an encode function to replace the special text (white space) to "%20" or "+".
http://www.abc.com/testing.asp?title=Title+1&content=Content+body
http://www.abc.com/testing.asp?title=Title%201&content=Content%20body
Then only we can receive the correct text from the http call.
Another half day gone.
Here some special text that might be useful:
1) White space - %20
2) New line - %0D%0A (Windows), %0A (Unix), %0D (Macintosh)
3) "+" - %2B
4) "/" - %2F
"When developing a traditional Web application you don't have to worry about encoding the form data because the Web browser performs this operation automatically when the user submits the data. In the case of an Ajax application, however, it's your job to encode the request parameters. JavaScript provides a very useful function named escape() that replaces any character that cannot be part of a URL with %HH where HH is the hexadecimal code. For example, any space character is replaced with %20."
The problem is very simple, when we make a http call to any url, we should encode the request parameters. I think I faced this similar problem when doing J2ME http call as well.
This code when make a http call, the result url will become:
http://www.abc.com/testing.asp?title=Title 1&content=Content body
Do you notice what problem with this url? Ya, the white space. From server side, the title & content text will received wrongly. (White space missing)
In order to correct it, we must add an encode function to replace the special text (white space) to "%20" or "+".
http://www.abc.com/testing.asp?title=Title+1&content=Content+body
http://www.abc.com/testing.asp?title=Title%201&content=Content%20body
Then only we can receive the correct text from the http call.
Another half day gone.
Here some special text that might be useful:
1) White space - %20
2) New line - %0D%0A (Windows), %0A (Unix), %0D (Macintosh)
3) "+" - %2B
4) "/" - %2F
Subscribe to:
Posts (Atom)