<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
  <channel>
    <title>micrexp</title>
    <description></description>
    <link>http://micrexp.javaeye.com</link>
    <language>UTF-8</language>
    <copyright>Copyright 2003-2008, JavaEye.com</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>JavaEye - 做最棒的软件开发交流社区</generator>
      <item>
        <title>关于对象进行按JSON格式重写的问题:如何实现对象中的局部变量(问题已解决,感谢sp42,有兴趣的可以来看一下)</title>
        <author>micrexp</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://micrexp.javaeye.com">micrexp</a>&nbsp;
          链接：<a href="http://micrexp.javaeye.com/blog/79231" style="color:red;">http://micrexp.javaeye.com/blog/79231</a>&nbsp;
          发表时间: 2007年05月13日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <pre name="code" class="java">
/////////////
//关于对象进行JSON格式的改造问题
//改造前

var a = function(){
    this.fieldA = "field";
    this.methodA = function(){
        alert(this.fieldA);
    }
}
var c =new a()
c.methodA();

//改造后
var a = {
    fieldA:"field",
    methodA:function(){
        alert(this.fieldA);
    }
}
var b = function(){};
b.prototype = a;
var c = new b();
c.methodA();



//问题
//为了在对象中隐藏“fieldA”我将代码改成好下方式
var a = function(){
    var fieldA = "field";
    this.methodA = function(){
        alert(fieldA);
    }
}
var c =new a()
c.methodA();
//那么，在JSON中如何来实现这种隐藏方式
//另外如果代码如是以下这种形式,那该如何来改?
var a = function(){
    var fieldA = "";
    this.methodA = function(){
        alert(fieldA);
    }

    function modify(){
        fieldA="field";
    }
    modify();
}
var c =new a()
c.methodA();
//PS:但愿不是新手贴
</pre>
          <br/>
          <span style="color:red;">
            <a href="http://micrexp.javaeye.com/blog/79231#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Sun, 13 May 2007 16:28:45 +0800</pubDate>
        <link>http://micrexp.javaeye.com/blog/79231</link>
        <guid>http://micrexp.javaeye.com/blog/79231</guid>
      </item>
      <item>
        <title>今天下午刚写的树形控件</title>
        <author>micrexp</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://micrexp.javaeye.com">micrexp</a>&nbsp;
          链接：<a href="http://micrexp.javaeye.com/blog/78945" style="color:red;">http://micrexp.javaeye.com/blog/78945</a>&nbsp;
          发表时间: 2007年05月11日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <pre name="code" class="java">
var HK_TreeNode = function(pNode){
    var me = this;
    var nodeValue = "";
    var nodeImage = document.createElement("img");
    var nodeElement = document.createElement("div");
    var nodeText = document.createElement("div");
    var childLayout = document.createElement("div");    
    nodeElement.appendChild(nodeImage);
    nodeElement.appendChild(nodeText);
    nodeElement.appendChild(childLayout);
    nodeImage.src="images/plus.png";
    nodeImage.className = "tree_nodeimage";
    nodeText.className = "tree_nodetext";
    childLayout.className = "tree_nodelayout";
    childLayout.style.display = "none";
    var nodeIndex = -1;
    var parentNode = null; 
    var level = 0;
    var items = new Array();
    if(parentNode!=null){
        level = pNode.level + 1;
        parentNode = pNode; 
    }
    this.tree = null;
    this.data = null;
    this.setActive = function(){
        var activeNode = this.tree.activeNode;
        if(activeNode!=null){
            activeNode.deActive();        
        }
        nodeText.className = "tree_nodetextActive";
        this.tree.activeNode = this;
    }
    this.deActive = function(){
        this.tree.activeNode = null;    
        nodeText.className = "tree_nodetext";
    }
    this.appendChild = function(node){
        nodeIndex = items.push(node);
        childLayout.appendChild(node.getElement()); 
        nodeImage.src="images/plus.gif";
    }
    this.expand = function(){
        if(childLayout.style.display != "none"){
                nodeImage.src="images/plus.gif";
                childLayout.style.display = "none";
        }else{
            if(items.length>0){
                nodeImage.src="images/plusExpand.gif";
                childLayout.style.display = "";
            }
        }
    }
    this.getCount = function(){
        return items.length;
    }    
    this.getLevel = function(){
        return level;
    }
    this.setParentNode = function(node){
        parentNode = node;
        node.appendChild(nodeElement);
    }
    this.getParentNode = function(){
        return node;
    }
    this.getElement = function(){
        return nodeElement;
    }
    this.getImageElement = function(){
        return nodeImage;
    }
    this.getTextElement = function(){
        return nodeText;
    }
    this.setText = function(value){
        nodeText.innerText = value;
    }
    this.getText = function(){
        return nodeText.innerText;
    }
    this.setValue = function(value){
        nodeValue = value;
        this.setText(value);
    }
    this.getValue = function(){
        return value;
    }    
    function onnodeclick(){
        me.expand();
    }
    function onnodetextclick(){
        me.setActive();
    }
    function ontextdblclick(){
        me.expand();
    }
    function onselect(){
        return false;
    }
    nodeElement.attachEvent("onselectstart",onselect);
    nodeText.attachEvent("onclick",onnodetextclick);
    nodeText.attachEvent("ondblclick",ontextdblclick);
    nodeImage.attachEvent("onclick",onnodeclick);
}

