Link to home
Start Free TrialLog in
Avatar of s_hausen
s_hausen

asked on

Coldfusion Menu and Session

Hi,
I have a situation here, I've designed a menu system. all 7 files codes are attached with file names(only add section are working just for sample). Load the samplemain.cfm file and click on administration, it will show the right menu with right heading(which is add menu and heading with administration).

but when you right click on Return to main menu and select schedules or therapy and open it in a new tab, it also shows the therapy heading with therapy menu but when we refresh the administration page its menu and heading changes to therapy heading and therapy menu.

I am confused what i am doing wrong. User can open admin, therapy and schedules in different tabs and work on it with the specific heading and menu. Right now, only ADD FILES are working, just for sample and also the users are restricted to use only FIREFOX. Any help, comments and feedback would be deeply appreciated. Thanks in advance..
samplemain.cfm
<!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>Untitled Document</title>
</head>

<body>

<table width="30%" border="1" cellspacing="2" cellpadding="2" align="center">
  <tr>
    <td><a href="#" onclick="ColdFusion.Window.show('administration_window')">ADMINISTRATION</a></td>
  </tr>
  <tr>
    <td><a href="#" onclick="ColdFusion.Window.show('schedules_window')">SCHEDULES</a></td>
  </tr>
  <tr>
    <td><a href="#" onclick="ColdFusion.Window.show('therapy_window')">THERAPY</a></td>
  </tr>
</table>


<cfwindow name="administration_window" title="Administration" width="200" height="120" modal="true" resizable="false" closable="true" draggable="false" center="true" 
headerStyle="font-family: verdana; background-color:##CC0033; color:white" x="100" y="100" >

<a href="javascript:window.open('redirectopages.cfm?ploc=adminadd01.cfm&svalue=administration', '_self'); ColdFusion.Window.hide('administration_window');"> Add Admin</a><br />
<a href="javascript:window.open('redirectopages.cfm?ploc=adminedit.cfm&svalue=administration', '_self'); ColdFusion.Window.hide('administration_window');"> Edit Admin</a><br />
<a href="javascript:window.open('redirectopages.cfm?ploc=admindelete.cfm&svalue=administration', '_self'); ColdFusion.Window.hide('administration_window');"> Delete Admin</a>

</cfwindow>

<cfwindow name="schedules_window" title="Schedules" width="200" height="120" modal="true" resizable="false" closable="true" draggable="false" center="true" 
headerStyle="font-family: verdana; background-color:##CC0033; color:white" x="100" y="100" >

<a href="javascript:window.open('redirectopages.cfm?ploc=scheduleadd01.cfm&svalue=schedules', '_self'); ColdFusion.Window.hide('schedules_window');"> Add Schedule</a><br />
<a href="javascript:window.open('redirectopages.cfm?ploc=scheduleedit.cfm&svalue=schedules', '_self'); ColdFusion.Window.hide('schedules_window');"> Edit Schedule</a><br />
<a href="javascript:window.open('redirectopages.cfm?ploc=scheduledelete.cfm&svalue=schedules', '_self'); ColdFusion.Window.hide('schedules_window');"> Delete Schedule</a>

</cfwindow>

<cfwindow name="therapy_window" title="therapy" width="200" height="120" modal="true" resizable="false" closable="true" draggable="false" center="true" 
headerStyle="font-family: verdana; background-color:##CC0033; color:white" x="100" y="100" >

<a href="javascript:window.open('redirectopages.cfm?ploc=therapyadd01.cfm&svalue=therapy', '_self'); ColdFusion.Window.hide('therapy_window');"> Add Therapy</a><br />
<a href="javascript:window.open('redirectopages.cfm?ploc=therapyedit.cfm&svalue=therapy', '_self'); ColdFusion.Window.hide('therapy_window');"> Edit Therapy</a><br />
<a href="javascript:window.open('redirectopages.cfm?ploc=therapydelete.cfm&svalue=therapy', '_self'); ColdFusion.Window.hide('therapy_window');"> Delete Therapy</a>

</cfwindow>

</body>
</html>


redirectopages.cfm
<cfif IsDefined("URL.ploc") AND #URL.ploc# NEQ ''> 

