Unable to add CSS or JS to FW1

251 views
Skip to first unread message

Pritesh Patel

unread,
Dec 30, 2012, 4:25:43 PM12/30/12
to framew...@googlegroups.com
Pretty much as the title says. I am trying to add a style sheet and a javascript file to my application but unable to do so.

Below is my folder structure:
wwwroot
  |-- assets
  |-- controllers
  |-- layout
  |-- org
  |-- views
  |-- Application.cfc
  |-- index.cfm
  |-- web.config

Inside assets I have two subfolders css and js, each with a file inside them. 

This is what my default.cfm in the layout's folder looks like:
<html>
<head>
<title>My Site</title>
         <link rel="stylesheet" type="text/css" href="/assets/css/style.css" />
         <script type="text/javascript" src="/assets/js/jquery-1.8.3.min.js"></script>
</head>
<body>
<div class="wrap">
        <cfinclude template="include/header.cfm">
<div class="page">
<cfoutput>#body#</cfoutput>
</div>
<cfinclude template="include/footer.cfm">
</div>
</body>
</html>

Application.cfc:
component extends="org.corfield.framework" {
// Either put the org folder in your webroot or create a mapping for it!
// FW/1 - configuration for introduction application:
// controllers/layouts/services/views are in this folder (allowing for non-empty context root):
variables.framework = {
        base = getDirectoryFromPath( CGI.SCRIPT_NAME ).replace( getContextRoot(), '' ),
        generateSES = true ,
        SESOmitIndex = true,
        defaultSection = 'myHome'
};
}

When I look at firebug (net) I see the following error:
<h1>Exception in onError</h1><p>The action assets.css failed.</p><h2>Unable to find a view for 'myHome.error' action.</h2><p>'/views/myHome/error.cfm' does not exist. (FW1.viewNotFound)</p>

What am I doing wrong? Thanking you in advance.

Joe Brislin

unread,
Dec 30, 2012, 4:36:12 PM12/30/12
to framew...@googlegroups.com
I would create an error view within your myHome folder and dump out the exception. FW/1 should not run for CSS files unless your mime types are setup wrong within your web server. There must be something else going on. 

Joe Brislin
BlueRidge Interactive
--
FW/1 on RIAForge: http://fw1.riaforge.org/
 
FW/1 on github: http://github.com/seancorfield/fw1
 
FW/1 on Google Groups: http://groups.google.com/group/framework-one

Sean Corfield

unread,
Dec 30, 2012, 4:43:26 PM12/30/12
to framew...@googlegroups.com
Yup, sounds like a configuration error in your web server, in terms of which requests are routed via CFML. Are you using rewrite rules?
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Jim Priest

unread,
Dec 30, 2012, 4:44:58 PM12/30/12
to framew...@googlegroups.com
On Sun, Dec 30, 2012 at 4:36 PM, Joe Brislin <jgbr...@gmail.com> wrote:
> generateSES = true ,

Do the samples included with the code run OK?

For getting started I'd turn off SES. It almost seems like your code
is trying to parse the

/assets/css/... as

action=assets.css

Jim

Pritesh Patel

unread,
Dec 30, 2012, 4:53:29 PM12/30/12
to framew...@googlegroups.com
Yes, in some of my views I have includes which are working without any issues.

There is rewriting going. 

This is the contents of my web.config file
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".air" mimeType="application/vnd.adobe.air-application-installer-package zip" />
        </staticContent>
        <handlers>
            <add name="JWildCardHandler" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\1\jrun_iis6_wildcard.dll" resourceType="Unspecified" requireAccess="None" />
            <add name="hbmxmlHandler" path="*.hbmxml" verb="*" modules="IsapiModule" scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" />
            <add name="cfswfHandler" path="*.cfswf" verb="*" modules="IsapiModule" scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" />
            <add name="cfrHandler" path="*.cfr" verb="*" modules="IsapiModule" scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" />
            <add name="cfcHandler" path="*.cfc" verb="*" modules="IsapiModule" scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" />
            <add name="cfmlHandler" path="*.cfml" verb="*" modules="IsapiModule" scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" />
            <add name="cfmHandler" path="*.cfm" verb="*" modules="IsapiModule" scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" />
            <add name="jwsHandler" path="*.jws" verb="*" modules="IsapiModule" scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" />
            <add name="jspHandler" path="*.jsp" verb="*" modules="IsapiModule" scriptProcessor="C:\ColdFusion9\runtime\lib\wsconfig\jrun_iis6.dll" resourceType="Either" responseBufferLimit="0" />
        </handlers>
