Changeset 852

Show
Ignore:
Timestamp:
08/07/07 00:14:50 (6 years ago)
Author:
lmajano
Message:

Updated thanks to Aaron Roberson.

Location:
coldbox/trunk/install/illidium_templates/coldbox
Files:
11 added
3 modified

Legend:

Unmodified
Added
Removed
  • coldbox/trunk/install/illidium_templates/coldbox/handler.cfm

    r809 r852  
    1111        <%/cffunction%> 
    1212 
    13         <%cffunction name="dspList" access="public" returntype="void" output="false"%> 
    14                 <%cfargument name="event" type="coldbox.system.beans.requestContext" required="yes"%> 
    15                 <%cfscript%> 
    16                 //Get references 
    17                 var rc = event.getCollection(); 
    18                 var oService = getPlugin("ioc").getBean("#root.bean.xmlAttributes.name#Service"); 
    19                  
    20                 //set The exit handlers 
    21                 rc.xehEditor = "#root.bean.xmlAttributes.name#.dspEditor"; 
    22                 rc.xehDelete = "#root.bean.xmlAttributes.name#.doDelete"; 
    23                  
    24                 //Get the listing 
    25                 rc.q#root.bean.xmlAttributes.name# = oService.get#root.bean.xmlAttributes.name#s() ; 
    26                  
    27                 //Sorting Logic. 
    28                 if ( event.getValue("sortOrder","") neq ""){ 
    29                         if (rc.sortOrder eq "asc") 
    30                                 rc.sortOrder = "desc"; 
    31                         else 
    32                                 rc.sortOrder = "asc"; 
    33                 } 
    34                 else{ 
    35                         rc.sortOrder = "asc"; 
    36                 } 
    37                 if ( event.getValue("sortBy","") neq "" ){ 
    38                         //Sort via Query Helper. 
    39                         rc.q#root.bean.xmlAttributes.name# = getPlugin("queryHelper").sortQuery(rc.q#root.bean.xmlAttributes.name#,rc.sortBy, rc.sortOrder); 
    40                 } 
    41                 else{ 
    42                         rc.sortBy = ""; 
    43                 } 
    44                  
    45                 //Set the view to render 
    46                 event.setView("#root.bean.xmlAttributes.name#List"); 
    47                 <%/cfscript%> 
    48         <%/cffunction%> 
    49          
    50         <%cffunction name="dspEditor" access="public" returntype="void" output="false"%> 
    51                 <%cfargument name="event" type="coldbox.system.beans.requestContext" required="yes"%> 
    52                 <%cfscript%> 
    53                 //References 
    54                 var rc = event.getCollection(); 
    55                 var oService = getPlugin("ioc").getBean("#root.bean.xmlAttributes.name#Service"); 
    56                  
    57                 //set the exit handlers 
    58                 rc.xehSave = "#root.bean.xmlAttributes.name#.doSave"; 
    59                 rc.xehList = "#root.bean.xmlAttributes.name#.dspList"; 
    60                  
    61                 //Get #root.bean.xmlAttributes.name# bean with/without ID. 
    62                 rc.o#root.bean.xmlAttributes.name#Bean = oService.get#root.bean.xmlAttributes.name#(event.getValue("#primaryKey#","0")); 
    63                  
    64                 //Set view to render 
    65                 event.setView("#root.bean.xmlAttributes.name#Editor"); 
    66                 <%/cfscript%>            
    67         <%/cffunction%> 
    68          
    69         <%cffunction name="doSave" access="public" returntype="void" output="false"%> 
    70                 <%cfargument name="event" type="coldbox.system.beans.requestContext" required="yes"%> 
    71                 <%cfscript%> 
    72                 //References 
    73                 var rc = event.getCollection(); 
    74                 var oService = getPlugin("ioc").getBean("#root.bean.xmlAttributes.name#Service"); 
    75                 var o#root.bean.xmlAttributes.name#Bean = ""; 
    76                  
    77                 //get a new #root.bean.xmlAttributes.name# bean 
    78                 o#root.bean.xmlAttributes.name#Bean = oService.get#root.bean.xmlAttributes.name#(0); 
    79                  
    80                 //Populate the bean 
    81                 getPlugin("beanFactory").populateBean(o#root.bean.xmlAttributes.name#Bean); 
    82                                  
    83                 //Send to service for saving 
    84                 oService.save#root.bean.xmlAttributes.name#(o#root.bean.xmlAttributes.name#Bean); 
    85                  
    86                 //Set redirect 
    87                 setNextEvent("#root.bean.xmlAttributes.name#.dspList"); 
    88                 <%/cfscript%>            
    89         <%/cffunction%> 
    90          
    91         <%cffunction name="doDelete" access="public" returntype="void" output="false"%> 
    92                 <%cfargument name="event" type="coldbox.system.beans.requestContext" required="yes"%> 
    93                 <%cfscript%> 
    94                 //References 
    95                 var rc = event.getCollection(); 
    96                 var oService = getPlugin("ioc").getBean("#root.bean.xmlAttributes.name#Service"); 
    97                  
    98                 //Remove via the incoming id 
    99                 oService.delete#root.bean.xmlAttributes.name#(rc.#primaryKey#); 
    100                  
    101                 //Redirect with message box 
    102                 getPlugin("messagebox").setMessage("info","The record was sucessfully deleted"); 
    103                 setNextEvent("#root.bean.xmlAttributes.name#.dspList"); 
    104                 <%/cfscript%>            
    105         <%/cffunction%>  
     13        <!-- custom code --> 
    10614         
    10715<%/cfcomponent%> 
  • coldbox/trunk/install/illidium_templates/coldbox/unittest.cfm

    r809 r852  
    1919        <%/cffunction%> 
    2020         
    21         <%cffunction name="testdspHome" access="public" returntype="void" output="false"%> 
    22                 <%cfscript%> 
    23                 var event = ""; 
    24                  
    25                 //Place any variables on the form or URL scope to test the handler. 
    26                 //FORM.name = "luis" 
    27                 event = execute("general.dspHome"); 
    28                          
    29                 //Do your asserts below 
    30                 assertEqualsString("Welcome to ColdBox!", event.getValue("welcomeMessage",""), "Failed to assert welcome message"); 
    31                          
    32                 <%/cfscript%> 
    33         <%/cffunction%> 
    34                  
    35         <%cffunction name="testdspList" access="public" returntype="void" output="false"%> 
    36                 <%cfscript%> 
    37                 //Get references 
    38                 var event = ""; 
    39                  
    40                 //Place any variables on the form or URL scope to test the handler. 
    41                 //FORM.name = "luis" 
    42                 event = execute("#root.bean.xmlAttributes.name#.dspList"); 
    43                          
    44                 //Do your asserts below 
    45                                  
    46                 <%/cfscript%> 
    47         <%/cffunction%> 
     21        <!-- custom code --> 
    4822         
    49         <%cffunction name="testdspEditor" access="public" returntype="void" output="false"%> 
    50                 <%cfscript%> 
    51                 //Get references 
    52                 var event = ""; 
    53                  
    54                 //Place any variables on the form or URL scope to test the handler. 
    55                 //FORM.name = "luis" 
    56                 event = execute("#root.bean.xmlAttributes.name#.dspEditor"); 
    57                          
    58                 //Do your asserts below 
    59                                  
    60                 <%/cfscript%> 
    61         <%/cffunction%> 
    62          
    63         <%cffunction name="testdoSave" access="public" returntype="void" output="false"%> 
    64                 <%cfscript%> 
    65                 //Get references 
    66                 var event = ""; 
    67                  
    68                 //Place any variables on the form or URL scope to test the handler. 
    69                 //FORM.name = "luis" 
    70                 <cfloop from="1" to="#arrayLen(root.bean.dbtable.xmlChildren)#" index="i"> 
    71                 <cfset element = root.bean.dbtable.xmlChildren[i].xmlAttributes> 
    72                 <cfif primaryKey neq element.name> 
    73                 <cfif element.type eq "numeric"> 
    74                 form.#element.name# = ''; 
    75                 <cfelseif element.type eq "Boolean"> 
    76                 form.#element.name# = true; 
    77                 <cfelseif element.type eq "Date"> 
    78                 form.#element.name# = dateformat(now(),"medium"); 
    79                 <cfelse> 
    80                 form.#element.name# = 'UNIT TEST'; 
    81                 </cfif> 
    82                 </cfif> 
    83                 </cfloop> 
    84                  
    85                 event = execute("#root.bean.xmlAttributes.name#.doSave"); 
    86                          
    87                 //Do your asserts below 
    88                                  
    89                 <%/cfscript%> 
    90         <%/cffunction%> 
    91          
    92         <%cffunction name="testdoDelete" access="public" returntype="void" output="false"%> 
    93                 <%cfscript%> 
    94                 //Get references 
    95                 var event = ""; 
    96                  
    97                 //Place any variables on the form or URL scope to test the handler. 
    98                 //FORM.name = "luis" 
    99                 form.#primaryKey# = '123'; 
    100                  
    101                 event = execute("#root.bean.xmlAttributes.name#.doDelete"); 
    102                          
    103                 //Do your asserts below 
    104                                  
    105                 <%/cfscript%> 
    106         <%/cffunction%> 
    107                          
    10823<%/cfcomponent%> 
    10924</cfoutput> 
  • coldbox/trunk/install/illidium_templates/coldbox/yac.xml

    r809 r852  
    2929                <include file="deleteBean.cfm" /> 
    3030        </service> 
     31        <handler fileNameAppend="" filetype="cfc" templateType="cfm"> 
     32                <include file="dspList.cfm" /> 
     33                <include file="dspEdit.cfm" /> 
     34                <include file="doSave.cfm" /> 
     35                <include file="doDelete.cfm" /> 
     36        </handler> 
     37        <unittest fileNameAppend="" filetype="cfc" templateType="cfm"> 
     38                <include file="testdspHome.cfm" /> 
     39                <include file="testdspList.cfm" /> 
     40                <include file="testdspEditor.cfm" /> 
     41                <include file="testdoSave.cfm" /> 
     42                <include file="testdoDelete.cfm" /> 
     43        </unittest> 
    3144        <coldspring filetype="xml"                      templateType="cfm" /> 
    32         <handler        fileNameAppend=""               filetype="cfc" templateType="cfm" /> 
    33         <unittest       fileNameAppend="test"   filetype="cfc" templateType="cfm" /> 
    3445        <list           fileNameAppend="List"   filetype="cfm" templatetype="cfm" /> 
    3546        <editor         filenameAppend="Editor" filetype="cfm" templatetype="cfm" />