Change cursor style to hand

Written by coregps on March 19th, 2008 in Web Design.

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

You might want to change the default cursor of an html element to hand. For example, an img element, something like this:

<img src=”button.gif” style=”cursor: hand” />

This works well in IE, but in Firefox, it has no effect. The correct css style should be:

<img src=”button.gif” style=”cursor: pointer” />

It works both in IE and Firefox.

When I use dhtmlxTree dynamical loading with jsp, I always get the following exception:

Error type: DataStructure
Description: XML reffers to not existing parent

The code of the jsp page is as following:

<html>
<head>
</head>
<body>
    <link rel="STYLESHEET" type="text/css" href="css/dhtmlxtree.css">
    <script  src="js/dhtmlxcommon.js"></script>
    <script  src="js/dhtmlxtree.js"></script>
    <div id="treeboxbox_tree" style="width:100%; height:218;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"></div>
    <script type="text/javascript">
		tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
		tree.attachEvent("onClick",onNodeSelect);
		tree.setImagePath("images/tree/");
		tree.setXMLAutoLoading("AdminFolderServlet?action=folder_treeview");
		tree.loadXML("AdminFolderServlet?action=folder_treeview&id=1");
		function onNodeSelect(nodeId){
		    document.getElementById("parent_folder_id").value = nodeId;
		}
    </script>
</body>
</html>

And the following is the code snippet used to generate XML file of the tree:

String id = request.getParameter("id");
if (id == null) id = "1";
Vector folders = Folder.getFolders(Integer.parseInt(id));
StringBuffer buff = new StringBuffer("< ?xml version=\"1.0\"?>“);
buff.append(”
“);
for (int i = 0; i < folders.size(); i++) {
	Folder f = (Folder)folders.get(i);
	buff.append("“);
}
buff.append(”“);
response.setContentType(”text/xml”);
response.setHeader(”Cache-Control”,”no-cache”); //HTTP 1.1
response.setHeader(”Pragma”,”no-cache”); //HTTP 1.0
response.setDateHeader(”Expires”, 0); //prevents caching at the proxy server
response.getWriter().write(buff.toString());

The generated XML is well formed.

<?xml version="1.0"?>
<tree id='1'>
	<item child='1' id='2' text='Games' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
	<item child='1' id='3' text='Music' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
	<item child='0' id='4' text='Books' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
	<item child='1' id='5' text='Movies' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
	<item child='1' id='6' text='Photos' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
	<item child='0' id='14' text='Articles' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
</tree>

I finally found the solution. The id attribute of the tree element must point to the parent id, which data will be linked, by default super-root ID = 0, but it can be changed while tree initialization ( 4th parameter of constructor ), In case of dynamic loading the tree id must be equal to the parent ID for which data requested.

In my database, the root id of the top level folder is 1, however, I use 0 in the tree initialization method.

tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);

So, I got the exception. After changing the fourth parameter to 1, it works well.

tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",1);

Hope this can help someone else in the future :)

Grabbing color with ColorPic

Written by coregps on December 14th, 2007 in Web Design.

colorpic.JPGColorPic is a free tool provided by IconIco. It can be used to pick any color from screen. ColorPic show colors in hex and decimal. To grab a color, just select ColorPic window and then click Ctrl + G, to cancel the grab, just press Ctrl + G again. We can also adjust color with four advanced color mixers. In addition, ColorPic has a magnifier which make it possible to pick color on a high resolution monitor.

The following are some tips of using the ColorPic provided by IconIco:

1. Grabbing Colors

To grab a color from the screen move your mouse and press the ‘Ctrl’ and ‘G’ keys on your keyboard. The selected color Chip will now say ‘Grab’. To un-grab a color just press ‘Ctrl’ and ‘G’ again.

2. Accurate Color Grabbing

Use the arrow keys on your keyboard to nudge the mouse pointer by a single pixel.

3. Selecting Chips

Use your mouse, or use the function keys on the top of your keyboard, to select color chips in your palette.

4. Small Screen Problems

Use the blue up and down toggle buttons on each of the five sections to save screen space. You can also resize the ColorPic window from the bottom right.

5. Zoom In

Change the magnification factor with the slider above the magnifier area.

6. Smooth Color Samples

Use the point size slider above the magnification area to select a single, 3×3 or 5×5 pixel point size for smoother color sampling.

7. Websafe Colors

If your selected color is not websafe click the ‘WebSnap’ button to change the color to the nearest safe value.

8. Enter an Exact Color

Using the keyboard you can type an exact value in any of the color value textboxes, including the Hue, Saturation and Value textboxes.

9. Using the Color Mixers Precisely

When using any of the color mixers and sliders you can use the arrow keys on your keyboard and your mouse wheel to nudge the color by a single step.

10. Use a Color in another Application

To use the decimal or hexadecimal color values in another application click the corresponding ‘Copy’ button. Then in your other application you can use the paste command or ‘Ctrl + V’ to insert the color value.

For more information, take a look at here.

Removing duplicate whitespace using regular expression

Written by coregps on December 14th, 2007 in Java.

Just a simple note about how to remove duplicate whitespace using regular expression in java.

public class Test {
    public static void main(String[] args) {
        String str = "Hello      World!";
		System.out.println(str.replaceAll("\s+", " "));
	}
}

Unintall VMWare Server on Ubuntu

Written by coregps on November 16th, 2007 in Linux, Ubuntu.

I’ve ever installed VMWare Server on my Ubuntu server. Now I want to uninstall it. This can be done by opening a terminal and type the following command.

sudo /usr/bin/vmware-uninstall.pl

Hope it is helpful to anyone who has the same problem.



Site Navigation