Link to home
Start Free TrialLog in
Avatar of btintermedia
btintermedia

asked on

finding and implementing path in cf for cfcomponent

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
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nebukad
Nebukad

<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('./')>