<cflock scope="Session" type="Exclusive" timeout="3" throwontimeout="Yes">
	<cfset Session.page="#URL.svalue#" />
</cflock>

	<cflocation url="#URL.ploc#" addtoken="no"/>
</cfif>


header01.cfm
<!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></title>
</head>

<body>
<table width="100%" border="1" cellspacing="2" cellpadding="2">
  <tr>
    <td><a href="samplemain.cfm">RETURN TO MAIN MENU</a></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div style="position:relative;">
  <span style="position:absolute; right:650px; bottom:0">
  <cfif IsDefined("SESSION.Page") AND #SESSION.Page# EQ 'administration'>
    <span class="red" style="font-size:24px"><strong>Administration</strong></span>
    <cfelseif IsDefined("SESSION.Page") AND #SESSION.Page# EQ 'schedules'>
    <span class="red" style="font-size:24px"><strong>Schedules(Medicare)</strong></span>
    <cfelseif IsDefined("SESSION.Page") AND #SESSION.Page# EQ 'therapy'>
    <span class="red" style="font-size:24px"><strong>Therapy Notes</strong></span>
  </cfif>
  </span></td>
  </tr>
</table>
</body>
</html>

menuitems01.cfm
<!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>Vertical Menu Items</title>

</head>
<body>
<table width="100%" border="0" cellspacing="2" cellpadding="2" >
  <tr>
    <td align="center">
	<!---start administration menu section--->
      <cfif IsDefined("SESSION.Page") AND #SESSION.Page# EQ "administration">
        <cfmenu name="menu" type="horizontal" menustyle="padding:0; yuimenu{z-index:300003}; border:solid; border-width:medium; color:##CC6666; font-weight: bold;" 
font="Arial, Helvetica, sans-serif" fontcolor="##FFFFFF" fontsize="16" selectedfontcolor="##000000" selecteditemcolor="##FFCC99"  bgcolor="##CC0033">
        <cfmenuitem name ="newUser" href= "adminadd01.cfm" display ="Add Admin"/>
        <cfmenuitem name ="editUser" href= "adminedit.cfm" display ="Edit Admin"/>
        <cfmenuitem name ="inactiveUser" href= "admindelete.cfm" display ="Delete Admin"/>
        </cfmenu>
        <!---end administration menu section--->
        
        <!---start references menu section--->
        <cfelseif IsDefined("SESSION.Page") AND #SESSION.Page# EQ "schedules">
        <cfmenu name="menu" type="horizontal" menustyle="padding:0; yuimenu{z-index:300003}; border:solid; border-width:medium; color:##CC6666; font-weight: bold;" 
font="Arial, Helvetica, sans-serif" fontcolor="##FFFFFF" fontsize="16" selectedfontcolor="##000000" selecteditemcolor="##FFCC99"  bgcolor="##CC0033">
        <cfmenuitem name ="newUser" href= "scheduleadd01.cfm" display ="Add schedules"/>
        <cfmenuitem name ="editUser" href= "scheduleedit.cfm" display ="Edit schedules"/>
        <cfmenuitem name ="inactiveUser" href= "scheduledelete.cfm" display ="Delete schedules"/>
        </cfmenu>
        
        <!---end references menu section--->
        
        <cfelseif IsDefined("SESSION.Page") AND #SESSION.Page# EQ "therapy">
        <cfmenu name="menu" type="horizontal" menustyle="padding:0; yuimenu{z-index:300003}; border:solid; border-width:medium; color:##CC6666; font-weight: bold;" 
font="Arial, Helvetica, sans-serif" fontcolor="##FFFFFF" fontsize="16" selectedfontcolor="##000000" selecteditemcolor="##FFCC99"  bgcolor="##CC0033">
        <cfmenuitem name ="newUser" href= "therapyadd01.cfm" display ="Add therapy"/>
        <cfmenuitem name ="editUser" href= "therapyedit.cfm" display ="Edit therapy"/>
        <cfmenuitem name ="inactiveUser" href= "therapydelete.cfm" display ="Delete therapy"/>
        </cfmenu>
      
      </cfif></td>
  </tr>
</table>
</body>
</html>

