MXcode All about coding 2010-06-23T09:30:25Z WordPress http://mxcode.com/feed/atom/ MXcode <![CDATA[Flex draw]]> http://mxcode.com/2010/06/flex-draw/ 2010-06-04T09:47:45Z 2010-06-04T09:39:27Z

]]>
2
MXcode <![CDATA[Go to top function with slide effect]]> http://mxcode.com/2010/03/go-to-top-function-with-slide-effect/ 2010-06-23T09:30:25Z 2010-03-21T03:18:57Z
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var goto_top_type = -1;
var goto_top_itv = 0;
 
function goto_top_timer()
{
  var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;
  var moveby = 15;
 
  y -= Math.ceil(y * moveby / 100);
  if (y < 0) {
    y = 0;
  }
 
  if (goto_top_type == 1) {
    document.documentElement.scrollTop = y;
  }
  else {
    document.body.scrollTop = y;
  }
 
  if (y == 0) {
    clearInterval(goto_top_itv);
    goto_top_itv = 0;
  }
}
 
function goto_top()
{
  if (goto_top_itv == 0) {
    if (document.documentElement && document.documentElement.scrollTop) {
      goto_top_type = 1;
    }
    else if (document.body && document.body.scrollTop) {
      goto_top_type = 2;
    }
    else {
      goto_top_type = 0;
    }
    if (goto_top_type > 0) {
      goto_top_itv = setInterval('goto_top_timer()', 50);
    }
  }
}
]]>
0
MXcode <![CDATA[Use JSP Tag with content body]]> http://mxcode.com/2010/03/use-jsp-tag/ 2010-03-17T09:09:50Z 2010-03-17T08:57:46Z 1.First add this to web.xml:

1
2
3
4
    <taglib>
      <taglib-uri>http://longshine.com/cufj</taglib-uri>
      <taglib-location>/WEB-INF/tlds/cufjTag.tld</taglib-location>
    </taglib>

2.Put the tld file into folder: /WEB-INF/tlds/. And the tld file is like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE taglib
  PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
  "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>cufjTag</short-name>
    <uri>http://longshine.com/cufj</uri>
 
    <tag>
      <name>role</name>
      <tag-class>longshine.telecom.mob.tag.RoleTag</tag-class>
      <body-content>JSP</body-content>
      <attribute>
      	<name>roleIds</name>
      	<required>true</required>
      </attribute>
    </tag>   
</taglib>

3.Now is the java class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package longshine.telecom.mob.tag;
 
import java.io.IOException;
 
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;
 
import longshine.telecom.mob.common.SessionUserObject;
import longshine.telecom.mob.service.BaseService;
 
public class RoleTag extends BodyTagSupport {
 
	private static final long serialVersionUID = 1L;
	private String roleIds;
 
	public int doEndTag() throws JspException {
		BodyContent bc = getBodyContent();
		if (roleIds != null) {
			SessionUserObject sessionUserObject = (SessionUserObject) pageContext.getSession()
				.getAttribute(BaseService.SESSION_USER_OBJECT);
			if (sessionUserObject == null || sessionUserObject.getPermissions() == null) {
				return SKIP_BODY;
			}
			String[] roles = roleIds.split(",");
			for (int i = 0; i < roles.length; i++) {
				if (sessionUserObject.getPermissions().contains(roles[i])) {
					try {
						pageContext.getOut().print(bc.getString());
						return SKIP_BODY;
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}
		}
		return SKIP_BODY;
	}
 
	public String getRoleIds() {
		return roleIds;
	}
 
	public void setRoleIds(String roleIds) {
		this.roleIds = roleIds;
	}
}

5.At last, you can write JSP with this tag, remember to declare this tag in the JSP head:
<%@taglib uri="http://longshine.com/cufj" prefix="c" %>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://longshine.com/cufj" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP TAG</title>
</head>
<body>
 
<c:role roleIds="002">
	<input type="text" name="n"></input>
</c:role>
 
</body>
</html>

Enjoy it!

]]>
8
MXcode <![CDATA[Change ip setting using bat command]]> http://mxcode.com/2010/03/change-ip-setting-using-bat-command/ 2010-03-16T14:19:34Z 2010-03-16T14:19:12Z Example:
1.Change to static:

