`
sunway
  • 浏览: 114772 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Ext onReady 加载页面的问题

阅读更多

1。使用Ext.onReady(),发现ext内部报空指针错误,用Null.createChild()了。

 

 使用<%
    request.setAttribute("decorator", "none");
    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
%>
<
%@page language="java" contentType="text/html; charset=UTF-8"
 pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="w" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/css/ext-all.css" />
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/css/button.css" />
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/workbench.css" />
 <script type="text/javascript" src="../AjaxExt/adapter/ext/ext-base-debug.js"></script>
 <script type="text/javascript" src="../AjaxExt/ext-all-debug.js"></script>
 
<title>View <s:text name="#parameters.action" /></title>
<script type="text/javascript">
Ext.onReady(function(){
       var tabs = new Ext.TabPanel({
        renderTo: "tab1",
          width:800,
           activeTab: 0,
        deferredRender: false,  
           height:400,
           bufferResize:true,
           monitorResize:true,
           bodyStyle:'background-color:#3CA9C4;padding-top:5px;padding-left:1px;',
           enableTabScroll:true
       });
       var tabcontent;
       <s:if test="allModules.size > 0">
       <s:iterator value="allModules" id="obj">
        <s:if test="#obj.components.size > 0">
          var subTabs = new Ext.TabPanel({
                 width:598,
                 activeTab: 0,
                 deferredRender: false,
                 height:200,
               //  title:'<s:property value="#obj.moduleName" />',
                 title:'<s:property value="#obj.i18N" />',
                 enableTabScroll:true,
                 autoScroll : true
             });
      <s:iterator value="#obj.components" id="comp">
       <s:if test="#comp.id in entryComponent">
        var functions=''+"<input type=checkbox id=entry<s:property value="#comp.id" />  onclick=\"disableAll(this,'<s:property value="#comp.id" />'); \"  checked=\"checked\" name=componentList value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.enterComponent"/> ";
       
       </s:if>
          <s:if test="#comp.id not in entryComponent">
       var functions=''+"<input type=checkbox id=entry<s:property value="#comp.id" />  onclick=\"disableAll(this,'<s:property value="#comp.id" />'); \"  name=componentList value='<s:property value="#comp.id" />'> <s:text name="Entity.Role.privilege.enterComponent"/> ";

      </s:if >
     <s:if test="#comp.id in entryAllowAll">
           
         functions=functions+"<input type=checkbox onclick=\"enableEntry(this,'<s:property value="#comp.id" />'); \" id=allow<s:property value="#comp.id" /> checked=\"checked\" name=componentAllowAll value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.allowAllFunction"/> <br><br>";

     </s:if >
     <s:if test="#comp.id not in entryAllowAll">
        functions=functions+"<input type=checkbox onclick=\"enableEntry(this,'<s:property value="#comp.id" />'); \" id=allow<s:property value="#comp.id" /> name=componentAllowAll value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.allowAllFunction"/>  <br><br>";

     </s:if >
     
     
     
     
     <s:if test="#comp.functionList.size > 0">
       <s:if test="#comp.id in entryAllowAll">
         functions=functions+"<div id=function<s:property value="#comp.id" /> style=\"visibility:hidden;\"><s:text name="Entity.Role.privilege.setFunctionPoints"/><br>";
      </s:if> 
      <s:if test="#comp.id not in entryAllowAll">
         functions=functions+"<div id=function<s:property value="#comp.id" /> style=\"visibility:visible;\"><s:text name="Entity.Role.privilege.setFunctionPoints"/><br>";
      </s:if >
      
        <s:iterator value="#comp.functionList" id="func" status="st">
           <s:if test="#func.id in roleFunctionNames">
            functions=functions+"<input type=checkbox name=functionList onclick=\"enablePrivilege(this,'<s:property value="#comp.id" />'); \"  checked=\"checked\"  value='<s:property value="#func.id" />'>"+'<s:text name="Function.%{#func.id}" />'+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         </s:if>
         <s:if test="#func.id not in roleFunctionNames">
          functions=functions+"<input type=checkbox name=functionList onclick=\"enablePrivilege(this,'<s:property value="#comp.id" />'); \"  value='<s:property value="#func.id" />'>"+'<s:text name="Function.%{#func.id}" />'+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         </s:if >
         <s:if test="#st.count%3==0">
           functions=functions+"<br>";
         </s:if >
         </s:iterator>
          functions=functions+"</div>";
     
     </s:if >
     
     subTabs.add({title:'<s:property value="#comp.i18N" />', autoScroll : true,autoShow:false,html:functions}).show();
      </s:iterator>  
         tabs.add(subTabs).show();

        </s:if>
        
        
        
        
       <s:else >
       tabs.add({title:'<s:property value="obj.i18N" />'}).show();
      
    </s:else>
    </s:iterator>
         
       </s:if>
       <s:else>
       </s:else>
     tabs.setActiveTab(0);
  });

function enableEntry(me,entrycomponent){
 var o=document.getElementById('entry'+entrycomponent);
 var oo=document.getElementById('function'+entrycomponent);
 if(me.checked){
  o.checked=true;
  if(oo!=null)oo.style.visibility='hidden';
 }else{
  if(oo!=null)oo.style.visibility='visible';
 }
 
 
}

function disableAll(me,entrycomponent){
 var o=document.getElementById('allow'+entrycomponent);
 var oo=document.getElementById('function'+entrycomponent);
 if(!(me.checked))
  o.checked=false;
  
 
}
function enablePrivilege(me,entrycomponent){
 var o=document.getElementById('entry'+entrycomponent);
 if(me.checked)o.checked=true;

}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="10">
  <s:form action="%{#parameters.action}/savePrivileges">
   <s:hidden name="id" label="ID" />
   <s:hidden name="obj.id" label="ID" />

   <div id="tab1"></div>
   
   
   <input type="submit" class="button"
    value="<s:text name='General.Button.submit'/>" />
   <input type="button" class="button"
    value="<s:text name='General.Button.return'/>"
    onClick="javascript: history.go(-1);" />
    
    
  </s:form>
  
  
 </body>
</html>

结果不能正确显示TabPanel,后来发现是onReady 中加载的时候出现问题,后来改为带延迟的。

 

<%
    request.setAttribute("decorator", "none");
    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
%>
<
%@page language="java" contentType="text/html; charset=UTF-8"
 pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="w" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/css/ext-all.css" />
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/css/button.css" />
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/workbench.css" />
 <script type="text/javascript" src="../AjaxExt/adapter/ext/ext-base-debug.js"></script>
 <script type="text/javascript" src="../AjaxExt/ext-all-debug.js"></script>
 
<title>View <s:text name="#parameters.action" /></title>
<script type="text/javascript">
Ext.onReady(function(){
       var tabs = new Ext.TabPanel({
        renderTo: "tab1",
          width:800,
           activeTab: 0,
        deferredRender: false,  
           height:400,
           bufferResize:true,
           monitorResize:true,
           bodyStyle:'background-color:#3CA9C4;padding-top:5px;padding-left:1px;',
           enableTabScroll:true
       });
       var tabcontent;
       <s:if test="allModules.size > 0">
       <s:iterator value="allModules" id="obj">
        <s:if test="#obj.components.size > 0">
          var subTabs = new Ext.TabPanel({
                 width:598,
                 activeTab: 0,
                 deferredRender: false,
                 height:200,
               //  title:'<s:property value="#obj.moduleName" />',
                 title:'<s:property value="#obj.i18N" />',
                 enableTabScroll:true,
                 autoScroll : true
             });
      <s:iterator value="#obj.components" id="comp">
       <s:if test="#comp.id in entryComponent">
        var functions=''+"<input type=checkbox id=entry<s:property value="#comp.id" />  onclick=\"disableAll(this,'<s:property value="#comp.id" />'); \"  checked=\"checked\" name=componentList value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.enterComponent"/> ";
       
       </s:if>
          <s:if test="#comp.id not in entryComponent">
       var functions=''+"<input type=checkbox id=entry<s:property value="#comp.id" />  onclick=\"disableAll(this,'<s:property value="#comp.id" />'); \"  name=componentList value='<s:property value="#comp.id" />'> <s:text name="Entity.Role.privilege.enterComponent"/> ";

      </s:if >
     <s:if test="#comp.id in entryAllowAll">
           
         functions=functions+"<input type=checkbox onclick=\"enableEntry(this,'<s:property value="#comp.id" />'); \" id=allow<s:property value="#comp.id" /> checked=\"checked\" name=componentAllowAll value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.allowAllFunction"/> <br><br>";

     </s:if >
     <s:if test="#comp.id not in entryAllowAll">
        functions=functions+"<input type=checkbox onclick=\"enableEntry(this,'<s:property value="#comp.id" />'); \" id=allow<s:property value="#comp.id" /> name=componentAllowAll value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.allowAllFunction"/>  <br><br>";

     </s:if >
     
     
     
     
     <s:if test="#comp.functionList.size > 0">
       <s:if test="#comp.id in entryAllowAll">
         functions=functions+"<div id=function<s:property value="#comp.id" /> style=\"visibility:hidden;\"><s:text name="Entity.Role.privilege.setFunctionPoints"/><br>";
      </s:if> 
      <s:if test="#comp.id not in entryAllowAll">
         functions=functions+"<div id=function<s:property value="#comp.id" /> style=\"visibility:visible;\"><s:text name="Entity.Role.privilege.setFunctionPoints"/><br>";
      </s:if >
      
        <s:iterator value="#comp.functionList" id="func" status="st">
           <s:if test="#func.id in roleFunctionNames">
            functions=functions+"<input type=checkbox name=functionList onclick=\"enablePrivilege(this,'<s:property value="#comp.id" />'); \"  checked=\"checked\"  value='<s:property value="#func.id" />'>"+'<s:text name="Function.%{#func.id}" />'+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         </s:if>
         <s:if test="#func.id not in roleFunctionNames">
          functions=functions+"<input type=checkbox name=functionList onclick=\"enablePrivilege(this,'<s:property value="#comp.id" />'); \"  value='<s:property value="#func.id" />'>"+'<s:text name="Function.%{#func.id}" />'+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         </s:if >
         <s:if test="#st.count%3==0">
           functions=functions+"<br>";
         </s:if >
         </s:iterator>
          functions=functions+"</div>";
     
     </s:if >
     
     subTabs.add({title:'<s:property value="#comp.i18N" />', autoScroll : true,autoShow:false,html:functions}).show();
      </s:iterator>  
         tabs.add(subTabs).show();

        </s:if>
        
        
        
        
       <s:else >
       tabs.add({title:'<s:property value="obj.i18N" />'}).show();
      
    </s:else>
    </s:iterator>
         
       </s:if>
       <s:else>
       </s:else>
     tabs.setActiveTab(0);
  },this,{delay:0.000000001});

function enableEntry(me,entrycomponent){
 var o=document.getElementById('entry'+entrycomponent);
 var oo=document.getElementById('function'+entrycomponent);
 if(me.checked){
  o.checked=true;
  if(oo!=null)oo.style.visibility='hidden';
 }else{
  if(oo!=null)oo.style.visibility='visible';
 }
 
 
}

function disableAll(me,entrycomponent){
 var o=document.getElementById('allow'+entrycomponent);
 var oo=document.getElementById('function'+entrycomponent);
 if(!(me.checked))
  o.checked=false;
  
 
}
function enablePrivilege(me,entrycomponent){
 var o=document.getElementById('entry'+entrycomponent);
 if(me.checked)o.checked=true;

}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="10">
  <s:form action="%{#parameters.action}/savePrivileges">
   <s:hidden name="id" label="ID" />
   <s:hidden name="obj.id" label="ID" />

   <div id="tab1"></div>
   
   
   <input type="submit" class="button"
    value="<s:text name='General.Button.submit'/>" />
   <input type="button" class="button"
    value="<s:text name='General.Button.return'/>"
    onClick="javascript: history.go(-1);" />
    
    
  </s:form>
  
  
 </body>
</html>
2.问题解决,但是现出现两个按钮,然后出现整个页面和两个按钮。以为是Ext的问题,因为将Ext.onReady()放到body最后面也是这个效果。后来又发现可以这样做,就完美解决了。

 

<%
    request.setAttribute("decorator", "none");
    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
%>
<
%@page language="java" contentType="text/html; charset=UTF-8"
 pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="w" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/css/ext-all.css" />
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/css/button.css" />
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/workbench.css" />
 <script type="text/javascript" src="../AjaxExt/adapter/ext/ext-base-debug.js"></script>
 <script type="text/javascript" src="../AjaxExt/ext-all-debug.js"></script>
 
<title>View <s:text name="#parameters.action" /></title>
<script type="text/javascript">
function a (){
       var tabs = new Ext.TabPanel({
        renderTo: "tab1",
          width:800,
           activeTab: 0,
        deferredRender: false,  
           height:400,
           bufferResize:true,
           monitorResize:true,
           bodyStyle:'background-color:#3CA9C4;padding-top:5px;padding-left:1px;',
           enableTabScroll:true
       });
       var tabcontent;
       <s:if test="allModules.size > 0">
       <s:iterator value="allModules" id="obj">
        <s:if test="#obj.components.size > 0">
          var subTabs = new Ext.TabPanel({
                 width:598,
                 activeTab: 0,
                 deferredRender: false,
                 height:200,
               //  title:'<s:property value="#obj.moduleName" />',
                 title:'<s:property value="#obj.i18N" />',
                 enableTabScroll:true,
                 autoScroll : true
             });
      <s:iterator value="#obj.components" id="comp">
       <s:if test="#comp.id in entryComponent">
        var functions=''+"<input type=checkbox id=entry<s:property value="#comp.id" />  onclick=\"disableAll(this,'<s:property value="#comp.id" />'); \"  checked=\"checked\" name=componentList value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.enterComponent"/> ";
       
       </s:if>
          <s:if test="#comp.id not in entryComponent">
       var functions=''+"<input type=checkbox id=entry<s:property value="#comp.id" />  onclick=\"disableAll(this,'<s:property value="#comp.id" />'); \"  name=componentList value='<s:property value="#comp.id" />'> <s:text name="Entity.Role.privilege.enterComponent"/> ";

      </s:if >
     <s:if test="#comp.id in entryAllowAll">
           
         functions=functions+"<input type=checkbox onclick=\"enableEntry(this,'<s:property value="#comp.id" />'); \" id=allow<s:property value="#comp.id" /> checked=\"checked\" name=componentAllowAll value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.allowAllFunction"/> <br><br>";

     </s:if >
     <s:if test="#comp.id not in entryAllowAll">
        functions=functions+"<input type=checkbox onclick=\"enableEntry(this,'<s:property value="#comp.id" />'); \" id=allow<s:property value="#comp.id" /> name=componentAllowAll value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.allowAllFunction"/>  <br><br>";

     </s:if >
     
     
     
     
     <s:if test="#comp.functionList.size > 0">
       <s:if test="#comp.id in entryAllowAll">
         functions=functions+"<div id=function<s:property value="#comp.id" /> style=\"visibility:visible;\"><s:text name="Entity.Role.privilege.setFunctionPoints"/><br>";
      </s:if> 
      <s:if test="#comp.id not in entryAllowAll">
         functions=functions+"<div id=function<s:property value="#comp.id" /> style=\"visibility:visible;\"><s:text name="Entity.Role.privilege.setFunctionPoints"/><br>";
      </s:if >
      
        <s:iterator value="#comp.functionList" id="func" status="st">
           <s:if test="#func.id in roleFunctionNames">
            functions=functions+"<input type=checkbox name=functionList  onclick=\"enablePrivilege(this,'<s:property value="#comp.id" />','<s:property value="#func.id" />'); \"     id=allow<s:property value="#comp.id" /><s:property value="#func.id" />  checked=\"checked\"  value='<s:property value="#func.id" />'>"+'<s:text name="Function.%{#func.id}" />'+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         </s:if>
         <s:if test="#func.id not in roleFunctionNames">
          functions=functions+"<input type=checkbox name=functionList  onclick=\"enablePrivilege(this,'<s:property value="#comp.id" />','<s:property value="#func.id" />'); \"     id=allow<s:property value="#comp.id" /><s:property value="#func.id" />  value='<s:property value="#func.id" />'>"+'<s:text name="Function.%{#func.id}" />'+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         </s:if >
         <s:if test="#st.count%1==0">
           functions=functions+"<br>";
         </s:if >
         </s:iterator>
          functions=functions+"</div>";
     
     </s:if >
     
     subTabs.add({title:'<s:property value="#comp.i18N" />', autoScroll : true,autoShow:false,html:functions}).show();
      </s:iterator>  
         tabs.add(subTabs).show();

        </s:if>
        
        
        
        
       <s:else >
       tabs.add({title:'<s:property value="obj.i18N" />'}).show();
      
    </s:else>
    </s:iterator>
         
       </s:if>
       <s:else>
       </s:else>
     tabs.setActiveTab(0);
  };

function enableEntry(me,entrycomponent){

 var oo=document.getElementById('function'+entrycomponent);
 var ooo=oo.getElementsByTagName('INPUT');
 
 
 if(me.checked){
  if(oo!=null){
  oo.style.visibility='visible';
  }
  if(ooo!=null){
    for(i=0;i<ooo.length;i++){
       if(!ooo[i].checked)
      ooo[i].checked = true;
    }
  
  }
  
 }else{
  if(oo!=null)oo.style.visibility='visible';
  if(ooo!=null){
    for(i=0;i<ooo.length;i++){
       if(ooo[i].checked)
      ooo[i].checked = false;
    }
  
  }
 }
 
 
}

function disableAll(me,entrycomponent){
 var o=document.getElementById('allow'+entrycomponent);
 var oo=document.getElementById('function'+entrycomponent);
 if(!(me.checked))
  o.checked=false;
  
 
}
function enablePrivilege(me,entrycomponent,func){
 var o=document.getElementById('allow'+entrycomponent);
 var oo = document.getElementById('allow'+entrycomponent+func);
 var ooo=document.getElementById('function'+entrycomponent).getElementsByTagName('INPUT');
 
 if(me.checked){
  if(oo!=null){
    if(!oo.checked){
     o.checked = false;
    
    }
    if(ooo!=null){
       var count = 0;
       for(i=0;i<ooo.length;i++){
         if(ooo[i].checked)
          count++;
        
        
          if(!ooo[i].checked)
         o.checked = false;
        if(count == ooo.length)
          o.checked = true; 
      }
  
    }
    
  }
  
 }else{
  if(oo!=null){
    if(!oo.checked){
     o.checked = false;
    
    }
  }
 
 
 }

}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="10">
  <s:form action="%{#parameters.action}/savePrivileges">
   <s:hidden name="id" label="ID" />
   <s:hidden name="obj.id" label="ID" />

   <div id="tab1"></div>
   
   
   <input type="submit" class="button"
    value="<s:text name='General.Button.submit'/>" />
   <input type="button" class="button"
    value="<s:text name='General.Button.return'/>"
    onClick="javascript: history.go(-1);" />
    
    
  </s:form>
 <script type="text/javascript">
    Ext.onReady(a);
  
 </script> 
 </body>
</html>

 

3.后来发现上面的不够标准,改用window.onload()解决如下

<%
    request.setAttribute("decorator", "none");
    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
%>
<
%@page language="java" contentType="text/html; charset=UTF-8"
 pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="w" tagdir="/WEB-INF/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/css/ext-all.css" />
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/css/button.css" />
 <link rel="stylesheet" type="text/css"
  href="../AjaxExt/resources/workbench.css" />
 <script type="text/javascript" src="../AjaxExt/adapter/ext/ext-base-debug.js"></script>
 <script type="text/javascript" src="../AjaxExt/ext-all-debug.js"></script>
 
<title>View <s:text name="#parameters.action" /></title>
<script type="text/javascript">
window.onload = a;
function a (){
       var tabs = new Ext.TabPanel({
        renderTo: "tab1",
          width:800,
           activeTab: 0,
        deferredRender: false,  
           height:400,
           bufferResize:true,
           monitorResize:true,
           bodyStyle:'background-color:#3CA9C4;padding-top:5px;padding-left:1px;',
           enableTabScroll:true
       });
       var tabcontent;
       <s:if test="allModules.size > 0">
       <s:iterator value="allModules" id="obj">
        <s:if test="#obj.components.size > 0">
          var subTabs = new Ext.TabPanel({
                 width:598,
                 activeTab: 0,
                 deferredRender: false,
                 height:200,
               //  title:'<s:property value="#obj.moduleName" />',
                 title:'<s:property value="#obj.i18N" />',
                 enableTabScroll:true,
                 autoScroll : true
             });
      <s:iterator value="#obj.components" id="comp">
       <s:if test="#comp.id in entryComponent">
        var functions=''+"<input type=checkbox id=entry<s:property value="#comp.id" />  onclick=\"disableAll(this,'<s:property value="#comp.id" />'); \"  checked=\"checked\" name=componentList value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.enterComponent"/> ";
       
       </s:if>
          <s:if test="#comp.id not in entryComponent">
       var functions=''+"<input type=checkbox id=entry<s:property value="#comp.id" />  onclick=\"disableAll(this,'<s:property value="#comp.id" />'); \"  name=componentList value='<s:property value="#comp.id" />'> <s:text name="Entity.Role.privilege.enterComponent"/> ";

      </s:if >
     <s:if test="#comp.id in entryAllowAll">
           
         functions=functions+"<input type=checkbox onclick=\"enableEntry(this,'<s:property value="#comp.id" />'); \" id=allow<s:property value="#comp.id" /> checked=\"checked\" name=componentAllowAll value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.allowAllFunction"/> <br><br>";

     </s:if >
     <s:if test="#comp.id not in entryAllowAll">
        functions=functions+"<input type=checkbox onclick=\"enableEntry(this,'<s:property value="#comp.id" />'); \" id=allow<s:property value="#comp.id" /> name=componentAllowAll value='<s:property value="#comp.id" />'><s:text name="Entity.Role.privilege.allowAllFunction"/>  <br><br>";

     </s:if >
     
     
     
     
     <s:if test="#comp.functionList.size > 0">
       <s:if test="#comp.id in entryAllowAll">
         functions=functions+"<div id=function<s:property value="#comp.id" /> style=\"visibility:visible;\"><s:text name="Entity.Role.privilege.setFunctionPoints"/><br>";
      </s:if> 
      <s:if test="#comp.id not in entryAllowAll">
         functions=functions+"<div id=function<s:property value="#comp.id" /> style=\"visibility:visible;\"><s:text name="Entity.Role.privilege.setFunctionPoints"/><br>";
      </s:if >
      
        <s:iterator value="#comp.functionList" id="func" status="st">
           <s:if test="#func.id in roleFunctionNames">
            functions=functions+"<input type=checkbox name=functionList  onclick=\"enablePrivilege(this,'<s:property value="#comp.id" />','<s:property value="#func.id" />'); \"     id=allow<s:property value="#comp.id" /><s:property value="#func.id" />  checked=\"checked\"  value='<s:property value="#func.id" />'>"+'<s:text name="Function.%{#func.id}" />'+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         </s:if>
         <s:if test="#func.id not in roleFunctionNames">
          functions=functions+"<input type=checkbox name=functionList  onclick=\"enablePrivilege(this,'<s:property value="#comp.id" />','<s:property value="#func.id" />'); \"     id=allow<s:property value="#comp.id" /><s:property value="#func.id" />  value='<s:property value="#func.id" />'>"+'<s:text name="Function.%{#func.id}" />'+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
         </s:if >
         <s:if test="#st.count%1==0">
           functions=functions+"<br>";
         </s:if >
         </s:iterator>
          functions=functions+"</div>";
     
     </s:if >
     
     subTabs.add({title:'<s:property value="#comp.i18N" />', autoScroll : true,autoShow:false,html:functions}).show();
      </s:iterator>  
         tabs.add(subTabs).show();

        </s:if>
        
        
        
        
       <s:else >
       tabs.add({title:'<s:property value="obj.i18N" />'}).show();
      
    </s:else>
    </s:iterator>
         
       </s:if>
       <s:else>
       </s:else>
     tabs.setActiveTab(0);
  };

function enableEntry(me,entrycomponent){

 var oo=document.getElementById('function'+entrycomponent);
 var ooo=oo.getElementsByTagName('INPUT');
 
 
 if(me.checked){
  if(oo!=null){
  oo.style.visibility='visible';
  }
  if(ooo!=null){
    for(i=0;i<ooo.length;i++){
       if(!ooo[i].checked)
      ooo[i].checked = true;
    }
  
  }
  
 }else{
  if(oo!=null)oo.style.visibility='visible';
  if(ooo!=null){
    for(i=0;i<ooo.length;i++){
       if(ooo[i].checked)
      ooo[i].checked = false;
    }
  
  }
 }
 
 
}

function disableAll(me,entrycomponent){
 var o=document.getElementById('allow'+entrycomponent);
 var oo=document.getElementById('function'+entrycomponent);
 if(!(me.checked))
  o.checked=false;
  
 
}
function enablePrivilege(me,entrycomponent,func){
 var o=document.getElementById('allow'+entrycomponent);
 var oo = document.getElementById('allow'+entrycomponent+func);
 var ooo=document.getElementById('function'+entrycomponent).getElementsByTagName('INPUT');
 
 if(me.checked){
  if(oo!=null){
    if(!oo.checked){
     o.checked = false;
    
    }
    if(ooo!=null){
       var count = 0;
       for(i=0;i<ooo.length;i++){
         if(ooo[i].checked)
          count++;
        
        
          if(!ooo[i].checked)
         o.checked = false;
        if(count == ooo.length)
          o.checked = true; 
      }
  
    }
    
  }
  
 }else{
  if(oo!=null){
    if(!oo.checked){
     o.checked = false;
    
    }
  }
 
 
 }

}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="10">
  <s:form action="%{#parameters.action}/savePrivileges">
   <s:hidden name="id" label="ID" />
   <s:hidden name="obj.id" label="ID" />

   <div id="tab1"></div>
   
   
   <input type="submit" class="button"
    value="<s:text name='General.Button.submit'/>" />
   <input type="button" class="button"
    value="<s:text name='General.Button.return'/>"
    onClick="javascript: history.go(-1);" />
    
    
  </s:form>
 
 </body>
</html>


 

0
0
分享到:
评论

相关推荐

    Ext介绍以及_ext页面布局

    在创建ExtJS应用时,一个常见的入门示例是使用`Ext.onReady`函数来确保DOM加载完成后执行代码。例如,弹出一个消息框: ```javascript Ext.onReady(function() { Ext.MessageBox.alert("hello", "wayfoon"); }); `...

    Ext4 动态加载js例子

    在你的应用中,通常会在 `Ext.application` 或 `Ext.onReady` 中设置 `Ext.Loader` 的配置项,例如设置路径映射、启用动态加载等: ```javascript Ext.application({ name: 'MyApp', requires: ['Ext.Loader'], ...

    Ext框架简介-Ext框架简介

    ExtJS 由一系列的类库组成,一旦页面成功加载了 ExtJS 库后,我们就可以在页面中调用 ExtJS 的类及控件来实现需要的功能。ExtJS 的类库由以下几部分组成:底层 API(core)、控件(widgets)和实用工具(Utils)。...

    ext入门必学

    这是Ext框架提供的关键函数,用于确保DOM加载完成再执行后续代码,避免因DOM未加载完毕而导致的元素获取失败问题。 **知识点10:Ext.get()与事件绑定** `Ext.get()`方法用于根据ID选择页面元素,`.on()`则用于绑定...

    Ext教程ext2-Ext简易教程

    例如,Ext的`Ext.onReady`函数用于确保DOM加载完成后再执行代码,这是初始化Ext组件的常见方法。以下是一个简单的例子,展示如何使用MessageBox组件弹出一个警告对话框: ```html Ext.onReady(function() { Ext....

    ext实例 ext操作步骤

    3. **启动EXT**:使用`Ext.onReady`函数在DOM加载完成后执行EXT的初始化代码,例如弹出一个消息框。 ```javascript Ext.onReady(function() { Ext.MessageBox.alert("你好", "wayfoon"); }); ``` 4. **创建布局...

    简单介绍Ext 2.0

    `Ext.onReady()`是一个非常重要的函数,用于确保文档对象模型(DOM)完全加载完毕后再执行某些操作。这可以避免由于DOM元素尚未加载而导致的引用错误。 ```javascript Ext.onReady(function(){ alert(...

    ext使用--Panel和iframe联合使用时页面高度的解决方法

    当Panel包含一个IFrame时,可能会遇到页面高度调整的问题,特别是在动态加载内容或者IFrame内页面高度不固定时。本文将深入探讨如何在使用ExtJS时解决Panel与IFrame结合时页面高度自动适应的问题。 首先,我们需要...

    Ext4.0使用指南

    - **Ext.onReady**:此方法在DOM加载完成后自动调用,确保所有元素都可供脚本引用。你可以尝试在此方法中添加代码,如: ```javascript Ext.onReady(function() { alert('hello world!'); }); ``` - **Ext....

    Ext教程_javakc

    例如,以下代码展示了如何在页面加载完成后弹出一个消息框: ```html &lt;link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css"/&gt; &lt;script type="text/javascript" src="extjs/adapter/ext/...

    ext中文入门手册

    `Ext.onReady`会在DOM加载完成后执行,确保所有元素都可以被脚本引用。`Ext.application`用于启动EXTJS应用程序,它是EXTJS 4中的核心入口点。你可以尝试在`Ext.onReady`函数中添加代码,如弹出对话框,以验证其工作...

    ext js学习文档

    4. **初始化脚本**:在页面底部或 `&lt;/body&gt;` 前添加初始化脚本,确保页面加载完毕后再执行 JavaScript 代码。使用 `Ext.onReady()` 函数可以达到此目的,示例代码如下: ```javascript Ext.onReady(function() ...

    ext培训第二讲.doc

    - **功能**:`Ext.onReady`方法用于确保某个函数在文档初始化完成后执行(即在页面的所有元素都已加载完毕,但图片等非关键资源可能尚未加载完成时)。这是一种非常常见的DOM加载完成后的事件处理机制。 - **语法**...

    doc格式 ext EXT 中文手册

    - **Ext.onReady**: 此方法用于确保DOM完全加载完成后再执行指定的JavaScript代码,确保页面内的所有元素可以被脚本引用。 - **示例代码**: ```javascript Ext.onReady(function() { alert("Congratulations! You...

    Jquery+ext

    // 在EXT页面加载完成后执行的代码 }); }); ``` 总结,jQuery和EXT的结合使得Web开发更高效,它们互补了JavaScript的不足,提供了丰富的UI组件和强大的交互体验。学习和掌握这两个库,对于提升Web应用的用户体验...

    兼容IE/Firefox/Opera/Safari的检测页面装载完毕的脚本Ext.onReady的实现

    它模仿了Ext.js库中的`Ext.onReady`功能,确保在页面DOM完全加载后执行指定的函数,即`GOOGLEResize`。 1. **IE的检测与处理**: 在IE浏览器中,代码通过检查`navigator.userAgent`来识别版本,并利用`...

    grid js 例子一个 ext 的

    - **Ext.onReady()**:确保在 DOM 加载完成后才执行函数体内的代码。 - **Ext.BLANK_IMAGE_URL**:设置 Ext JS 的默认空白图片路径。 - **Ext.QuickTips.init()**:初始化快速提示功能。 - **CheckboxSelectionModel...

Global site tag (gtag.js) - Google Analytics