Solved

finding and implementing path in cf for cfcomponent

Posted on 2013-01-19
2
208 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
ID: 38797540
> 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
ID: 38802680
<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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 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