I've been searching for hours for an answer to this issue and have been unable to find an answer that works for me anywhere. I have been using the same method to invoke actions from cfc's, but in this instance it doesn't seem to work.
This is CF9 with cfWheels 1.1.6
I have the form:
<form action="index.cfm?controller=QmAdmin&action=add-document" method="POST" id="addDocument" name="add" onsubmit="return submitForm(this.id);">
<input type="text" id="addDocumentName" name="name" />
<input type="text" id="addDocumentLink" name="link" />
<input type="text" id="addDocumentDetails" name="details"/>
<select name="parentid" id="addDocumentParent">
</select>
<input type="submit" name="submit" class="btn" value="Add"/>
</form>
The action within QmAdmin.cfc however is never reached when the submit button is clicked. I've added logging within the action to check and it is never reached. I just get a Wheels error page with:
Wheels.ViewNotFound
Could not find the view page for the addDocument action in the Qmadmin controller.
The action is definitely there, and using a <cfinvoke component="controllers.QmAdmin" method="addDocument"/>
invocation (with the correct arguments) will work fine.
action as requested:
<cffunction name="addDocument" access="remote">
<cfargument name="name" type="String">
<cfargument name="link" type="String">
<cfargument name="details" type="String">
<cfargument name="parentid" type="numeric">
<cftry>
<cfquery name="addDocument">
INSERT INTO BLANK.DOCUMENTS (ID, NAME, LINK, DETAILS, PARENT)
VALUES (BLANK.SQ_DOCUMENTS_ID.NEXTVAL,
<cfqueryparam value="#name#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#link#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#details#" cfsqltype="cf_sql_varchar">,
<cfqueryparam value="#parentid#" cfsqltype="cf_sql_numeric">)
</cfquery>
<cfcatch type="any">
<cfset flashInsert(error="An error occured, no changes were made")>
<cfset redirectTo(controller="qmadmin", action="qmsadmin")>
</cfcatch>
</cftry>
<cfset flashInsert(message="Successfully added document")>
<cfset redirectTo(controller="qmadmin", action="qmsadmin")>
</cffunction>
I've tried clearing the caches in the coldfusion administrator, altered capitalisation, changed the formatting of the form invocation to QmAdmin.cfc?method=addDocument&arg1=&arg2= etc.
Directly using the url in the browser returns the same error page.
This error only started occurring recently which makes me think that it must be something configurable that's causing it, but I'm fairly new to coldfusion so just can't pin it down.
It turns out that this may be down to some sort of caching bug. The first reference to the controller that loaded the page with the forms used controller=qmadmin
(lowercase) and somehow the caching is preventing subsequent requests to controller=QmAdmin
from working.
Switching to design mode in wheels disabled the caching and it started to work again. Following that adjusting the initial call to the controller to controller=QmAdmin
seems to have resolved the issue.