netsh interface ip set address "Wireless Network Connection" source = static 10.206.15.184 255.255.255.0 10.206.15.1
netsh interface ip add dns name = "Wireless Network Connection" addr = 10.206.1.33
netsh interface ip add dns name = "Wireless Network Connection" addr = 58.22.96.66

2.Change to dhcp:

netsh interface ip set address "Wireless Network Connection" source = dhcp
netsh interface ip set dns name = "Wireless Network Connection" source = dhcp
]]>
0
MXcode <![CDATA[how to install squid-2.5.STABLE13 on linux]]> http://mxcode.com/2010/03/how-to-install-squid-2-5-stable13-on-linux/ 2010-03-09T03:13:09Z 2010-03-09T03:12:20Z To build and install the Squid Cache, type:

% ./configure –prefix=/usr/local/squid
% make all
% make install

To run a Cache, you will need to:

1. customize the squid.conf configuration file:
% vi /usr/local/squid/etc/squid.conf

2. start the cache:
% /usr/local/squid/sbin/squid

If you want to use the WWW interface to the Cache Manager, copy the cachemgr.cgi program into your httpd server’s cgi-bin directory.

]]>
1
MXcode <![CDATA[validation problems when deploy an application in weblogic 10]]> http://mxcode.com/2010/03/validation-problems-when-deploy-an-application-in-weblogic-10/ 2010-03-16T14:20:39Z 2010-03-03T11:34:07Z Error message is:

Unable to access the selected application.
 
Exception in AppMerge flows' progression
 
Exception in AppMerge flows' progression
 
VALIDATION PROBLEMS WERE FOUND problem: cvc-complex-type.2.3: Element 'filter@http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content.: problem: cvc-complex-type.2.3: Element 'init-param@http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content.: problem: cvc-complex-type.2.3: Element 'init-param@http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content.: problem: cvc-complex-type.2.3: Element 'filter-mapping@http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content.:
 
VALIDATION PROBLEMS WERE FOUND problem: cvc-complex-type.2.3: Element 'filter@http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content.: problem: cvc-complex-type.2.3: Element 'init-param@http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content.: problem: cvc-complex-type.2.3: Element 'init-param@http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content.: problem: cvc-complex-type.2.3: Element 'filter-mapping@http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content.:

If you meet this error message, please check your web.xml and make sure it does not contain any unusual characters.

]]>
4
MXcode <![CDATA[open a port on linux server]]> http://mxcode.com/2010/01/open-a-port-on-linux-server/ 2010-03-05T02:46:05Z 2010-01-13T14:39:47Z =========================================
iptables -A RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 3690 -j ACCEPT
=========================================
RH-Firewall-1-INPUT is the name of the chain, and change 3690 to the port number you expect.

You must restart the service to make it effective:
[root@localhost ~]# service iptables restart

]]>
0
MXcode <![CDATA[make div align center]]> http://mxcode.com/2009/12/make-div-align-center/ 2009-12-31T03:29:49Z 2009-12-31T03:15:25Z use style as:
.style{margin-left:auto;margin-right:auto;}

or
.style{margin:0 auto;}
for short

]]>
0
MXcode <![CDATA[ORACLE UTL_RAW.BIT_AND]]> http://mxcode.com/2009/12/oracle-utl_raw-bit_and/ 2009-12-31T03:23:44Z 2009-12-01T09:39:02Z eg.
select to_number(UTL_RAW.bit_and(to_char(1), ‘3′)) from dual;

]]>
0
MXcode <![CDATA[href and onclick method in ‘A’ tag]]> http://mxcode.com/2009/10/href-and-onclick-method-in-a-tag/ 2009-10-16T09:30:15Z 2009-10-16T09:25:43Z How to invoke onclick method but not go to the page head.

1
<a href="#" onclick="javascript:jsMethod();return false;">a link</a>
]]>
0