CF 8.0 cfscript variable
Pls check if this is a bug cos it seemed like the cfscript and main cfoutput shared the same variable:
Result : 5
Expeced Result: 1
<cfscript>
function
valid4D(str){
if (len(str) neq 4)
return false;
if (Ucase(str) eq "XXXX")
return false;
for(i = 1; i lte 4; i = i + 1){c =
Mid(str, i, 1);
if (Not Find(c, "0123456789xX"))
return false;}
return true;}
</cfscript>
<cfloop
from="1" to="1" index="i">
<cfif not #valid4D("5555")#>
<cfset err= 1>
</cfif>
<cfoutput>#i#</cfoutput></cfloop>
it seemed like the cfscript
and main cfoutput shared the same variable:
That is entirely possible. It does not look like you are VAR scoping your function variables. So when you declare your variables inside the function they are placed in the shared "variables" scope. The "variables" scope is accessible to the whole page, including your "main cfoutput".
You need to VAR scope all of your function local variables so they do not leak into the shared "variables" scope.
function valid4D(str){
VAR i = "";
VAR c = "";
.... etc ....
Similar Messages
-
Using CF8. I'm creating a report using cfdocument what will export as a PDF. I want the report to look like the following:
Vendors Within the City
comm_cd sub-heading
vendor name
address
loc_code
vendor name
address
loc_code
comm_cd sub-heading
vendor name
address
loc_code
comm_cd sub-heading
vendor name
address
loc_code
Vendors Outside the City
comm_cd sub-heading
vendor name
address
loc_code
vendor name
address
loc_code
The loc_code is what determines which grouping the record will be in. Here is the code I'm working with so far without the second heading...not sure where to put it.
My query that is being called from the switch
<cfquery dbtype="query" name="getVendor">
SELECT DISTINCT
comm_cd,
comm_desc,
vend10,
mbe,
gender,
ethnic,
lgl_nm,
street_address,
city,
state,
zip,
loc_code,
phone,
fax
FROM
variables.savedlist
ORDER BY
comm_cd,
lgl_nm
</cfquery>
<cfscript>
variables.location = 0;
</cfscript>
<cfif listFind('LO,AU,SL',getvendor.loc_code)>
<cfset variables.location = 1 />
</cfif>
<cfif variables.location EQ 1>
<div style="text-align:left;font-size:10pt;font-weight:bold;font-family:arial;">Vendors Within City</div>
<cfoutput query="getvendor" group="comm_cd">
<table>
<div style="width: 100%; border: 1px; table-layout:fixed;">
<colgroup>
<col align="left" style="width:400px;"/>
<col align="left" style="width:400px;"/>
<col align="left" style="width:300px;"/>
<col align="left" style="width:300px;"/>
<col align="left" style="width:300px;"/>
</colgroup>
<tbody>
<tr>
<td colspan="6"><div style="text-align:left;font-size:8pt;font-weight:bold;font-family:arial;">#getVendor.COMM_CD# #getVendor.comm_desc#</div></td>
</tr>
<cfoutput>
<tr>
<td><div style="text-align:left;font-size:8pt;font-family:arial;"> </div></td>
<td><div style="text-align:left;font-size:8pt;font-family:arial;">#getVendor.VEND10#<br>#getVendor.LGL_NM#<br>#getVendor.street_address#<br>#getVendor.city# #getVendor.state# #getVendor.zip#</div></td>
<td><div style="text-align:left;font-size:8pt;font-family:arial;">#getVendor.phone#<br>#getVendor.fax#</div></td>
<td><div style="text-align:left;font-size:8pt;font-family:arial;">#getVendor.MBE#</div></td>
<td><div style="text-align:left;font-size:8pt;font-family:arial;">#getVendor.GENDER#/#getVendor.ETHNIC#</div>
<td><div style="text-align:left;font-size:8pt;font-family:arial;">#getVendor.loc_code#</div></td>
</tr>
</cfoutput>
<tr> </tr>
</tbody>
</div>
</table>
</cfoutput>
</cfif>
What am I doing wrong? I know I need a <cfelse> in there along with the heading 'Vendors Outside the City'. But no matter where I put it nothing seems to work correctly.
ThanksHi,
in that case you can group them using Sort table parameter. you can build the sort table based on month, and the data will be grouped based on month. this is another possibility.
sort-fieldname = 'MONTH'.
sort-up = 'X'.
append sort to it_sort.
pass this IT_sort to alv grid FM.
Regards
Vjay -
Coldfusion, JSON, and the Amazon CloudSearch API
Hi all,
We are using Amazon CloudSearch service for our site search. We created a front end which uses jquery to communicate with the server to display search results.
The problem we are running into is with creating and updating data on the backend. We have been creating new domains and uploading whole data sets manually from spreadsheets which is obviously not going to work for us long term.
The cloud search uses has an API that we can send JSON to for updating the items. I have created the nested json like this (the query name and data has been changed to protect the innocent):
<cfscript>
variables.dataFields = {};
variables.dataFields['id'] = " #getsdata.id#";
variables.dataFields['lang'] = "en";
variables.dataFields['type'] = "add";
variables.dataFields['version'] = " #DateFormat(Now(),"YYMMDD")##TimeFormat(Now(),"HHMM")#";
variables.dataFields['fields'] = {};
variables.dataFields.fields['redfield'] = "#getsdata.redfield#";
variables.dataFields.fields['blackfield'] = "#getdata.blackfield#";
variables.dataFields.fields['purplefield'] = "#getdata.purplefield#";
variables.dataFields = serializejson(variables.dataFields);
</cfscript>
When I dump that json out, it looks pretty good (there are many more fields). For now, I added a space before numbers to work around a bug I read about in the serializedjson function in CF8 that sees all numbers as numbers even if they are expressed as strings. I will figure that out later.
The code to post the json is:
<cfhttp url="http://doc-ourcompanydomain-abunchofnumbers.us-west-2.cloudsearch.amazonaws.com/2011-02-01 /documents/batch" method="post" result="httpResp">
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="header" name="Accept" value="application/json" />
<cfhttpparam type="header" name="Content-Length" value="#Len(variables.dataFields)#" />
<cfhttpparam type="body" value="#variables.dataFields#" />
</cfhttp>
The response I get is "400 Bad Request"
I know that there aren't that many people using cloud search and Coldfusion but I was hoping somebody might see a noob mistake in my code or methods.
Thanks!
RedHi Peter,
Thank you for your response. For some reason, I was not able to reply to my own post. Maybe I just wasn't signed in.
Anyway, the problem was with the json that I was uploading and not with my method for uploading it. I was actually able to remove the "Accept" and "Content-Length" params.
I had added a space in front of the ID so that the serializedjson function would treat it as a string and not a number but the API required that field start with an alphanumeric character. Since I am using the sku number for that product, I just changed it to sku12345 etc so that it was seen by the serializedjson function as a string and the API would accept it.
Also, I had to add brackets around the enitre body because the Cloudsearch API wanted the entry to be an array so I just added:
<cfset theuploaddata = "[" & variables.dataFields & "]">
Once I made those changes, the server responded with a 200 code and updated the item. Now I just need to figure out how to get arrays past the CF json tag. Some of our json is set up for the cloudsearch in arrays like colors. The facets need to appear in the upload as "Colors" : ["Red","Blue"] but the serialized json tag automatically escapes the quotes in the facets. I think I saw some third party custom tags that I can use as a work around.
Thanks again for your help. The Cloudsearch service has been awesome so far. We are really happy with it. We are a small to midsized company and the cost of a dedicated search company was 10-15 as much as the cloud search and they basically wanted total control of the site. The cloudsearch required a considerable amount of work to set up but it works beautifully. Since we use it for navigation too, I have been thinking about caching the json for the common requests.
Red -
I am looking for advice on how to nest objected created from
cfcs...
The place I have seen this sdone is in the fusebox framwork
in the following:
#myFusebox.getCurrentCircuit().getAlias()#
What I would like to do is create an object called called
users from a users.cfc with methods such as listUsers() and
findUser(userID)...
Ex. #users.findUser(34)#
Then from there I want to next another object (object might
not be the correct term) or set of functions that deal with the
user specified such as getName() and getEmail()...
Ex. #users.findUser(34).getName()#
Ex. #users.findUser(34).getEmail()#
Can someone explain to me how this can be done?
Thanks!jeby wrote:
> Can someone explain to me how this can be done? Thanks!
>
How this is done depends largely on how the objects are
related to each
other. I.E. Does one object extend (inherit) the other object
creating
an is-a or parent child relationship. Or does one object
contain an
instance of the other as a property|variable (composite)
creting an
has-a relationship.
I'm doing some web service with complex object testing and I
have just
written this simple testing code. See if it makes some sense
to you.
basic.cfc
<cfcomponent>
<cfproperty name="foo" type="string">
<cfproperty name="bar" type="string">
<cfscript>
this.foo = "George";
variables.bar = "Gracie";
</cfscript>
<cffunction name="getBar" access="remote"
returntype="string">
<cfreturn variables.bar>
</cffunction>
</cfcomponent>
complex.cfc
<cfcomponent>
<cfproperty name="anObj" type="basic">
<cfscript>
variables.anObj = createObject("component","basic");
</cfscript>
<cffunction name="getObj" access="remote"
returntype="basic">
<cfreturn variables.anObj>
</cffunction>
</cfcomponent>
index.cfm
<cfscript>
complexComp = createObject("component","complex");
</cfscript>
<cfdump var="#basicComp#" expand="no">
<dl>
<dt>complexComp.getObj()</dt>
<dd><cfdump
var="#complexComp.getObj()#"></dd>
<dt>complexComp.getObj().foo</dt><
dd>#complexComp.getObj().foo#</dd>
<dt>complexComp.getObj().getBar()</dt>
<dd>#complexComp.getObj().getBar()#</dd>
</dl> -
Hi Everybody,
I am not a tech person but I'll try my best describing the situation.
When I yesterday tried to fix an error message (which always showed when not all requiered fields were filled in at our company's "Request for Quote" site), I think I messed up the whole inquiry-forwarding system. I must have deleted everything.
My company's using Macromedia Dreamwaver 8, and the guy who wrote the pages are long gone. If only I could revert the present non-functioning system how it used to be but it's too late, I already turned my comp off yesterday.
The way it should work is that the customer types in all info we need from him, then pushes the submit button, which then sends an email to us and leads the customer to our "Thank you for your inquiry" page. If some eror happens, it brings the customer to our mailto.cfm page, which now shows some error message I do not understand about the 3rd line, variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"RECIPIENT") );
Here's what I found as an old-timer back-up to our mailto.cfm page (which I altered yesterday, and that caused the whole problem), which no longer works either:
<cfscript>
variable.fieldnames = form.fieldnames;
variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"RECIPIENT") );
variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"SUBJECT") );
variable.fieldnames = ListDeleteAt(variable.fieldnames, ListFindNoCase(variable.fieldnames,"THANKURL") );
</cfscript>
<cfparam name="FORM.SUBJECT" default="Web Site Form">
<cfmail to="[email protected]" from="[email protected]" subject="#FORM.SUBJECT#">#FORM.SUBJECT#
Sent #DateFormat(now(),'dddd mmmm d, yyyy')# @ #TimeFormat(now(),'h:mm tt')#
<cfloop index="i" list="#variable.fieldnames#"><cfif len(evaluate("form.#i#"))><cfif uCase(right(i,6)) eq "_BREAK">#chr(13)#</cfif>#ReplaceNoCase(i,"_BREAK","")#:#RepeatString(" ", evaluate(15-len(ReplaceNoCase(i,"_BREAK",""))))# #Replace( evaluate("form.#i#"), chr(10), chr(10) & RepeatString(" ",17), "All" )# #chr(13)#</cfif></cfloop>
</cfmail>
<cflocation url="#form.THANKURL#" addtoken="No">
It seems simple, the to-field is correct, the from-field must be too, why do you still think that it's not forwarding the inquiries as emails any more? Where is this code broken?
I would welcome all suggestions, I really need your help!Please repost this request on the Dreamweaver Application Development Forum - it's much more suited to these kinds of questions!
http://forums.adobe.com/community/dreamweaver/dreamweaver_development -
Function references and stateful cfcs?
Using 8.0.1
ok, i have a happy component (example4.cfc):
<cfcomponent output="false">
<cfscript>
variables.txt = "un-init";
</cfscript>
<cffunction name="Init" access="public" returntype="example4" output="false">
<cfscript>
variables.txt = "init";
</cfscript>
<cfreturn this />
</cffunction>
<cffunction name="remoteEcho" access="remote" returntype="string" ExtDirect="true" output="false">
<cfargument name="str" type="string" required="true" />
<cfreturn str & "[" & variables.txt & "]"/>
</cffunction>
</cfcomponent>
and I am trying to call a function reference like so:
<cfscript>
cfc = CreateObject('Component', 'Example4').Init();
method = cfc['RemoteEcho']; //<- try to create function reference
</cfscript>
<cfdump var="#cfc#">
<cfdump var="#method#">
<cfdump var="#cfc.remoteEcho('bobo')#"><!--- this works, naturally --->
<cfdump var="#method('bobo')#"><!--- failure here --->
The problem that I am running into is that it cannot find the variables.txt private member.
Element TXT is undefined in VARIABLES.
The direct call works fine, however the reference acts as if it's, i don't know, a regular UDF outside of a cfc?
Any help here, or will this just not work?
-JimAs far as I know it will not work if you're accessing private
variables because I seem to remember that the function reference is
not tied to the cfc instance.
Mack -
Cfloginuser - roles of object permission. Array?
Hello, wonderfully helpful people!
Imagine a project that involves a corporate structure. Some
users can only see themselves, some users can see one (or many)
departments, and maybe an extra user or two. Some users can see
everything. Etc.
Now, expand this to include many corporations, each with
their unique corporate structures, and a single person has access
over (seemingly) arbitrary objects within multiple corporations.
Basically, the user's permission is at the object level;
there's not a *role*. And, to add a little extra fun, I do not know
all the objects involved - it's dynamic -, and those objects do not
have a unique id amongst themselves.
What I would like to put into roles is a list of lists; a
list of each object type, containing the ids for that object that
the user has access to. Perhaps the first value is the object type,
and the rest are the ids. Example:
{1,12,13},{2,12,52},{3,12,42}
I'm currently doing a workaround to make the list like, in
order to be able to use the IsUserInRole and whatnot (though it's a
bit tedious):
1_12,1_13,2_12,2_52,3_12,3_42
So:
1. has anyone else dealt with object-level permissions using
cflogin? How did you do it?
2. what suggestions might you make to improve this?
Thank you in advance! Surely there's a better way to do this.
Best wishes,
CatSorry no good tutorials, I've mostly figured it out by trial
and error.
I find that security schemes tend to be very personally and
vary
wildly from application and organization to another.
The basic concept is a CFC that stores the relevant
information and the
appropriate functions to retrieve this information in the
desired
format. A big question is do you want this cfc to be aware of
the user
information store(s) or to have that factored out into
another layer.
For easy of readability I'll provide the basic skeleton of a
CFC that is
not aware of the data store but the roles are passed in. I
have also
built this such that by just passing in a user ID the
component
generates all the user data.
<cfcomponent name="User Object">
<cfscript>
variables.name = "";
variables.roles = structNew();
</cfscript>
<cffunction name="init" ...>
<cfargument name="name"...>
<cfargument roles="" ...>
<cfscript>
variables.name = arguments.name;
variables.roles = arguments.roles;
</cfscript>
</cffunction>
<cffunction name="getName"...>
<cfreturn variables.name>
</cffunction>
<cffunction name="getRoles"...>
<cfreturn variables.Roles>
</cffunction>
<cffunction name="isUserInRole"...>
<cfargument name="role"...>
<cfreturn
structKeyExists(variables.roles,arguments.role)>
</cffunction>
</cfcomponent>
This is extremely bare bones and will need considerable
fleshed out but
it should give you an idea.
Then you just replace the <cfloginuser.... line with a
createObject()
function or <cfinvoke...> tag to call this CFC init
function passing in
the required arguments. And call thisObj.isUserInRole where
you are
calling isUserInRole(). -
Can't get cf_averyrtf to work for me!
Using Coldfusion 8 with an Oracle backend. I'm trying to implement this custom tag, but not getting anywhere. I'm a newbie at this so I'm sure there's something I'm not doing correctly.
All I get when I try to run the labels is the following along with the CSS that creates the application headings and sidebars (this is just a partial copy) -
{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss Arial;}{\f1\fswiss Helvetica;}{\f2\fswiss Impact;}{\f3\froman Times New Roman;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\g reen255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\g reen255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\g reen0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192 \green192\blue192;\red255\green255\blue255;}{\info{\title VFIVE Label Generator (Avery Labels Generated by CF_AVERYRTF Output)}{\author cf_averyRTF $Revision: 1.17 $}{\operator cf_averyRTF resides at http://rtf.vfive.com}{\*\company VFIVE (http://www.vfive.com)}{\creatim\yr2012\mo9\dy6\hr10\min43}{\version1}{\edmins0}{\nofpages1}{\nofwords0}{\nofch ars0}{\nofcharsws0}{\vern1000}}\paperw12240\paperh15840\margl405\margr0\margt900\margb0\gu tter0 \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\horzdoc \jexpand\viewkind1\viewscale100\nolnhtadjtbl \fet0\sectd \linex0\sectdefaultcl\trowd \trrh-1080\trkeep \cellx3420 \cellx4005 \cellx7425 \cellx8010 \cellx11430 \pard\plain \ql \li10\ri0\widctlpar\intbl\faauto \f0
Here is the code in the switch page -
<cfcase value="availabilitylistlbl">
<cfscript>
variables.soldata = session.solicitation.getSolicitation(attributes.solicitation_id);
variables.savedlist = session.availability.getSavedAvailabilityList(attributes.snapshot);
</cfscript>
<cf_cf_averyrtf>
<cfoutput query="variables.savedlist">
<cf_cf_averycell>
#lgl_nm# #chr(10)#
#street_address# #chr(10)#
#city#, #state# #zip# #chr(10)#
</cf_cf_averycell>
</cfoutput>
</cf_cf_averyrtf>
</cfcase>
Any coding help would be greatly appreciated.
SherryText and object MUST be on the same layer.
Text MUST be on top of object to be wrapped.
Text MUST be area text.
Are all of the above true?
From reading your steps, you've got the text behind the object to wrapped, becuase you created the text, then placed/pasted an image. If you were to place/paste the image, then create the text, you'd be set.
Select the text and choose Object > Arrange > Move to front. Then try wrapping the text. -
In my array for a Shopping Cart, the customer can select to add, subtract or delete an item.
All the functions work.
In the code to subtract, when the function is invoked, quantity changes from 1 to 0 in the cart, with a total value of $0.00.
A line also appears telling the customer that the cart is empty.
But if you click the subtract one more time, quantity changes from 0 to -1, with a value of -$5.00.
How can I delete an item when the subtraction results in a quantity of 0?
Many thanks, Charlie
CART.CFM
<cfif isdefined("url.action")>
<cfif url.action is "addQuantity">
<cfset session.cart.addQuantity(url.position)>
<cflocation url="cart_main.cfm">
</cfif>
<cfif url.action is "subtractQuantity">
<cfset session.cart.subtractQuantity(url.position)>
<cflocation url="cart_main.cfm">
</cfif>
<cfif url.action is "delete">
<cfset session.cart.removeItem(url.position)>
<cflocation url="cart_main.cfm">
</cfif>
</cfif>
<cfset arCart = session.cart.getCart()>
<table>
<cfoutput>
<cfloop from="1" to="#arraylen(arCart)#" index="counter">
<tr valign="top">
<td>#arCart[counter].isd_code#</td>
<td></td>
<td>#arCart[counter].title.gettitle()#</td>
<td></td>
<td>#dollarformat(arCart[counter].price)#</td>
<td></td>
<td>#arCart[counter].ItemName#</td>
<td></td>
<td align="center">#arCart[counter].quantity#</td>
<td></td>
<td><a href="cart.cfm?action=addQuantity&position=#counter#">ADD</a></td>
<td></td>
<td><a href="cart.cfm?action=subtractQuantity&position=#counter#">SUB</a></td>
<td></td>
<td><a href="cart.cfm?action=delete&position=#counter#">DEL</a></td>
<td></td>
<td>
<cfset variable.itemTotal = (#arCart[counter].quantity# * #arCart[counter].price#)>
#dollarFormat(variable.itemTotal)#
</td>
</tr>
</cfloop>
</cfoutput>
</table>
SHOPPINGCART.CFC
<cfcomponent output="false">
<cfproperty name="arCart" type="array" default="arraynew(1)" />
<cfscript>
variables.arCart = arraynew(1);
</cfscript>
<cffunction name="subtractQuantity" access="public" output="false" returntype="void">
<cfargument name="position" required="true" type="numeric">
<cfparam name="subQty" type="numeric" default="1">
<cfset arCart[position].quantity = arCart[position].quantity - subQty>
</cffunction>
<cffunction name="removeItem" access="public" output="false" returntype="void">
<cfargument name="position" required="true" type="numeric">
<cfset arraydeleteat(arCart, arguments.position)>
</cffunction>
</cfcomponent>It's hard to understand exactly what's going there but this code might help set you in the right direction. It basically looks at the quantity of the item for the given position and it won't let you subtract more than the number of items that are in it, or go below zero.
<cffunction name="subtractQuantity" access="public" output="false" returntype="void">
<cfargument name="position" required="true" type="numeric">
<cfargument name="subQty" type="numeric" default="1">
<cfif arCart[arguments.position].quantity gte 1 and arguments.subQty lte arCart[arguments.position].quantity>
<cfset arCart[arguments.position].quantity = (arCart[arguments.position].quantity - arguments.subQty)>
<cfelse>
<cfset arCart[arguments.position].quantity = 0 >
</cfif>
</cffunction>
One other thing I noticed in your subtractQuantity() function was that you have a cfparam instead of a cfargument tag, this is probably also causing you issues.
-JD -
Hello,
I am trying to write a wrapper function to be able to work with queries in cfscript (I deal with CF MX7). The SQL string can be assembled and passed to the function as an argument. Here is the function:
<cffunction name="QUERY" access="public" returntype="query">
<cfargument name="SQLString" type="string" required="yes">
<cfargument name="Datasource" type="string" required="no" default="#this.dsn#">
<cfargument name="dbType" type="string" required="no" default="">
<CFQUERY NAME="QryToReturn" Datasource="#arguments.Datasource#" dbtype="#arguments.dbType#">
#preserveSingleQuotes(arguments.SQLString)#
</CFQUERY>
<cfreturn QryToReturn>
</cffunction>
When it's as simple as this it works:
<cfscript>
Variables.iMyValue = 10;
sSQL = "SELECT * FROM t_test WHERE field1 = #Variables.iMyValue#";
Variables.qry1 = QUERY(SQLString: sSQL, DATASOURCE: Application.sDataSrc, DBTYPE: Application.sDBType);
</cfscript>
However I want to add cfqueryparam stuff to the queries and here is where I get errors.
I tried two ways to assemple the SQL:
<cfscript>
Variables.iMyValue = 10;
//this way the function gets value 10
sSQL1 = "SELECT * FROM t_test WHERE field1 = < cfqueryparam value=#Variables.iMyValue# cfsqltype='cf_sql_integer'>";
//this way the function gets a variable
sSQL2 = "SELECT * FROM t_test WHERE field1 = < cfqueryparam value=##Variables.iMyValue## cfsqltype='cf_sql_integer'>";
Variables.qry1 = QUERY(SQLString: sSQL1, DATASOURCE: Application.sDataSrc, DBTYPE: Application.sDBType);
Variables.qry2 = QUERY(SQLString: sSQL2, DATASOURCE: Application.sDataSrc, DBTYPE: Application.sDBType);
</cfscript>
Either way results in the same server error:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Oracle][ODBC][Ora]ORA-00936: missing expression
Could anybody tell me what I am doing wrong?
Thanks,
AlexPassing the cfqueryparam tag within a string neutralizes it. As a general rule, ColdFusion wont evaluate tags that are enclosed within a string.
It is better to place the tag within the query in the function. Then pass the rest of the SQL script as a string. Something like this:
<cffunction name="QUERY" access="public" returntype="query">
<cfargument name="SQLString" type="string" required="yes">
<cfargument name="fieldValue" type="numeric" required="yes">
<cfargument name="Datasource" type="string" required="no" default="#this.dsn#">
<cfargument name="dbType" type="string" required="no" default="">
<CFQUERY NAME="QryToReturn" Datasource="#arguments.Datasource#" dbtype="#arguments.dbType#">
#arguments.SQLString#
WHERE field1 = <cfqueryparam value="#arguments.fieldValue#" cfsqltype="cf_sql_integer">
</CFQUERY>
<cfreturn QryToReturn>
</cffunction>
<cfscript>
variables.iMyValue = 10;
sSQL = "SELECT * FROM t_test";
Variables.qry = QUERY(SQLString: sSQL, variables.iMyValue, DATASOURCE: Application.sDataSrc, DBTYPE: Application.sDBType);
</cfscript> -
I am parsing xml and I am trying to set each xml tag with the
same name to a different variable. This is what I have.
COVYEAR = XmlSearch(myxmldoc, "//COVERED/YR_INFO/YEAR");
for (i = 1; i LTE ArrayLen(COVYEAR); i = i + 1)
vCOVYEAR = COVYEAR
.XmlAttributes["VALUE"];
How do I add the "i" index to the variable vCOVYEAR so that
each element in the array would be set to vCOVYEAR1, vCOVYEAR2,
vCOVYEAR3, etc. etc.
Thanks in advance.Love ColdFusion Scope Structures. They are your friend:
Variables["vCovYear#i#"] = "SomeValue"; -
Trying to move a list of form variables to session variables of the same name
I am trying to move a list of form variables to session variables of the same name and I am having a lot of trouble.
I have never had to post of this forum with a language question in all the 10 years I have been using ColdFusion. I was a qa Engineer @ Allaire/Macromedia back when it was going from one to the other. I have a pretty good grasp of the language.
I have software that runs off a list. The fieldnames are variable and stored off in an array. It's survey software that runs off a "meta file". In this example; I have the number of fields in the survey set to 12 in the "metafile". I have each field declared in that file in array Session.SurveyField[1] and the above loop works fine. I include this "metafile" at the start of the process.
I cfloop around a struct and it works wherever I have needed to use it; such as here - writing to the database for example;
<CFQUERY NAME="InsertRec" DATASOURCE="Survey">
INSERT into #variables.SurveyTableName#
(EntryTime
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
,#Session.SurveyField[arrayindex]#
</cfloop>
<!--- EXAMPLE OF WHAT THE ABOVE GENERATES
,q01_name,q02_AcadTechORNA,q03_Water,q04_FirstAid,q05_CPR,q06_LifeGuard,q07_AED
,q08_ProjAdv,q09_Color,q10_SantaClaus,q11_Supervisor,q12_SupervisorOpinion --->
VALUES
('#EntryTime#'
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thisname = "Session." & Session.SurveyField[arrayindex]>
,'#evaluate(variables.thisname)#'
</cfloop>
<!--- EXAMPLE OF WHAT THE ABOVE GENERATES
,'#Session.q01_name#','#Session.q02_AcadTechORNA#','#Session.q03_Water#','#Session.q04_Fi rstAid#'
,'#Session.q05_CPR#','#Session.q06_LifeGuard#','#Session.q07_AED#','#Session.q08_ProjAdv# ',
,'#Session.q09_Color#','#Session.q10_SantaClaus#','#Session.q11_Supervisor#','#Session.q1 2_SupervisorOpinion#' --->
</CFQUERY>
NOW HERE'S THE PROBLEM: I am running into trouble when trying to move the form variables to session variables of the same name. It is the only part of the software that I still need the datanames hard coded and that is a roadblock for me.
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thissessionfield = "Session." & Session.SurveyField[arrayindex]>
<cfset thisformfield = "Form." & Session.SurveyField[arrayindex]>
<cfset #thissessionfield# = #evaluate(thisformfield)#>
</cfloop>
I have tried it with or without the "evaluate"; same result. It doesn't give an error; it just ignores them (session variables look as such in the next page in the chain)
q01_name=
q02_acadtechorna=
q03_water=
q04_firstaid=
q05_cpr=
q06_lifeguard=
q07_aed=
q08_projadv=
q09_color=
q10_santaclaus=
q11_supervisor=
q12_supervisoropinion=
Note: they exist because I CFPARAM them in a loop like the above at the start of the procedure) - and this works just fine!
<cflock scope="Session" type="EXCLUSIVE" timeout="30">
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset dataname = "Session." & Session.SurveyField[arrayindex]>
<cfparam name="#variables.dataname#" default="">
</cfloop>
</cflock>
I EVEN tried exploiting the Form.Fieldnames list using CFLoop over the list and the same sort of logic within and it still gives me nothing....
Here's the FORM.FIELDNAMES value
"Q01_NAME,Q02_ACADTECHORNA,Q03_WATER,Q04_FIRSTAID,Q05_CPR,Q06_LIFEGUARD,Q07_AED,Q08_PROJAD V,Q09_COLOR,
Q10_SANTACLAUS,Q11_SUPERVISOR,Q12_SUPERVISOROPINION"
Here's the logic; SAME RESULT - The session variables don't get set.
<cfoutput>
<cfloop list="#Form.FieldNames#" index="thisfield">
<!--- <br>#thisfield# --->
<cfscript>
thisSESSIONfield = "Session." & thisfield;
thisFORMfield = "Form." & thisfield;
#thisSESSIONfield# = #thisFORMfield#;
</cfscript>
</cfloop>
</cfoutput>
The CFPARAM in a loop with variable output name works just fine; so does the post (which I included above) as does the SQL Create, Param Form Variables, Param Session Variables, etc.
THIS even works for moving BLANK to each session variable, to zero them all out at the end of the process;
<cflock scope="Session" type="EXCLUSIVE" timeout="30">
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thislocalfield = Session.SurveyField[arrayindex]>
<cfscript>
thissessionfield = "Session." & thislocalfield;
</cfscript>
<cfset #thissessionfield# = "">
</cfloop>
</cflock>
Expanding on that code, you would think this would work, but it doesn't;
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset thislocalfield = Session.SurveyField[arrayindex]>
<cfscript>
thissessionfield = "Session." & thislocalfield;
thisformfield = "Form." & thislocalfield;
</cfscript>
<!--- debug --->
<!--- <cfoutput>#thissessionfield# = "#evaluate(thisformfield)#"</cfoutput><br> --->
<cfoutput>
<cfset #thissessionfield# = "#evaluate(thisformfield)#">
</cfoutput>
</cfloop>
And see that debug code in the middle? To add insult to injury... When I uncomment that it shows me this. So it certainly looks like this should work....
Session.q01_name = "Me"
Session.q02_AcadTechORNA = "N/A"
Session.q03_Water = "Yes (certificate expired)"
Session.q04_FirstAid = "Yes (certificate is current)"
Session.q05_CPR = "No"
Session.q06_LifeGuard = "Yes (certificate expired)"
Session.q07_AED = "Yes (certificate expired)"
Session.q08_ProjAdv = "Yes (certificate expired)"
Session.q09_Color = "Gray"
Session.q10_SantaClaus = "Yes"
Session.q11_Supervisor = "Da Boss"
Session.q12_SupervisorOpinion = "Not a bad thing"
There must be some simpler way to do this. This way won't work against all odds even though it seems so much like it should.
So I end up having to hardcode it; still looking for an automated way to set these #@%$*@!## session variables over the list from the form variables of the same @#@!$#%$%# name. Do I sound frustrated???
No matter what I do, if I don't HARDCODE like this;
<cfset Session.q01_name = Form.q01_name>
<cfset Session.q02_AcadTechORNA = Form.q02_AcadTechORNA>
<cfset Session.q03_Water = Form.q03_Water>
<cfset Session.q04_FirstAid = Form.q04_FirstAid>
<cfset Session.q05_CPR = Form.q05_CPR>
<cfset Session.q06_LifeGuard = Form.q06_LifeGuard>
<cfset Session.q07_AED = Form.q07_AED>
<cfset Session.q08_ProjAdv = Form.q08_ProjAdv>
<cfset Session.q09_Color = Form.q09_Color>
<cfset Session.q10_SantaClaus = Form.q10_SantaClaus>
<cfset Session.q11_Supervisor = Form.q11_Supervisor>
<cfset Session.q12_SupervisorOpinion = Form.q12_SupervisorOpinion>
I always get this from my next page because the session variables are empty;
You must answer question 1.
You must answer question 2.
You must answer question 3.
You must answer question 4.
You must answer question 5.
You must answer question 6.
You must answer question 7.
You must answer question 8.
You must answer question 9.
You must answer question 10.
I tried duplicate as well, but I can not get the above to work...
Can anyone help me do this thing that one would think is simple????I think if you use structure array syntax you should get the results you want.
<cfloop from="1" to="#Session.NumberOfSurveyFields#" index="arrayindex">
<cfset session[Session.SurveyField[arrayindex]] = Form[Session.SurveyField[arrayindex]]>
</cfloop>
Or probably even easier.
<cfset session = duplicate(form)> -
Problem with application-variables - CFLOCK?
Hi,
i have a problem with my application. It is a multi-user
application with 100 parallel-users and CFMX 7.
The problem wich occures is with application variables. These
are mainly structs wich get filled onApplicationStart(). The
problem is, that the variables suddenly disappear, they are empty.
I have read about CFLock and found out, that it is necesseary
to use cflock. And i found out, that onApplicationStart does
correct locking automatically. That is where i do not understand
the problem. The variables get intialized correctly and in further
they only get read-access. Why can they be corrupted?
My other question about that is, wheather i need cflock for
all Read-Access to Application and Session-Variables, even if there
happens no writing to the variables?
Best Regards,
Andreas> ?The element of position 2, of dimension 2, of an array
object used as part of
> an expression, cannot be found.?
> The array is in this case the struct.
Well, OK, that could be a problem. Arrays are not structs:
they are two
different things, are not interchangeable, and have
completely different
sets of functions to utilise them. You cannot treat a struct
as an array.
If CF is claiming your "struct" is an array, then it actually
*is* an
array, not a struct.
What's the line of code which is generating that error?
I suppose one could get this error if you have an array of
structs thus:
myArray
.key1
myArray.key2
(etc)
and you're trying to reference it with a numeric key rather
than by key
name, eg:
myArray
[n]
When n is an integer value, rather than a string (which
corresponds to the
name of the key).
> > Have you trapped the error, done a <cfdump>
of the application scope and
> > checked to see if it's the whole lot going awry, or
just some values?
> I have not used cfdump for it, because the server had to
be immediately
> restarted for our customers. But i think, that it is
not completely empty,
> because the index runs to pos2 of dimenstion2.
So does this not happen in your dev / testing environment?
> Will
> onApplicationStart() be called before? Or only if
onRequestStart() returns true?
I would ***-u-me that the application one would be called
before the
request one. It's pretty easy for you to test this though, I
should think?
(Sorry: for reasons beyond the scope of this conversation,
we're still
forced to use Application.cfm in our software, so I've only a
passing
knowledge of how Application.cfc works).
> Here is the code from onRequestStart()
> <cffunction name="onRequestStart"
returntype="boolean">
> <cfargument name="Requestedpage" required="yes" />
> <cfscript>
> var lFile = "/cargorent/Login.cfm";
> var iPosn = ListFindNoCase( lFile,
Arguments.Requestedpage );
> if( iPosn gt 0 )
> return true;
>
> if( NOT IsDefined( "session.user.Loginname" ) or
session.user.Loginname eq
> "" )
> {
> WriteOutput( "<p><p> The current user is no
longer valid, please log in
> again.</p></p>" & chr(10) & chr(13)
> WriteOutput( "<script
language=""javascript"">parent.location = ""
http://"
> & CGI.HTTP_HOST &
"/Login/Login.cfm"";</script>" );
> return false;
> }
>
> return true;
> </cfscript>
> </cffunction>
One thing I will say here is that I really think you should
be separating
your processing from your display. A function should do
processing. it
should pass that processing back to a CFM template which
should handle
whatever needs to be displayed on the browser. Although
that's nowt to do
with your current issue.
Adam -
Coldfusion session variables being lost
ok so when my users login I establish session variables. one of these is employee id. in my Application.cfc I have this at the top:
<cfscript>
this.name = "My App";
this.sessiontimeout=CreateTimeSpan("0", "0", "45", "0");
this.SESSIONMANAGEMENT="YES";
this.SetClientCookies = "true";
this.setDomainCookies = "true";
</cfscript>
i also set the timeout for sessions at 45 in the CFadmin too.
after a successfull login i capture their session.employeenumber by authenticating through our corporate LDAP. no problem there. note: this app has run smoothly for 6+ years now but something has recently gone wrong.
on every page i reference a file in my application directory called "check_session.cfm" like this:
<cfmodule template="/myApp/Tags/check_session.cfm">
In that file I have code that checks for the existence of the session.employee_number. if it doesn't exist they either timed out or book-marked a page in the app in which they need to be logged in to view:
<cflock timeout="30" throwontimeout="Yes" type="READONLY" scope="SESSION">
<!--- Checks to make sure the user has a session--->
<CFIF NOT IsDefined("Session.employee_number")>
<CFLOCATION URL="http://#cgi.HTTP_HOST#/myApp/LoginAgain.cfm">
</CFIF>
</cflock>
every now and then (i'd say on average 5 times per week) i get an error message from a user (i re-direct all errors to my email with diagnostic info). the error reads "Element EMPLOYEE_NUMBER is undefined in SESSION". when i look at the page the error came from i see my call to the check_session.cfm file about 50 lines above where this error happened when i tried to reference session.employee_number. why wouldn't it not find it and re-direct the user to the timeout page? i can never duplicate this error on my machine either... i always get the right result without the error message. its a random, sporadic, intermittent error.Here is the diagnostic error information. Where you see [omitted] i've changed the URL for the purposes of displaying this detail in a public forum:
struct
Browser
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E; MS-RTC LM 8)
DateTime
{ts '2011-02-21 20:59:21'}
Diagnostics
Element EMPLOYEENUMBER is undefined in SESSION. <br>The error occurred on line 162.
GeneratedContent
<!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"> <!-- DW6 --> <head> <!-- Copyright 2005 Macromedia, Inc. All rights reserved. --> <title>My Home</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="mm_training.css" type="text/css" /> <link rel="stylesheet" type="text/css" href="../template/organized.css"> </head> <body bgcolor="#ffffff" onLoad="onInit()">
HTTPReferer
http://[omitted]/mypage/myhome.cfm?CFID=101686&CFTOKEN=53097237
Mailto
[empty string]
Message
Element EMPLOYEENUMBER is undefined in SESSION.
QueryString
[empty string]
RemoteAddress
10.x.x.x [remote address omitted for purposes of this forum]
RootCause
struct
Detail
[empty string]
ErrNumber
0
Message
Element EMPLOYEENUMBER is undefined in SESSION.
Resolvedname
SESSION
StackTrace
coldfusion.runtime.UndefinedElementException: Element EMPLOYEENUMBER is undefined in SESSION. at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1659) at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1612) at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1747) at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1740) at cfmyhome2ecfm1641837815._factor14(D:\[path_omitted]\mypage\myhome.cfm:162) at cfmyhome2ecfm1641837815.runPage(D:\[path_omitted]\mypage\myhome.cfm:1) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:273) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:86) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.CfmServlet.service(CfmServlet.java:175) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42 ) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
TagContext
array
1
struct
COLUMN
0
ID
LINE
162
RAW_TRACE
at cfmyhome2ecfm1641837815._factor14(D:\[path_omitted]\mypage\myhome.cfm:162)
TEMPLATE
D:\[path_omitted]\mypage\myhome.cfm
TYPE
CFML
2
struct
COLUMN
0
ID
CF_MYHOME
LINE
1
RAW_TRACE
at cfmyhome2ecfm1641837815.runPage(D:\[path_omitted]\mypage\myhome.cfm:1)
TEMPLATE
D:\[path_omitted]\mypage\myhome.cfm
TYPE
CFML
Type
Expression
element
EMPLOYEENUMBER
objectType
object of java.lang.Class
Class Name
java.lang.Class
Methods
Method
Return Type
asSubclass(java.lang.Class)
java.lang.Class
cast(java.lang.Object)
java.lang.Object
desiredAssertionStatus()
boolean
forName(java.lang.String, boolean, java.lang.ClassLoader)
java.lang.Class
forName(java.lang.String)
java.lang.Class
getAnnotation(java.lang.Class)
java.lang.annotation.Annotation
getAnnotations()
java.lang.annotation.Annotation[]
getCanonicalName()
java.lang.String
getClassLoader()
java.lang.ClassLoader
getClasses()
java.lang.Class[]
getComponentType()
java.lang.Class
getConstructor(java.lang.Class[])
java.lang.reflect.Constructor
getConstructors()
java.lang.reflect.Constructor[]
getDeclaredAnnotations()
java.lang.annotation.Annotation[]
getDeclaredClasses()
java.lang.Class[]
getDeclaredConstructor(java.lang.Class[])
java.lang.reflect.Constructor
getDeclaredConstructors()
java.lang.reflect.Constructor[]
getDeclaredField(java.lang.String)
java.lang.reflect.Field
getDeclaredFields()
java.lang.reflect.Field[]
getDeclaredMethod(java.lang.String, java.lang.Class[])
java.lang.reflect.Method
getDeclaredMethods()
java.lang.reflect.Method[]
getDeclaringClass()
java.lang.Class
getEnclosingClass()
java.lang.Class
getEnclosingConstructor()
java.lang.reflect.Constructor
getEnclosingMethod()
java.lang.reflect.Method
getEnumConstants()
java.lang.Object[]
getField(java.lang.String)
java.lang.reflect.Field
getFields()
java.lang.reflect.Field[]
getGenericInterfaces()
java.lang.reflect.Type[]
getGenericSuperclass()
java.lang.reflect.Type
getInterfaces()
java.lang.Class[]
getMethod(java.lang.String, java.lang.Class[])
java.lang.reflect.Method
getMethods()
java.lang.reflect.Method[]
getModifiers()
int
getName()
java.lang.String
getPackage()
java.lang.Package
getProtectionDomain()
java.security.ProtectionDomain
getResource(java.lang.String)
java.net.URL
getResourceAsStream(java.lang.String)
java.io.InputStream
getSigners()
java.lang.Object[]
getSimpleName()
java.lang.String
getSuperclass()
java.lang.Class
getTypeParameters()
java.lang.reflect.TypeVariable[]
isAnnotation()
boolean
isAnnotationPresent(java.lang.Class)
boolean
isAnonymousClass()
boolean
isArray()
boolean
isAssignableFrom(java.lang.Class)
boolean
isEnum()
boolean
isInstance(java.lang.Object)
boolean
isInterface()
boolean
isLocalClass()
boolean
isMemberClass()
boolean
isPrimitive()
boolean
isSynthetic()
boolean
newInstance()
java.lang.Object
toString()
java.lang.String
StackTrace
coldfusion.runtime.UndefinedElementException: Element EMPLOYEENUMBER is undefined in SESSION. at coldfusion.runtime.CfJspPage.resolveCanonicalName(CfJspPage.java:1659) at coldfusion.runtime.CfJspPage._resolve(CfJspPage.java:1612) at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1747) at coldfusion.runtime.CfJspPage._resolveAndAutoscalarize(CfJspPage.java:1740) at cfmyhome2ecfm1641837815._factor14(D:\[path_omitted]\mypage\myhome.cfm:162) at cfmyhome2ecfm1641837815.runPage(D:\[path_omitted]\mypage\myhome.cfm:1) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:370) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:273) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:86) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.CfmServlet.service(CfmServlet.java:175) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42 ) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
TagContext
array
1
struct
COLUMN
0
ID
LINE
162
RAW_TRACE
at cfmyhome2ecfm1641837815._factor14(D:\[path_omitted]\mypage\myhome.cfm:162)
TEMPLATE
D:\[path_omitted]\mypage\myhome.cfm
TYPE
CFML
2
struct
COLUMN
0
ID
CF_MYHOME
LINE
1
RAW_TRACE
at cfmyhome2ecfm1641837815.runPage(D:\[path_omitted]\mypage\myhome.cfm:1)
TEMPLATE
D:\[path_omitted]\mypage\myhome.cfm
TYPE
CFML
Template
/[omitted]/mypage/myhome.cfm
Type
coldfusion.runtime.CfErrorWrapper -
Get loggedin Session variables in Home Page
I got a members directory where u login.
1.How come they get killed when i refresh a page.
2.How do i get the loggedin session variable the home page.
so i know if current user is logged in.
The Application.cfc of the members is
<cfcomponent name="Application" displayname="Application
Component for the Login Security Tutorial" >
<cfset This.name = "NewLoveZoneAfrica">
<cfset This.applicationTimeout =
CreateTimeSpan(0,0,0,45)>
<cfset This.sessionManagement = "true">
<cfset This.sessionTimeout = CreateTimeSpan(0,0,0,30)>
<cfset This.clientManagement = "false">
<cfset This.loginstorage="session">
<cffunction name="onApplicationStart"
returntype="boolean" output="true">
<!--- Set up Application variables. Locking the
Application scope is not necessary in this method. --->
application starting
<cfset Application.configured = 1>
<cfset Application.datetimeConfigured = TimeFormat(Now(),
"hh:mm tt") & " " & DateFormat(Now(), "mm.dd.yyyy")>
<cfset Application.currentSessions = 0>
<!--- Begin Setting up request variables here. --->
<cfscript>
request.app = structNew();
Application.dsn = "LoveZoneAfrica";
Application.webRoot =
"#getPageContext().getRequest().getContextPath()#/NewLoveZoneAfrica/";
Application.machineRoot = "/NewLoveZoneAfrica/";
Application.cfcRoot = "NewLoveZoneAfrica.com";
Application.Domain = "NewLoveZoneAfrica.com";
factory=CreateObject("java","coldfusion.server.ServiceFactory");
sqlService = factory.getDataSourceService();
dsn = duplicate(sqlService.datasources[Application.dsn]);
if(dsn.driver eq "MSAccess" or dsn.driver eq "MSAccessJet"
or dsn.driver eq "ODBCSocket")
request.app.ucase = "ucase";
request.app.isAccess = true;
else
request.app.ucase = "ucase";
request.app.isAccess = false;
</cfscript>
<!--- End Setting up request variables here. --->
<cfreturn true>
</cffunction>
<cffunction name="onRequestStart" returntype="boolean"
output="true" >
<cfargument name="requestname" required=true/>
<cfif isDefined("form.j_username") and
isDefined("form.j_password")>
<!--- If either password or Username is empty go to
login--->
<cfif form.j_username is "" or form.j_password is "">
<cfinclude
template="#Application.webRoot#Login/Security/Login.cfm">
<cfabort>
</cfif>
<!--- First Check to see wether there is need to log out
user--->
<cfscript>
// create the Security object
Security =
createObject("component","#Application.cfcRoot#.security");
// store authenticate method of security object as roles
variable.
LogQry=Security.authenticate(form.j_username,form.j_password);
</cfscript>
<cfif LogQry.recordcount> <!--- User has
Successfully logged in #GetValidUser# --->
<cfloginuser name="#form.j_username#"
password="#form.j_password#" roles="#valuelist(LogQry.Role)#">
<!--- Update the LastLogin timestamp. --->
<cfscript>Update_LastLogin=Security.LastLogin(form.j_username);
</cfscript>
<cfset request.User.LoggedIn = "1">
<cfset request.User.Username = form.j_username>
<cfset request.User.LastLogin = LogQry.LastLogin_Date
>
<cfelse>
<!---Destroy request --->
<cflock scope="SESSION" throwontimeout="Yes" timeout="7"
type="EXCLUSIVE">
<cfset clearStruct = StructDelete(request, "User")>
</cflock>
<!---Destroy request --->
<cflock scope="SESSION" throwontimeout="Yes" timeout="7"
type="EXCLUSIVE">
<cfset clearStruct = StructDelete(SESSION, "User")>
</cflock>
</cfif>
<cfif NOT isDefined("request.User.LoggedIn")>
<cfset request.loginMessage ="Your Login Username or
Password is Invalid ">
<cfinclude
template="#Application.webRoot#Login/Security/Login.cfm">
<cfabort>
<cfelse>
<!--- If the login procedure is passed duplicate the
request structure into the Session scope. --->
<cflock scope="SESSION" throwontimeout="Yes"
timeout="107" type="EXCLUSIVE">
<cfset Session.User = Duplicate(request.User)>
</cflock>
<cflock name="lck_currentSessions" throwontimeout="Yes"
timeout="107" type="EXCLUSIVE">
<!---THIS has BE CHANgED : bEGIN- original COPY IS @ THE
FOOT --->
<!--- Copy identifying session information into the
Application scope. --->
<cfif NOT isDefined("Application.sessionData")>
<!--- Increment the number of current sessions. --->
<cfset Application.currentSessions =
Application.currentSessions + 1>
<cfset Application.sessionData = ArrayNew(1)>
<cfset Arraysize = 0>
<cfset Application.sessionData[Arraysize+1] =
form.j_username>
<CFELSE>
<!---check to see wether this "Username" appears in the
Application.sessionData.
If so, ignore. If no then append the name to the array so we
have a unique list of usernames--->
<cfset Arraysize = ArrayLen(Application.sessionData)>
<cfset Application.temp = ArrayNew(1)>
<cfif Arraysize>
<cfloop index = "LoopCount" from = "1" to =
"#Arraysize#">
<cfset #ArrayAppend(Application.temp,
Application.sessionData[LoopCount])#>
</cfloop>
<cfdump var="#Application.sessionData#" >
<cfset Isloggedin =
ListFind(ArrayToList(Application.temp), form.j_username)>
<cfif Isloggedin is 0>
<cfset Application.sessionData[Arraysize+1] =
form.j_username>
<!--- Increment the number of current sessions. --->
<cfset Application.currentSessions =
Application.currentSessions + 1>
</cfif>
<cfelse>
<!--- Increment the number of current sessions since twas
empty. --->
<cfset Application.currentSessions =
Application.currentSessions + 1>
<cfset Application.sessionData[Arraysize+1] =
form.j_username>
</cfif>
</cfif>
</cflock>
</cfif>
<cfelse>
<cfif not ListLast(CGI.SCRIPT_NAME, "/") EQ
"logout.cfm">
<!---Check wether the username appears on the list
Application.currentSessions is 0 --->
<cfif NOT isDefined("Session.User.LoggedIn") >
<cfinclude
template="#Application.webRoot#Login/Security/login.cfm">
<cfabort>
</cfif>
</cfif>
</cfif>
<!--- Check to see if a user is logged in on *every* cfm
page request. --->
<cfif not ListLast(CGI.SCRIPT_NAME, "/") EQ
"logout.cfm">
<cflock scope="SESSION" throwontimeout="Yes" timeout="7"
type="READONLY">
<cfif NOT isDefined("Session.User.LoggedIn")>
<cfinclude
template="#Application.webRoot#Login/Security/login.cfm">
<cfabort>
</cfif>
</cflock>
</cfif>
<cfreturn true>
</cffunction>
<cffunction name="onSessionEnd" returntype="void">
<cfargument name="SessionScope" required="true">
<cfargument name="ApplicationScope" required="true">
<cfset request.loginMessage="Nimeingia onSessionEnd">
<cflock name="lck_currentSessions" throwontimeout="Yes"
timeout="7" type="EXCLUSIVE">
<cfset sessionPosition =
ListFind(ArrayToList(arguments.ApplicationScope.sessionData),
arguments.SessionScope.sessionid)>
<cfif sessionPosition neq 0>
<cfset
ArrayDeleteAt(arguments.ApplicationScope.sessionData,
sessionPosition)>
<cfset arguments.ApplicationScope.currentSessions =
arguments.ApplicationScope.currentSessions - 1>
</cfif>
</cflock>
</cffunction>
<cffunction name="onSessionStart" returntype="void">
<cfset request.loginMessage="Nimeingia onSessionEnd">
</cffunction>
<cffunction name="onRequestEnd" returntype="void">
<!--- Write any code that needs to run when the page
request ends. This replaces onRequestEnd.cfm --->
</cffunction>
</cfcomponent>Answered my own quests
http://www.rewindlife.com/archives/000046.cfm
Maybe you are looking for
-
BASIS--to restrict authorization for a PO document type & 122 movement type
Dear All, Plz guide me how to restrict authorization for a PO document type & for a movement type 122 i.e. for eg. if a user has authorization for PO document type IC then he should not be able to rum movement type 122 for any T-code he runs. Thanks
-
Question in subject
-
User friendly way to let user pick a report?
I have a table that stores report names, the user that generated the report and report date. What is the best method for displaying a list of available reports and letting the user select one for viewing? Would it be an LOV? Darren
-
Hi Every body, I have a requirement on Hr-Benefits, Could any body have a documentations,Configure on Hr-Benefits.Pls send to [email protected] Thank you, Vikram.C
-
Can Aperture 3 upgrade read/convert v1.5.6 library?
In the process of migrating apps/files from G5 to Mac Pro. Unfortunately, my trusty version of Aperture 1.5.6 will not run on the Mac Pro forcing me to upgrade to v3. I have the original Aperture library and two backups, my question is when I go to i