adminadd01.cfm
<!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>ADMIN ADD PAGE</title>
<cfinclude template="header01.cfm">
<cfinclude template="menuItems01.cfm">
</head>

<body>
ADMIN ADD SAMPLE PAGE
</body>
</html>

scheduleadd01.cfm
<!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>SCHEDULE ADD PAGE</title>
<cfinclude template="header01.cfm">
<cfinclude template="menuItems01.cfm">
</head>

<body>
SCHEDULE ADD SAMPLE PAGE
</body>
</html>

therapyadd01.cfm
<!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>THERAPY ADD PAGE</title>
<cfinclude template="header01.cfm">
<cfinclude template="menuItems01.cfm">
</head>

<body>
THERAPY ADD SAMPLE PAGE
</body>
</html>

Open in new window

Avatar of James Rodgers
James Rodgers
Flag of Canada image

In this block

<cfif IsDefined("URL.ploc") AND #URL.ploc# NEQ ''>

<cflock scope="Session" type="Exclusive" timeout="3" throwontimeout="Yes">
      <cfset Session.page="#URL.svalue#" />
</cflock>

      <cflocation url="#URL.ploc#" addtoken="no"/>
</cfif>

if the url variables are either not defined or equal to ''
then your session variable is not reset

combined with theis link
<a href="samplemain.cfm">
which does not pass a ploc or svalue means than when used this link will not reset the session.page variable
Avatar of s_hausen
s_hausen

ASKER

Hi Jester 48,
Would you please elaborate it, I didn't catch what you are trying to say?
your code checks for a URL variable
<cfif IsDefined("URL.ploc") AND #URL.ploc# NEQ ''>

if the variable exist and is not empty then set session.page=svalue

so first time through the URL looks like this

redirectopages.cfm?ploc=adminadd01.cfm&svalue=administration
ploc is defined  true
ploc != '' true
svalue = 'administration'

open the link
<a href="samplemain.cfm">

the if block defined within statement

<cfif IsDefined("URL.ploc") AND #URL.ploc# NEQ ''>

does not get executed to change the value of session.page

session.page is still administration
ok, took a few tries to get what you were experiencing, and yes that is the behaviour, you change the value of the variable session.page and all references to that variable will update to the new value and anything that references that variable will be affected by the value change
SOLUTION
Avatar of James Rodgers
James Rodgers
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Jester 48,
I do appreciate your help but is there any other way around, coss the code I just put is sample otherwise , i've more than 1200 files here and it would be impossible for me. I also wanted to go with diffrent menu's and headers for diffrent sections but i don't thinks its also a good approach.
but when you right click on Return to main menu and select schedules or therapy and open it in a new tab, it also shows the therapy heading with therapy menu but when we refresh the administration page its menu and heading changes to therapy heading and therapy menu.

To clarify, that's exactly what should happen.  All of your tabs share the same session.  Meaning there's only ever one #Session.page# for ALL windows, not one value per window.  Every time you change #Session.page# it changes in ALL of your windows.  That's what it's supposed to do.  

If you want to maintain a different value for each window, you should be using URL variables instead as Jester suggested earlier.

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry for late response. i go ahead and check it in my code and get back with you guys...
I also try to create different sessions with diffrent menu's but in that case, all the menu's appears and stack on each other. I guess there's no other way instead of creating diffrent menu's for diffrent sections or passing the url values on diffrent pages.
helped me to find out the best route to solve my problem..
@s_hausen - I'm really baffled by the "C" grade? We explained the cause of the problem and the correct way to resolve it. Was there further clarification you needed?

https://www.experts-exchange.com/help.jsp#hs=29&hi=403
i do apologize for that, would u please let me know how to change it to, B.
I appreciate that. But I'm still wondering .. was something unclear? Because a "B" grade usually means we didn't fully answer the question, and I think we did.  ie You're just using the wrong variable type for this task. Session variables actually do the opposite of what you're trying to achieve. But if there's something that's still not clear, I'd be happy to explain further.

> let me know how to change it
You can use the "request attention" link to ask the moderators to re-open the question.




Thanks. If you have further questions, please don't hesitate to ask.
thank you all again...