[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Coldfusion Menu and Session

Posted on 2011-10-11
17
Medium Priority
?
697 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:s_hausen
  • 7
  • 5
  • 4
16 Comments
 
LVL 25

Expert Comment

by:James Rodgers
ID: 36957372
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
0
 

Author Comment

by:s_hausen
ID: 36958064
Hi Jester 48,
Would you please elaborate it, I didn't catch what you are trying to say?
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 36958180
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
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 25

Expert Comment

by:James Rodgers
ID: 36958392
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
0
 
LVL 25

Assisted Solution

by:James Rodgers
James Rodgers earned 1200 total points
ID: 36958511
if you want to be able to maintain different states across different windows you should pass some url parameters

something like

adminadd01.cfm?pagetype=1&pagesection=17
so that if the page is preloaded it can maintain the state

if the code samples above are how you intent\d to implement your code
remove the header and footer blocks from header01.cfm and menu01.cfm, when converted to HTML you end up with three doctyoe declarations as well as other code
0
 

Author Comment

by:s_hausen
ID: 36959501
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.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36963687
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.

0
 
LVL 52

Accepted Solution

by:
_agx_ earned 800 total points
ID: 36964016
    > If you want to maintain a different value for each window, you should be using
     > URL variables instead as Jester suggested earlier.

In other words, you have to pass the selected menu option in the URL as a parameter on your redirection page:

        <!--- ie go to url:  "adminadd01.cfm?svalue=administration" --->
      <cflocation url="#URL.ploc#?page=#URL.svalue#" addtoken="no" />

Then use that URL variable in your menu

     <cfif IsDefined("URL.Page") AND URL.Page EQ "administration">
      ....

.... NOT the session variable

     <cfif IsDefined("SESSION.Page") AND #SESSION.Page# EQ "administration">
0
 

Author Comment

by:s_hausen
ID: 36966071
sorry for late response. i go ahead and check it in my code and get back with you guys...
0
 

Author Comment

by:s_hausen
ID: 36966108
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.
0
 

Author Closing Comment

by:s_hausen
ID: 36966140
helped me to find out the best route to solve my problem..
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36966170
@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?

http://www.experts-exchange.com/help.jsp#hs=29&hi=403
0
 

Author Comment

by:s_hausen
ID: 36966184
i do apologize for that, would u please let me know how to change it to, B.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36966208
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.




0
 
LVL 52

Expert Comment

by:_agx_
ID: 36966398
Thanks. If you have further questions, please don't hesitate to ask.
0
 

Author Comment

by:s_hausen
ID: 36968801
thank you all again...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question