FabriceB
11-09-2010, 10:45 PM
Hi!
This is as much of a discussion then question I suppose and I am also uncertain that this is the right place to ask but here goes...
I'm learning (in school) at the moment about separations of concerns and see some of the benefits so I'd like to try and see if it could pay off here as well.
I am trying to clean up the codes that were developed here which are mainly done in ASP. (At school we're learning JSP)
In JSP I noticed that most of the HTML page was free of code. There was really the minimum present (i.e.: access to information through RS)
Here is what I am wondering, is there a way to do the same with ASP?
With a page like this one:
<!--#include virtual="\common\asp\functions.asp"-->
<!--#include virtual="\common\classes\asp\connectionmanager.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Outage Tool</title>
</head>
<%
if not (HasRight("42-SMST_Report") or HasRight("42-SMST_Coordinator_Report")) then DieSecurityError
dim conn, sp, pageNameOfThisPage, phrases,rsP
dim rs, WTS_isEmpty,arrH , arrM
WTS_isEmpty = session("WTS_RSisEmpty")
if not WTS_isEmpty then
set rs = session("WTS_recordset")
end if
function IIf( expr, truepart, falsepart )
IIf = falsepart
If expr Then IIf = truepart
end function
function condIf( expr, expr2, expr3, truepart1, truepart2, truepart3 )
condIf = ""
If expr Then condIf = truepart1 end if
If expr2 then condIf = truepart2 end if
If expr3 then condIf = truepart3 end if
end function
pageNameOfThisPage = "default"
set conn = new connectionManager
sp = "SELECT phraseid, phrase FROM Tbl_Form_SMST_Phrases " _
& " WHERE (pageid IS NULL OR pageid = '" & pageNameOfThisPage & "' " _
& ") AND language = '" & Session("language") & "'"
conn.storedprocedure = sp
'response.write(sp)
conn.connect
Set phrases = Server.CreateObject("Scripting.Dictionary")
if conn.hasErrorOccured then
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
else
set rsP = conn.recordset
If rsP.EOF Then Response.Write "NO RECORDS in rsP recordset<hr>"
Do Until rsP.EOF
pid = rsP("phraseid")
ph = rsP("phrase")
'Response.Write pid & "::" & ph & "<br/>" & vbNewLine
phrases.Add LCase(pid), ph
rsP.MoveNext
Loop
set rsP = nothing
end if
'------------------------------ SystemTool_id Selection --------------------------------------------------
if not isObject(session("sysSelect")) then
sp = "SELECT SystemTool_id, SystemTool_Name FROM Tbl_Form_SMST_System_Dim WHERE (Language IS NULL) OR Language = '" & Session("language") & "'"
conn.storedprocedure = sp
conn.connect
if not conn.hasErrorOccured then
session("sysSelect") = conn.getrows
else
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
end if
end if
'------------------------ Ending SystemTool_id selection -------------------------------------------------
'------------------------ network Selection --------------------------------------------------
if not isObject(session("netSelect")) then
sp = "SELECT network_id, network_Name FROM Tbl_Form_SMST_Network_Dim"
conn.storedprocedure = sp
conn.connect
if not conn.hasErrorOccured then
session("netSelect") = conn.getrows
else
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
end if
end if
'------------------------ Ending Department selection -------------------------------------------------
'------------------------------ SystemTool_id Selection --------------------------------------------------
if not isObject(session("provSelect")) then
sp = "SELECT province_id, province FROM Tbl_Form_SMST_Provinces_Dim WHERE (Language IS NULL) OR Language = '" & Session("language") & "'"
conn.storedprocedure = sp
conn.connect
if not conn.hasErrorOccured then
session("provSelect") = conn.getrows
else
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
end if
end if
'------------------------ Ending SystemTool_id selection -------------------------------------------------
'------------------------------ Service Selection --------------------------------------------------
if not isObject(session("servSelect")) then
sp = "SELECT service_id, service_name FROM Tbl_Form_SMST_Service_Dim WHERE (Language IS NULL) OR Language = '" & Session("language") & "'"
conn.storedprocedure = sp
conn.connect
if not conn.hasErrorOccured then
session("servSelect") = conn.getrows
else
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
end if
end if
'------------------------ Ending SystemTool_id selection -------------------------------------------------
'------------------------------ Service Selection --------------------------------------------------
if not isObject(session("escSelect")) then
sp = "SELECT escalate_id, escalate_name FROM Tbl_Form_SMST_Escalate_Dim WHERE (Language IS NULL) OR Language = '" & Session("language") & "'"
conn.storedprocedure = sp
conn.connect
if not conn.hasErrorOccured then
session("escSelect") = conn.getrows
else
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
end if
end if
'------------------------ Ending SystemTool_id selection -------------------------------------------------
dim link
link = Request.ServerVariables("URL")
%>
<link rel="stylesheet" type="text/css" href="smst.css">
<style type="text/css">@import url(datepicker.css);</style>
<script language="javascript" src="/common/javascript/jquery/jquery-1.2.6.min.js"></script>
<script language="javascript" src="/common/javascript/jquery/jquery.blockUI.js"></script>
<script type="text/javascript" src="smst.js"></script>
<body >
<div id="MainPage" >
<form id="form" name="form" action="details.asp" method="get" onsubmit="return fn_validate()">
<div id="bannerDIV">
<p align="center"><img id="banner" name="banner" src="<%=phrases("bannerurl")%>" width=600 height=50 /></p>
<div id="lineList">
<ul class="left">
<li> <a href="default.asp"><%=phrases("inline1")%></a></li>
<li> <a href="itsc.asp"><%=phrases("inline2")%></a></li>
<li> <a href="noc.asp"><%=phrases("inline3")%></a></li>
<li> <a href="smst.asp"><%=phrases("inline4")%></a></li>
<li> <a href="mailto:Fido-System.ManagementandSupport@rci.rogers.com?subject=Signaler Problème"><%=phrases("inline5")%></a></li>
</ul>
</div>
</div> <!-- end of Banner Div -->
<div id="ticketEntry" dir="ltr" style="float:left;width:960px">
<div>
<table>
<tr>
<td>
<label class="inputs"><strong><%=phrases("ticket")%></strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("Ticket_Id")) ,"" , rs("Ticket_Id"))) end if %><br/>
<label class="inputs"><strong><%=phrases("master")%></strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("SMSTTicket_Id")) ,"" , rs("SMSTTicket_Id"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("system")%> </strong></label><% If WTS_isEmpty = false then response.write(IIF(isNull(rs("System_selected")) ,"" , rs("System_selected"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("network")%></strong></label><% If WTS_isEmpty = false then response.write(IIF(isNull(rs("Network_selected")) ,"" , rs("Network_selected"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("province")%></strong></label><% If WTS_isEmpty = false then response.write(IIF(isNull(rs("Province_selected")) ,"" , rs("Province_selected"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("service")%></strong></label><% If WTS_isEmpty = false then response.write(IIF(isNull(rs("Service_selected")) ,"" , rs("Service_selected"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("estarttime")%> </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("Start_Date")) , "", rs("Start_Date"))) end if%> <% response.write(" " & rs("Start_Time")) %><br/>
<label class="inputs"><strong><%=phrases("eendtime")%> </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("End_Date")) , "", rs("End_Date"))) end if%> <% response.write(" " & rs("End_Time")) %><br/>
<label class="inputs"><strong><%=phrases("etr")%> </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("etr")) , "", rs("etr") )) end if%> <br/>
<label class="inputs"><strong><%=phrases("escalate")%> </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("escalate_name")) ,"" , rs("escalate_name"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("severity")%> </strong></label><%if not WTS_isEmpty then response.write( condIf( rs("severity")=1, rs("severity")=2, rs("severity")=3, phrases("serverity1"), phrases("serverity2"), phrases("serverity3") ) ) end if %><br/>
<label class="inputs"><strong><%=phrases("example")%> </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("examples")) , "", rs("examples"))) end if%><br/>
<label class="inputs"><strong><%=phrases("status")%> </strong></label><%if not WTS_isEmpty then response.write( condIf( rs("status")=1, rs("status")=2, rs("status")=3, phrases("status1"), phrases("status2"), phrases("status3") ) ) end if %><br/>
<label class="inputs"><strong><%=phrases("detail1")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("alert_msg")) , "", rs("alert_msg"))) end if %><br/>
<label class="inputs"><strong><%=phrases("detail5")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("RootCause")) , "", rs("RootCause"))) end if %><br/>
<label class="inputs"><strong><%=phrases("input1")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("Description")) , "", rs("Description"))) end if%><br/>
<label class="inputs"><strong><%=phrases("input2")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("Positioning")) , "", rs("Positioning"))) end if%><br/>
<label class="inputs"><strong><%=phrases("input3")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("WorkAround")) , "", rs("WorkAround"))) end if%><br/>
<label class="inputs"><strong><%=phrases("input4")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("CxImpact")) , "", rs("CxImpact"))) end if%><br/>
<label class="inputs"><strong><%=phrases("input5")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("history")) , "", rs("history"))) end if%><br/>
</td>
</tr>
</table>
</div>
</div> <!-- end of ticketentry -->
<input type="hidden" id="actionState" name="actionState" <%response.write(IIF(request("actionState") <> "" , "value=" & request("actionState"),"")) %> />
</form>
</div>
</body>
</html>
<% set conn = nothing
set detailsRS = nothing %>
Is there anything that could be done?
(In this particular case, I'm really inquiring about the code in between head and body
This is as much of a discussion then question I suppose and I am also uncertain that this is the right place to ask but here goes...
I'm learning (in school) at the moment about separations of concerns and see some of the benefits so I'd like to try and see if it could pay off here as well.
I am trying to clean up the codes that were developed here which are mainly done in ASP. (At school we're learning JSP)
In JSP I noticed that most of the HTML page was free of code. There was really the minimum present (i.e.: access to information through RS)
Here is what I am wondering, is there a way to do the same with ASP?
With a page like this one:
<!--#include virtual="\common\asp\functions.asp"-->
<!--#include virtual="\common\classes\asp\connectionmanager.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Outage Tool</title>
</head>
<%
if not (HasRight("42-SMST_Report") or HasRight("42-SMST_Coordinator_Report")) then DieSecurityError
dim conn, sp, pageNameOfThisPage, phrases,rsP
dim rs, WTS_isEmpty,arrH , arrM
WTS_isEmpty = session("WTS_RSisEmpty")
if not WTS_isEmpty then
set rs = session("WTS_recordset")
end if
function IIf( expr, truepart, falsepart )
IIf = falsepart
If expr Then IIf = truepart
end function
function condIf( expr, expr2, expr3, truepart1, truepart2, truepart3 )
condIf = ""
If expr Then condIf = truepart1 end if
If expr2 then condIf = truepart2 end if
If expr3 then condIf = truepart3 end if
end function
pageNameOfThisPage = "default"
set conn = new connectionManager
sp = "SELECT phraseid, phrase FROM Tbl_Form_SMST_Phrases " _
& " WHERE (pageid IS NULL OR pageid = '" & pageNameOfThisPage & "' " _
& ") AND language = '" & Session("language") & "'"
conn.storedprocedure = sp
'response.write(sp)
conn.connect
Set phrases = Server.CreateObject("Scripting.Dictionary")
if conn.hasErrorOccured then
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
else
set rsP = conn.recordset
If rsP.EOF Then Response.Write "NO RECORDS in rsP recordset<hr>"
Do Until rsP.EOF
pid = rsP("phraseid")
ph = rsP("phrase")
'Response.Write pid & "::" & ph & "<br/>" & vbNewLine
phrases.Add LCase(pid), ph
rsP.MoveNext
Loop
set rsP = nothing
end if
'------------------------------ SystemTool_id Selection --------------------------------------------------
if not isObject(session("sysSelect")) then
sp = "SELECT SystemTool_id, SystemTool_Name FROM Tbl_Form_SMST_System_Dim WHERE (Language IS NULL) OR Language = '" & Session("language") & "'"
conn.storedprocedure = sp
conn.connect
if not conn.hasErrorOccured then
session("sysSelect") = conn.getrows
else
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
end if
end if
'------------------------ Ending SystemTool_id selection -------------------------------------------------
'------------------------ network Selection --------------------------------------------------
if not isObject(session("netSelect")) then
sp = "SELECT network_id, network_Name FROM Tbl_Form_SMST_Network_Dim"
conn.storedprocedure = sp
conn.connect
if not conn.hasErrorOccured then
session("netSelect") = conn.getrows
else
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
end if
end if
'------------------------ Ending Department selection -------------------------------------------------
'------------------------------ SystemTool_id Selection --------------------------------------------------
if not isObject(session("provSelect")) then
sp = "SELECT province_id, province FROM Tbl_Form_SMST_Provinces_Dim WHERE (Language IS NULL) OR Language = '" & Session("language") & "'"
conn.storedprocedure = sp
conn.connect
if not conn.hasErrorOccured then
session("provSelect") = conn.getrows
else
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
end if
end if
'------------------------ Ending SystemTool_id selection -------------------------------------------------
'------------------------------ Service Selection --------------------------------------------------
if not isObject(session("servSelect")) then
sp = "SELECT service_id, service_name FROM Tbl_Form_SMST_Service_Dim WHERE (Language IS NULL) OR Language = '" & Session("language") & "'"
conn.storedprocedure = sp
conn.connect
if not conn.hasErrorOccured then
session("servSelect") = conn.getrows
else
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
end if
end if
'------------------------ Ending SystemTool_id selection -------------------------------------------------
'------------------------------ Service Selection --------------------------------------------------
if not isObject(session("escSelect")) then
sp = "SELECT escalate_id, escalate_name FROM Tbl_Form_SMST_Escalate_Dim WHERE (Language IS NULL) OR Language = '" & Session("language") & "'"
conn.storedprocedure = sp
conn.connect
if not conn.hasErrorOccured then
session("escSelect") = conn.getrows
else
response.write("<div class='error'>")
response.write(conn.messageString)
response.write("</div>")
end if
end if
'------------------------ Ending SystemTool_id selection -------------------------------------------------
dim link
link = Request.ServerVariables("URL")
%>
<link rel="stylesheet" type="text/css" href="smst.css">
<style type="text/css">@import url(datepicker.css);</style>
<script language="javascript" src="/common/javascript/jquery/jquery-1.2.6.min.js"></script>
<script language="javascript" src="/common/javascript/jquery/jquery.blockUI.js"></script>
<script type="text/javascript" src="smst.js"></script>
<body >
<div id="MainPage" >
<form id="form" name="form" action="details.asp" method="get" onsubmit="return fn_validate()">
<div id="bannerDIV">
<p align="center"><img id="banner" name="banner" src="<%=phrases("bannerurl")%>" width=600 height=50 /></p>
<div id="lineList">
<ul class="left">
<li> <a href="default.asp"><%=phrases("inline1")%></a></li>
<li> <a href="itsc.asp"><%=phrases("inline2")%></a></li>
<li> <a href="noc.asp"><%=phrases("inline3")%></a></li>
<li> <a href="smst.asp"><%=phrases("inline4")%></a></li>
<li> <a href="mailto:Fido-System.ManagementandSupport@rci.rogers.com?subject=Signaler Problème"><%=phrases("inline5")%></a></li>
</ul>
</div>
</div> <!-- end of Banner Div -->
<div id="ticketEntry" dir="ltr" style="float:left;width:960px">
<div>
<table>
<tr>
<td>
<label class="inputs"><strong><%=phrases("ticket")%></strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("Ticket_Id")) ,"" , rs("Ticket_Id"))) end if %><br/>
<label class="inputs"><strong><%=phrases("master")%></strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("SMSTTicket_Id")) ,"" , rs("SMSTTicket_Id"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("system")%> </strong></label><% If WTS_isEmpty = false then response.write(IIF(isNull(rs("System_selected")) ,"" , rs("System_selected"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("network")%></strong></label><% If WTS_isEmpty = false then response.write(IIF(isNull(rs("Network_selected")) ,"" , rs("Network_selected"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("province")%></strong></label><% If WTS_isEmpty = false then response.write(IIF(isNull(rs("Province_selected")) ,"" , rs("Province_selected"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("service")%></strong></label><% If WTS_isEmpty = false then response.write(IIF(isNull(rs("Service_selected")) ,"" , rs("Service_selected"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("estarttime")%> </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("Start_Date")) , "", rs("Start_Date"))) end if%> <% response.write(" " & rs("Start_Time")) %><br/>
<label class="inputs"><strong><%=phrases("eendtime")%> </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("End_Date")) , "", rs("End_Date"))) end if%> <% response.write(" " & rs("End_Time")) %><br/>
<label class="inputs"><strong><%=phrases("etr")%> </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("etr")) , "", rs("etr") )) end if%> <br/>
<label class="inputs"><strong><%=phrases("escalate")%> </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("escalate_name")) ,"" , rs("escalate_name"))) end if %> <br/>
<label class="inputs"><strong><%=phrases("severity")%> </strong></label><%if not WTS_isEmpty then response.write( condIf( rs("severity")=1, rs("severity")=2, rs("severity")=3, phrases("serverity1"), phrases("serverity2"), phrases("serverity3") ) ) end if %><br/>
<label class="inputs"><strong><%=phrases("example")%> </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("examples")) , "", rs("examples"))) end if%><br/>
<label class="inputs"><strong><%=phrases("status")%> </strong></label><%if not WTS_isEmpty then response.write( condIf( rs("status")=1, rs("status")=2, rs("status")=3, phrases("status1"), phrases("status2"), phrases("status3") ) ) end if %><br/>
<label class="inputs"><strong><%=phrases("detail1")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("alert_msg")) , "", rs("alert_msg"))) end if %><br/>
<label class="inputs"><strong><%=phrases("detail5")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("RootCause")) , "", rs("RootCause"))) end if %><br/>
<label class="inputs"><strong><%=phrases("input1")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("Description")) , "", rs("Description"))) end if%><br/>
<label class="inputs"><strong><%=phrases("input2")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("Positioning")) , "", rs("Positioning"))) end if%><br/>
<label class="inputs"><strong><%=phrases("input3")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("WorkAround")) , "", rs("WorkAround"))) end if%><br/>
<label class="inputs"><strong><%=phrases("input4")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("CxImpact")) , "", rs("CxImpact"))) end if%><br/>
<label class="inputs"><strong><%=phrases("input5")%>: </strong></label><%If WTS_isEmpty = false then response.write(IIF(isNull(rs("history")) , "", rs("history"))) end if%><br/>
</td>
</tr>
</table>
</div>
</div> <!-- end of ticketentry -->
<input type="hidden" id="actionState" name="actionState" <%response.write(IIF(request("actionState") <> "" , "value=" & request("actionState"),"")) %> />
</form>
</div>
</body>
</html>
<% set conn = nothing
set detailsRS = nothing %>
Is there anything that could be done?
(In this particular case, I'm really inquiring about the code in between head and body