Solved

finding and implementing path in cf for cfcomponent

Posted on 2013-01-19
2
203 Views
Last Modified: 2013-06-17
I am having difficulty implementing some code that is supposed to find/create the path to a component for my application.

 - The cfcomponent is in the root directory.
 - the file that is calling it is in a directory called 'modules'


the code that is calling it is:
<!--- begin example code --->
<cfset paginationPath = reReplace(replace(getDirectoryFromPath(cgi.script_name), "/", ".", "ALL"), "(^\.|\.modules\.?$)", "", "ALL") />

<cfset       pagination = createObject("component", "#paginationPath#.Pagination").init() />
<!--- end example code --->


it generates the following error:
<!--- begin error example --->
   The name .Pagination is not a valid component name.
Component names cannot start or end with dots.
 
The error occurred in E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\E_WebUsers.cfm: line 132

130 :
131 : <cfoutput>
132 : <cfset       pagination = createObject("component", "#paginationPath#.Pagination").init() />
133 : </cfoutput>
134 :

Resources:

    Check the ColdFusion documentation to verify that you are using the correct syntax.
    Search the Knowledge Base to find a solution to your problem.

Browser         ColdFusion
Remote Address         216.151.164.71
Referrer         
Date/Time         19-Jan-13 04:51 PM
Stack Trace
at cfE_WebUsers2ecfm1033662156._factor7(E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\E_WebUsers.cfm:132) at cfE_WebUsers2ecfm1033662156.runPage(E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\E_WebUsers.cfm:1)

coldfusion.runtime.TemplateProxyFactory$InvalidComponentNameException: The name .Pagination is not a valid component name.
      at coldfusion.runtime.TemplateProxyFactory.resolveName(TemplateProxyFactory.java:610)
      at coldfusion.runtime.CFPage.createObject(CFPage.java:5704)
      at coldfusion.runtime.CFPage.CreateObject(CFPage.java:5673)
      at coldfusion.runtime.CFPage.CreateObject(CFPage.java:5638)
      at cfE_WebUsers2ecfm1033662156._factor7(E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\E_WebUsers.cfm:132)
      at cfE_WebUsers2ecfm1033662156.runPage(E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\E_WebUsers.cfm:1)
      at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
      at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
      at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
      at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:225)
      at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:51)
      at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
      at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:69)
      at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:52)
      at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
      at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
      at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
      at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
      at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:115)
      at coldfusion.CfmServlet.service(CfmServlet.java:107)
      at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
      at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
      at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
      at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
      at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
      at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
      at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
      at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

<!--- end error example>




This code worked fine, in a previous example. I only changed the directory (as it was given in the example, by the developer) from 'examples' to 'modules' - but apparently, I have missed something else?

thanks for  you help
0
Comment
Question by:btintermedia
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
Comment Utility
> The name .Pagination is not a valid component name.

Well that means reReplace is returning an empty string for some reason.  

Sorry I can't answer your question, since it's really about a regular expressions (not CF). You you may want to add the regex topic to the tags to attract attention from the right experts. Since they may not know CF, I'd suggest outputting all of the paths/variables involved. It'll help you (and them) troubleshoot the problem:

<!--- get the result --->
<cfset paginationPath = reReplace(replace(getDirectoryFromPath(cgi.script_name), "/", ".", "ALL"), "(^\.|\.modules\.?$)", "", "ALL") />

<!--- display all variables --->
<cfoutput>
cgi.script_name = #cgi.script_name#<br>
getDirectoryFromPath(cgi.script_name) = #getDirectoryFromPath(cgi.script_name)#
##paginationPath##.Pagination = "#paginationPath#.Pagination#"<br>
</cfoutput>

Open in new window


Best of luck!
0
 

Expert Comment

by:Nebukad
Comment Utility
<cfset pagination = createObject("component", "#paginationPath#.Pagination").init() />

Open in new window

should be
<cfset       pagination = createObject("component", "#paginationPath#Pagination").init() />

Open in new window


On a side note you could also do
<cfset paginationPath = expandPath('./')>
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now