• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 687
  • Last Modified:

IF Condition Not Showing Right Result...

Hi,

Im trying to checking if “ query_string” is not coming  or if it is NULL AND template is NOT “Index.cfm ” forward  to ERROR.CFM Page
Im doing to prevent error if someone remove IDs or remove query string
When im writing this code my index.cfm page is also not coming it going on error.cfm page other then this everything working fine.


Here is my index.cfm code.
<cfset currTempl = trim(GetFileFromPath(GetCurrentTemplatePath()))>
Here im checking current template name .

Application.cfc code:
<cfparam name="indexTemp" default="False" type="boolean">
<cfparam name="currTempl" type="string" default="">

<cfif trim(currTempl) EQ "INDEX.CFM" OR trim(currTempl) EQ "index.cfm" >
<cfset indexTemp = True >
</cfif>


<cfif len(trim(QUERY_STRING)) IS 0 AND indexTemp NEQ True >
<cflocation url="error.cfm" addtoken="yes">
</cfif>

If there is any easy way please let me know, really appreciated
0
xeondxb
Asked:
xeondxb
  • 5
  • 4
1 Solution
 
_agx_Commented:
The only thing I see wrong is a missing CGI scope in from of QUERY_STRING.  This works correctly for me:

<cfset currentTemplate = trim(GetFileFromPath(GetCurrentTemplatePath()))>
<!--- by default, CF string comparisons are case insensitive --->
<cfif currentTemplate neq "index.cfm" AND not len(trim(CGI.QUERY_STRING))>
      go to error page
<cfelse>
      okay
</cfif>

EDIT  But if you're calling it from Application.cfc in one of the request methods you should use the "targetPage" argument instead of currentTemplate (because it returns Application.cfc not the requested page).  Example:

      <cffunction name="onRequestStart" returnType="void">
               <cfargument name="targetPage" type="string" required="true" />
      
            <cfset currentTemplate = trim(GetFileFromPath(arguments.targetPage))>
            <!--- by default, CF string comparisons are case insensitive --->
            <cfif currentTemplate neq "index.cfm" AND not len(trim(CGI.QUERY_STRING))>
                  <cflocation url="error.cfm">
            </cfif>      
      </cffunction>
0
 
xeondxbAuthor Commented:
yea it working now im facing only one issue
when it is going on error.cfm  it is not showing because there is no queryString
AND not len(trim(CGI.QUERY_STRING))>
0
 
_agx_Commented:
Lol, duh! Try this:

      <cffunction name="onRequestStart" returnType="void">
          <cfargument name="targetPage" type="string" required="true" />
      
            <cfset currentTemplate = trim(GetFileFromPath(arguments.targetPage))>
            <!--- by default, CF string comparisons are case insensitive --->
            <cfif not listFindNoCase("index.cfm,error.cfm", currentTemplate)
                            AND not len(trim(CGI.QUERY_STRING))>
                  <cflocation url="error.cfm">
            </cfif>      
      </cffunction>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
xeondxbAuthor Commented:
Thanks Man.....
0
 
xeondxbAuthor Commented:
0
 
_agx_Commented:
Sorry, I know zip about Dreamweaver.  As far as cfc's, can you update your question to be more specific about what you're ultimately trying to do? The basic concept of getters/setters is very simple. But whether you even need cfc's, or how you structure them, depends on your app's needs.
0
 
xeondxbAuthor Commented:
i just updated the question could you have a look ....

--------------------------------------------------------------------------
Hi dear,

i know coldfusion when it was not OOP but know, im  reading coldfusion 9 in this version i can  use OOP, ORM i was writing some exmpale code, i just want to understand how does this getter and setters works where we can use? how does it work when we  get data from database.

about dreamweaver CS6 how can i configure it to work like coldfusion builder because i saw CFBuilder it is easy to work with, like a .NET Studio and we can also save lot of  time to writing code. i don't have CF-Builder software.

i was reading CF-Builder can auto generate  CFC components  like Gateway.cfc, service.cfc and DAO.cfc
0
 
_agx_Commented:
That's a lot of questions for one thread ;-) Unfortunately I don't use ORM either. Here are the parts I can answer:

    about dreamweaver CS6 how can i configure it to work like coldfusion builder

CF Builder is specifically designed for CFML. So it has create CFC wizards built into the app. IIRC, Dreamweaver isn't specifically designed for CF. So it's quite possible it doesn't include (or doesn't support) those wizards. You'd have to ask someone who knows Dreamweaver well.

http://blogs.adobe.com/cfbuilder/2009/07/orm_cfc_generator_1.html


    i don't have CF-Builder software.

If you want to try it out, I hear there's an Express version. They say it is full featured for 60-days, then drops down to a limited version.

Best of luck!
0
 
xeondxbAuthor Commented:
thanks man ... your great...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now