School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,143 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,752 people online right now. Registration is fast and FREE... Join Now!




Passing Complex values into a CFC through a form

 

Passing Complex values into a CFC through a form

xheartonfire43x

29 Apr, 2009 - 09:17 AM
Post #1

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 267



Thanked: 2 times
My Contributions
I have a form that I am passing to a CFC for the action page. I store all of my datasource information in the application.cfm. I know that application variables don't carry over so I store my datasource info in an array (array[1] = datasource, array[2] = username, and array[3] = password). I know that normally with CFC's as action pages you use hidden fields in the form to pass values in, just as you would with arguments in regular CFC useage. I need to pass that array into my CFC. Is there another way to do it?

CODE

<cfform method="post" action="ticket_engine.cfc?method=addtick"  name="form1" skin="HALOBLUE" >
     <input type="hidden" name="method" value="addTick">
     <cfinput type="hidden" name="cat" value="#cat#">
     <cfinput type="hidden" name="username" value="#session.myusername#">
     <cfinvokeargument name="dbarray" value="#dbarray#">




User is offlineProfile CardPM
+Quote Post


apendrag0n3

RE: Passing Complex Values Into A CFC Through A Form

3 May, 2009 - 07:01 AM
Post #2

New D.I.C Head
*

Joined: 3 May, 2009
Posts: 6



Thanked: 1 times
My Contributions
Not sure what you mean by "application variables don't carry over" - if you are using CF8. I set my dsn in the Application.cfc in and call them from inside my component functions all the time - no need to pass them from inside a form.


QUOTE(xheartonfire43x @ 29 Apr, 2009 - 09:17 AM) *

I have a form that I am passing to a CFC for the action page. I store all of my datasource information in the application.cfm. I know that application variables don't carry over so I store my datasource info in an array (array[1] = datasource, array[2] = username, and array[3] = password). I know that normally with CFC's as action pages you use hidden fields in the form to pass values in, just as you would with arguments in regular CFC useage. I need to pass that array into my CFC. Is there another way to do it?

CODE

<cfform method="post" action="ticket_engine.cfc?method=addtick"  name="form1" skin="HALOBLUE" >
     <input type="hidden" name="method" value="addTick">
     <cfinput type="hidden" name="cat" value="#cat#">
     <cfinput type="hidden" name="username" value="#session.myusername#">
     <cfinvokeargument name="dbarray" value="#dbarray#">




User is offlineProfile CardPM
+Quote Post

xheartonfire43x

RE: Passing Complex Values Into A CFC Through A Form

4 May, 2009 - 05:25 AM
Post #3

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 267



Thanked: 2 times
My Contributions
QUOTE(apendrag0n3 @ 3 May, 2009 - 07:01 AM) *

Not sure what you mean by "application variables don't carry over" - if you are using CF8. I set my dsn in the Application.cfc in and call them from inside my component functions all the time - no need to pass them from inside a form.


I use application.cfm files so maybe that is it, but application.cfm variables don't carry over into cfc's.
User is offlineProfile CardPM
+Quote Post

apendrag0n3

RE: Passing Complex Values Into A CFC Through A Form

4 May, 2009 - 05:38 AM
Post #4

New D.I.C Head
*

Joined: 3 May, 2009
Posts: 6



Thanked: 1 times
My Contributions
Are you using CF7? If not - and you are using 8 and can convert to the Application.cfc - I would. I know the application level variables are read by my CFC's - I simply address them like #application.xxx# - so - say a function in my CFC runs a DB query - my query line looks like:
CODE

<cfquery datasource="#application.dsn#" name="blarg>
SQL STUFF HERE
</cfquery>


Also, when passing a form to a CFC function - I make the form action an actual page - and invoke the function from that page:

Example:

CODE

<cfform name="thisForm" method="post" action="procPage.cfm">



Then on procPage, I send the whole FORM structure to the CFC:

CODE

<cfinvoke component="cfcs/appUtil.cfc" method="formProc">
    <cfinvokeargument name="theForm" value="#FORM#">
</cfinvoke>


Then my function would expect an argument of a type="structure" and handle accordingly.

Does this make sense?


QUOTE(xheartonfire43x @ 4 May, 2009 - 05:25 AM) *

QUOTE(apendrag0n3 @ 3 May, 2009 - 07:01 AM) *

Not sure what you mean by "application variables don't carry over" - if you are using CF8. I set my dsn in the Application.cfc in and call them from inside my component functions all the time - no need to pass them from inside a form.


I use application.cfm files so maybe that is it, but application.cfm variables don't carry over into cfc's.


This post has been edited by apendrag0n3: 4 May, 2009 - 05:48 AM
User is offlineProfile CardPM
+Quote Post

xheartonfire43x

RE: Passing Complex Values Into A CFC Through A Form

4 May, 2009 - 05:52 AM
Post #5

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 267



Thanked: 2 times
My Contributions
QUOTE(apendrag0n3 @ 4 May, 2009 - 05:38 AM) *

