ASP Framework Example
By default the file “web.config” trys to catch all possible URI’s. I felt the best way to lay it out is that each “controller” is a single file. So the “route” just calls the controller. No extra data can be set. This is probably the biggest down fall, which I may fix if there is enough demand on the project.
To get started browse to the file “/application/config/config.asp” and open it up and configure everything you may want to play with. There are only a few options since you declare most everything yourself.
Next, make a controller or edit the default controller. This is simply a file inside the “application/controllers” folder. At the top use a server side include to pull in the “core” file inside the “application/system” directory.
After that put whatever HTML and ASP you want. You have access to a constant “frameworkVersion”. Along with your config variables, you also have access to 3 more “view”, “model”, and “helper”. Each of these three variables all have one method used to pull in other files “retrieve” which takes 2 parameters: “fileName” which is a string of the file name you want, and “willReturn” a boolean that, if true, will return the data for you to execute yoruself, however, if false, will execute it for you. Let’s dive into some code!
Currently, the eventQue requies a class of events and requires two methods “getHooks” which returns an array of which hooks to call him out on, and a “trigger” function which always gets called on an event and passed a single variable with which hook was called.
' Event Que Requires
Execute helper.retrieve("eventQue", true)
' Event Que Variables
Dim myQue, variablesWork
Set myQue = new eventQue
variablesWork = "<strong>Variables:</strong> Working"
' Event Que Hook Class
Class defaultControllerHooks
Public Function getHooks()
getHooks = Array("404", "header")
End Function
Public Function trigger(name)
If name = "404" THen
Response.write("<strong>Hooks:</strong> Working")
ElseIf name = "header" Then
triggerHeader()
End If
End Function
Public Function triggerHeader
%>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#container').append($('<div class="item"><strong>JS + Hooks:</strong> Working</div>'));
});
</script>
<%
End Function
End Class
' Event Que Hooks
Dim myHooks
Set myHooks = new defaultControllerHooks
myQue.addHooks(myHooks)
Next, the database is a bit odd. Most model functions ask for a record set which is passed by reference, you pass it in and then you are free to use it as you wish. I feel this area could use some more work.
' Database Setup
Dim recordSet1, tableModelVar
Execute model.retrieve("tables", true)
Set recordSet1 = Server.CreateObject("ADODB.Recordset")
Set tableModelVar = new tableModel
' Database Query
tableModelVar.getTables(recordSet1)
Do While Not recordSet1.EOF
Response.write("Name: " & recordSet1("name") & vbCrLf) ' Name: userMaster
recordSet1.MoveNext
Loop
recordSet1.Close
Lastly, views are simple as well. All variables you have open right now is accessible in the view.
' View
Execute view.retrieve("404", true)


Discussion
No responses to "ASP Framework Example"
There are no comments yet, add one below.
Leave a Comment