var HK_Tree = function(){
    var me = this;
    var layout = document.createElement("div");
    var items = new Array();
    var map = new Object();
    var root = new Array();
    var activeNode = null;    
    this.xml = null;
    this.parent = null;
    this.primaryField = "";
    this.parentField = "";
    this.valueField = "";
    this.textField = "";
    this.activeNode = null;
    this.appendNode = function(parentNode){
        var node = new HK_TreeNode(parentNode);
        if(parentNode!=null){
            parentNode.appendChild(node);
        }else{
            layout.appendChild(node.getElement());
            root.push(node);
        }
        node.tree = this;
        items.push(node);        
        return node;
    }
    this.getNodeByIndex = function(index){
        if(items[i]!=undefined){
            return items[i];
        }
        return null;
    }
    this.getNodeByName = function(name){
        if(map[name]!=undefined){
            return map[name];
        }
        return null;        
    }
    this.getCount = function(){
        return items.length;
    }
    this.laodxml = function(){
        
    }
    this.databand = function(){
        var oRows = this.xml.getElementsByTagName("Row");
        var oCol,oCells,oRow;
        for(var i=0;i&lt;oRows.length;i++){
            var parentId = oRows[i].selectSingleNode("./field[@name='"+this.parentField+"']");
            var nodeId = oRows[i].selectSingleNode("./field[@name='"+this.primaryField+"']");
            var nodeValue = oRows[i].selectSingleNode("./field[@name='"+this.valueField+"']");
            var nodeText = oRows[i].selectSingleNode("./field[@name='"+this.textField+"']");
            if(parentId!=null&&nodeId!=null){
                var node = this.appendNode(this.getNodeByName(parentId.text));
                node.data = oRows[i].xml;
                if(nodeValue!=null){
                    node.setValue(nodeValue.text);                    
                }
                if(nodeText!=null){
                    node.setText(nodeText.text);
                }
                map[nodeId.text] = node;
            }
            
        }
        this.ondataband();
    }
    this.init = function(){
        this.parent.appendChild(layout);
    }
    this.ondataband = function(){};
}

var tree = new HK_Tree();
tree.parent = document.getElementById("treepanel");
tree.primaryField = "unitId";
tree.parentField = "parentUnitId";
tree.valueField = "name";
tree.textField = "name";
tree.init();
</pre><br />今天下午完成的,发上来给大家看看
          <br/>
          <span style="color:red;">
            <a href="http://micrexp.javaeye.com/blog/78945#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Fri, 11 May 2007 19:41:38 +0800</pubDate>
        <link>http://micrexp.javaeye.com/blog/78945</link>
        <guid>http://micrexp.javaeye.com/blog/78945</guid>
      </item>
      <item>
        <title>在javascript里面怎么取得一个对像在数组中的位置 </title>
        <author>micrexp</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://micrexp.javaeye.com">micrexp</a>&nbsp;
          链接：<a href="http://micrexp.javaeye.com/blog/78061" style="color:red;">http://micrexp.javaeye.com/blog/78061</a>&nbsp;
          发表时间: 2007年05月08日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          不好意思，忘了写环境<br />不知道现在算不算新手贴了<img src="/images/smiles/icon_cool.gif"/><br /><br />在JAVA里面除了循环我不知道什么更好的方法实现,但我知道如果是一个<br />LIST对像可以用indexOf(object)来取object的当前位置.他们实现的方式我也知道<br />我只是想知javascript里的Array对像是否也有这样的功能,或者说其它的替代实现方式.<br /><br />算了,当我没问这个问题,两次新手贴了,这里的都是高手<br /><br /><br />顺便发现了一个BUG,哈哈,不知道这倒底是不是BUG,反正我发出来了
          <br/>
          <span style="color:red;">
            <a href="http://micrexp.javaeye.com/blog/78061#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 08 May 2007 23:45:25 +0800</pubDate>
        <link>http://micrexp.javaeye.com/blog/78061</link>
        <guid>http://micrexp.javaeye.com/blog/78061</guid>
      </item>
      <item>
        <title>刚刚看了一个XD写的TAB页,顺便发一个我写的</title>
        <author>micrexp</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://micrexp.javaeye.com">micrexp</a>&nbsp;
          链接：<a href="http://micrexp.javaeye.com/blog/78022" style="color:red;">http://micrexp.javaeye.com/blog/78022</a>&nbsp;
          发表时间: 2007年05月08日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          顺便贴一个我写的<br /><br /><pre name="code" class="java">