<rewrite>
<rules>
<rule name="Rewriteto index.cfm"> 
<match url="^([a-z]+)/([a-z]+)/([a-z]+)/([0-9]+)" /> 
<action type="Rewrite" url="/index.cfm?action={R:1}.{R:2}&amp;{R:3}={R:4}" /> 
</rule> 
<rule name="Rewriteto.cfm"> 
<match url="^([a-z]+)/([a-z]+)" /> 
<action type="Rewrite" url="/index.cfm?action={R:1}.{R:2}" /> 
</rule> 
<rule name="Rewriteto.cfm default"> 
<match url="^([a-z]+)" /> 
<action type="Rewrite" url="/index.cfm?action={R:1}.default" /> 
</rule> 
</rules>
</rewrite>
    </system.webServer>
</configuration>

I guess there is something wrong with my rewrites.

Sean Corfield

unread,
Dec 30, 2012, 6:59:05 PM12/30/12
to framew...@googlegroups.com
On Sun, Dec 30, 2012 at 1:53 PM, Pritesh Patel <prite...@gmail.com> wrote:
I guess there is something wrong with my rewrites.

Yes, your rewrite rules are catching /assets/css/... and rewriting it to a CF URL with action=...

You need to exclude /assets from the rewrites. Or exclude all static assets URLs (that end in .css .gif .jpg etc etc).

I don't know how to do that with IIS (sorry), only Apache. Hopefully someone else can help you with IIS.

Pritesh Patel

unread,
Dec 31, 2012, 6:56:34 AM12/31/12
to framew...@googlegroups.com
On Sunday, 30 December 2012 23:59:05 UTC, Sean Corfield wrote:
I don't know how to do that with IIS (sorry), only Apache. Hopefully someone else can help you with IIS.

Having done some digging around I have found a solution that works which excludes /assets from rewrites, however someone else can help with a cleaner solution.

<rule name="Rewriteto index.cfm?action={R:1}.{R:2}and{R:3}={R:4}"> 
<match url="^([a-z]+)/([a-z]+)/([a-z]+)/([0-9]+)" /> 
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
<add input="{URL}" pattern="^/(assets)" negate="true"/>
</conditions>
<action type="Rewrite" url="/index.cfm?action={R:1}.{R:2}&amp;{R:3}={R:4}" /> 
</rule> 
<rule name="Rewriteto index.cfm?action={R:1}.{R:2}"> 
<match url="^([a-z]+)/([a-z]+)" /> 
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
<add input="{URL}" pattern="^/(assets)" negate="true"/>
</conditions>
<action type="Rewrite" url="/index.cfm?action={R:1}.{R:2}" /> 
</rule> 
<rule name="Rewriteto index.cfm?action={R:1}.default"> 
<match url="^([a-z]+)" /> 
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
<add input="{URL}" pattern="^/(assets)" negate="true"/>
</conditions>

Chris Blackwell

unread,
Dec 31, 2012, 7:16:31 AM12/31/12
to framew...@googlegroups.com
I've never used iis rewriting, but in apache i don't need multiple rules, or to ignore specific paths, unless theres a really special case.  Simply telling the rewrite engine to ignore anything that is a real file is sufficient.  I would have thought that the following rule, or something similar should be sufficient

<rule name="Rewrite fw/1 requests"> 
<match url="^(.*)$" /> 
<conditions>
<!-- don't rewrite where a file actually exists -->
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<!-- rewrite urls and allow fw/1 to work out the action from cgi.path_info
/index.cfm/section/item/key/value etc..
-->
<action type="Rewrite" url="/index.cfm{R:1}" appendQueryString="true" /> 
</rule> 

You may also need to add an iis handler for *.cfm/*

hope that helps
Chris

--
Reply all
Reply to author
Forward
0 new messages