Are you using CF7? If not - and you are using 8 and can convert to the Application.cfc - I would. I know the application level variables are read by my CFC's - I simply address them like #application.xxx# - so - say a function in my CFC runs a DB query - my query line looks like:
CODE

<cfquery datasource="#application.dsn#" name="blarg>
SQL STUFF HERE
</cfquery>


Also, when passing a form to a CFC function - I make the form action an actual page - and invoke the function from that page:

Example:

CODE

<cfform name="thisForm" method="post" action="procPage.cfm">



Then on procPage, I send the whole FORM structure to the CFC:

CODE

<cfinvoke component="cfcs/appUtil.cfc" method="formProc">
    <cfinvokeargument name="theForm" value="#FORM#">
</cfinvoke>


Then my function would expect an argument of a type="structure" and handle accordingly.

Does this make sense?



That does make sense. That will also let me push in application variables from my application.cfm. I know I need to convert over to using application.cfc, but my boss is still trying to use CF5 coding sometimes so he has no idea how to handle cfc's
User is offlineProfile CardPM
+Quote Post

apendrag0n3

RE: Passing Complex Values Into A CFC Through A Form

4 May, 2009 - 05:57 AM
Post #6

New D.I.C Head
*

Joined: 3 May, 2009
Posts: 6



Thanked: 1 times
My Contributions
OUCH! CF5?!?!?! Wow - are wew trying to be backwards compatible with an existing app written in 5 - or has the boss just not come up the learning curve from the CF5 days. I started back in the CF 3.1 days - and I know the curve is steep if you don't keep on top of it.


QUOTE(xheartonfire43x @ 4 May, 2009 - 05:52 AM) *

QUOTE(apendrag0n3 @ 4 May, 2009 - 05:38 AM) *

Are you using CF7? If not - and you are using 8 and can convert to the Application.cfc - I would. I know the application level variables are read by my CFC's - I simply address them like #application.xxx# - so - say a function in my CFC runs a DB query - my query line looks like:
CODE

<cfquery datasource="#application.dsn#" name="blarg>
SQL STUFF HERE
</cfquery>


Also, when passing a form to a CFC function - I make the form action an actual page - and invoke the function from that page:

Example:

CODE

<cfform name="thisForm" method="post" action="procPage.cfm">



Then on procPage, I send the whole FORM structure to the CFC:

CODE

<cfinvoke component="cfcs/appUtil.cfc" method="formProc">
    <cfinvokeargument name="theForm" value="#FORM#">
</cfinvoke>


Then my function would expect an argument of a type="structure" and handle accordingly.

Does this make sense?



That does make sense. That will also let me push in application variables from my application.cfm. I know I need to convert over to using application.cfc, but my boss is still trying to use CF5 coding sometimes so he has no idea how to handle cfc's


User is offlineProfile CardPM
+Quote Post

apendrag0n3

RE: Passing Complex Values Into A CFC Through A Form

4 May, 2009 - 07:02 AM
Post #7

New D.I.C Head
*

Joined: 3 May, 2009
Posts: 6



Thanked: 1 times
My Contributions
Let me know if I can be of any help.

QUOTE(apendrag0n3 @ 4 May, 2009 - 05:57 AM) *

OUCH! CF5?!?!?! Wow - are wew trying to be backwards compatible with an existing app written in 5 - or has the boss just not come up the learning curve from the CF5 days. I started back in the CF 3.1 days - and I know the curve is steep if you don't keep on top of it.


QUOTE(xheartonfire43x @ 4 May, 2009 - 05:52 AM) *

QUOTE(apendrag0n3 @ 4 May, 2009 - 05:38 AM) *

Are you using CF7? If not - and you are using 8 and can convert to the Application.cfc - I would. I know the application level variables are read by my CFC's - I simply address them like #application.xxx# - so - say a function in my CFC runs a DB query - my query line looks like:
CODE

<cfquery datasource="#application.dsn#" name="blarg>
SQL STUFF HERE
</cfquery>


Also, when passing a form to a CFC function - I make the form action an actual page - and invoke the function from that page:

Example:

CODE

<cfform name="thisForm" method="post" action="procPage.cfm">



Then on procPage, I send the whole FORM structure to the CFC:

CODE

<cfinvoke component="cfcs/appUtil.cfc" method="formProc">
    <cfinvokeargument name="theForm" value="#FORM#">
</cfinvoke>


Then my function would expect an argument of a type="structure" and handle accordingly.

Does this make sense?



That does make sense. That will also let me push in application variables from my application.cfm. I know I need to convert over to using application.cfc, but my boss is still trying to use CF5 coding sometimes so he has no idea how to handle cfc's



User is offlineProfile CardPM
+Quote Post

ComboAlex

RE: Passing Complex Values Into A CFC Through A Form

12 Aug, 2009 - 07:01 AM
Post #8

New D.I.C Head
*

Joined: 31 Jul, 2009
Posts: 25


My Contributions
Hi there!

I am having a similar problem and I am stuck because a small stupid thing... please, could you check out my problem here? Thank you a lot.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 03:34PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month