代码 &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
&lt;html xmlns="http://www.w3.org/1999/xhtml" >  
&lt;head>  
    &lt;title>Untitled Page&lt;/title>  
    &lt;link type="text/css" href="gridstyle.css" rel="StyleSheet"/>  
    &lt;script language="javascript" type="text/javascript">  
        var HK_TabItem = function(){   
            this.tabControl = null;   
            var button = document.createElement("div");              
            var items = new Array();   
            var active = false;   
            this.appendItem = function(value){   
                items[items.length] = value;   
                valuevalue.oldVisible = value.style.display;   
                value.style.display = "none";   
            }   
            this.getElement = function(){   
                return button;   
            }   
            this.setCaption = function(value){   
                button.innerText = value;   
            }   
            this.setActive = function(){   
                if(active){return};   
                button.className = "tab_tabbuttonactive";   
                this.tabControl.setActiveTab(this);   
                for(var i=0;i&lt;items.length;i++){   
                    items[i].style.display = items[i].oldVisible;   
                }   
                active = true;   
            }   
            this.deActive = function(){   
                button.className = "tab_tabbutton";   
                for(var i=0;i&lt;items.length;i++){   
                    items[i].style.display = "none";   
                }   
                active = false;   
            }   
            function onClick(){   
                button.tab.setActive();   
            }   
            button.attachEvent("onclick",onClick);   
            button.className = "tab_tabbutton";   
            button.tab = this;   
        }   
        var HK_TabControl = function(){   
            var activeTab = null;   
            var banner =document.createElement("div");   
            var head = document.createElement("div");   
            var line = document.createElement("div");   
            var tab = document.createElement("div");   
            var padding = document.createElement("div");   
            banner.className = "tab_banner";   
            head.className = "tab_head";   
            line.className = "tab_line";   
            padding.className = "tab_padding";   
            line.innerHTML = " ";   
            tab.appendChild(banner);   
            tab.appendChild(line);   
            banner.appendChild(head);               
            this.tabs = new Array();   
            this.setActiveTab = function(value){   
                if(activeTab!=null){   
                    activeTab.deActive();   
                }                
                activeTab = value;      
            }   
            this.getActiveTab = function(){   
                return activeTab;   
            }   
            this.appendTab = function(){   
                var tab = new HK_TabItem();   
                banner.appendChild(tab.getElement());   
                tab.tabControl = this;   
                return tab;   
            }   
            this.parent = null;     
            this.init = function(){   
                this.parent.appendChild(tab);   
                banner.appendChild(padding);   
                padding.style.pixelWidth = banner.offsetWidth - padding.offsetLeft-2;   
            }             
        }   
    &lt;/script>  
&lt;/head>  
&lt;body>  
&lt;div id="test">&lt;/div>  
    &lt;div id="test1" style="width: 100px; height: 100px">  
        &lt;input id="Button1" type="button" value="button" />  
        asdfasdf&lt;/div>  
    &lt;div id="test2" style="width: 100px; height: 100px">  
        asdfasdf&lt;input id="Text1" type="text" />&lt;/div>  
    &lt;div id="test3" style="width: 100px; height: 100px">  
        &lt;input id="Checkbox1" type="checkbox" />asdfasdf&lt;/div>  
    &lt;div id="test4" style="width: 100px; height: 100px">  
        asdfasdf&lt;input id="Hidden1" type="hidden" />&lt;/div>  
        &lt;script>  
            var tabcontrol = new HK_TabControl();   
            var tab = tabcontrol.appendTab();       
            tab.setCaption("test1");   
            tab.appendItem(document.getElementById("test1"));                     
            var tab = tabcontrol.appendTab();       
            tab.setCaption("test2");   
            tab.appendItem(document.getElementById("test2"));        
            var tab = tabcontrol.appendTab();       
            tab.setCaption("test3");   
            tab.appendItem(document.getElementById("test3"));        
            var tab = tabcontrol.appendTab();       
            tab.setCaption("test4");   
            tab.appendItem(document.getElementById("test4"));        
            tab.setActive();               
            tabcontrol.parent = document.getElementById("test");   
            tabcontrol.init();   
        &lt;/script>  
  
&lt;/body>  
&lt;/html>  
  
css:   
  
tab_tabbuttonactive   
{   
    cursor:hand;   
    text-align:center;   
    vertical-align:middle;   
    background-color: #cde6f8;   
    border-width:1px;   
    border-top:solid 1px #336699;   
    border-left:solid 1px #336699;   
    border-right:solid 1px #336699;   
    display:inline;   
    float:left;     
    height:26px;   
    width:80px;   
    text-align:center;   
    vertical-align:middle;   
    line-height:2;   
}   
.tab_padding   
{   
    cursor:hand;   
    text-align:center;   
    vertical-align:middle;   
    border-bottom:solid 1px #336699;    
    border-width:1px;   
    background-color: #98b1c4;    
    display:inline;   
    float:left;     
    height:27px;   
}   
.tab_tabbutton   
{   
    cursor:hand;   
    text-align:center;   
    vertical-align:middle;   
    border-bottom:solid 1px #336699;    
    border-width:1px;   
    background-color: #98b1c4;    
    display:inline;   
    float:left;     
    height:26px;   
    width:80px;   
    text-align:center;   
    vertical-align:middle;   
    line-height:2;   
}   
.tab_banner   
{   
    cursor:hand;   
    text-align:center;   
    vertical-align:middle;   
    background-color: #98b1c4;    
    height:27px;     
}   
.tab_head   
{   
    cursor:hand;   
    text-align:center;   
    vertical-align:middle;   
    border-bottom:solid 1px #336699;    
    border-width:1px;   
    background-color: #98b1c4;    
    display:inline;   
    float:left;     
    width:12px;   
    height:27px;   
}   
.tab_line   
{   
    background-color:#cde6f8;   
    line-height: 6px;   
}   
</pre><br />[img ][/img]
          <br/>
          <span style="color:red;">
            <a href="http://micrexp.javaeye.com/blog/78022#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 08 May 2007 17:41:33 +0800</pubDate>
        <link>http://micrexp.javaeye.com/blog/78022</link>
        <guid>http://micrexp.javaeye.com/blog/78022</guid>
      </item>
      <item>
        <title>问一个很简单的问题,在javascript里面怎么取得一个对像在数组中的位置</title>
        <author>micrexp</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://micrexp.javaeye.com">micrexp</a>&nbsp;
          链接：<a href="http://micrexp.javaeye.com/blog/78020" style="color:red;">http://micrexp.javaeye.com/blog/78020</a>&nbsp;
          发表时间: 2007年05月08日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <span style="color: red">不要告诉我用循环</span><br /><br />在JAVA里面除了循环我不知道什么更好的方法实现,但我知道如果是一个<br />LIST对像可以用indexOf(object)来取object的当前位置.他们实现的方式我也知道<br />我只是想知javascript里的Array对像是否也有这样的功能,或者说其它的替代实现方式.<br /><br />算了,当我没问这个问题,两次新手贴了,这里的都是高手<br /><br /><br />另外发现了这里的一个BUG,扣我分的XD应该看出来了吧
          <br/>
          <span style="color:red;">
            <a href="http://micrexp.javaeye.com/blog/78020#comments" style="color:red;">本文的讨论也很精彩，浏览讨论>></a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/115' target='_blank'><span style="color:red;font-weight:bold;">JavaEye图灵杯第2届问答大赛开始了！8月4日至8月17日，奖品丰厚！</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 08 May 2007 17:32:58 +0800</pubDate>
        <link>http://micrexp.javaeye.com/blog/78020</link>
        <guid>http://micrexp.javaeye.com/blog/78020</guid>
      </item>
  </channel>
</rss>