Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Question about action from a button

Guest
Apr 20, 2011 Apr 20, 2011

I have an html form (didn't see the need for CFFORM in this instance) and I have a button that is to call

a method.  I am not sure whether to do it from either javascript or cfscript or even a cffunction.  The

issue is (this client/server thing is a serious pain to an old embedded systems developer) that

I have declared and set a session variable (a list).  So, the thing is I have to loop through this

list and send the values to another form for processing.

Question is, should I do this in javascript (which doesn't really like session variables), cfscript,

or a cffunction?  I know server side constructs are more costly and all, but in looking at it,

javascript will be a bear to use with all the stuff on the server side.

So, help, please?   Thanks in advance.

863
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 20, 2011 Apr 20, 2011

It depends on where the method is written and what you want the user to experience while it is running and after it is finished.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2011 Apr 20, 2011

OK, here's the thing.  I need a way to access the session variable.  That's it.  I want the easiest way.  The development system I

am using does not have jQuery on it.  I would have to install it on there and update install docs if it is necessary.  If I can do it

easily enough without using it then my job is easier.  If I must use Ajax and such, then I have to install it, etc.  I'd like to know

the best way and some tips on how to do this.  Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 20, 2011 Apr 20, 2011

You can access session variables with Cold Fusion.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 21, 2011 Apr 21, 2011

Yes, but that's not the answer to my question.  The answer, after looking into it, are hidden fields.  Only way.  I don't

want to install jquery.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 21, 2011 Apr 21, 2011

So, that being said, if I have a session variable called "session.foo", and a hidden input called "Form.myinput", how

can I set that "Form.input" to the value of the session variable?  I tried the <CFSET Form.myinput = session.foo> but

that isn't working.

I don't want to have to do request after request.  All I want is to keep the hidden field updated with the value with the

session variable after it's set.  This way I (in theory) can grab values from the hidden fields with my "on click" method.

So, please, no one line general answers.  I seriously need to get this done, and if I had access to the full google, I

wouldn't be pestering you here.

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 21, 2011 Apr 21, 2011

edsarro1 wrote:

I don't want to have to do request after request. 

You may not WANT to but you HAVE to.  It sounds like you want to update the hidden form field on the CLIENT with data in the session scope on the SERVER.

The client and the server are two different computers with two different sets of ram chips that can be seperated by thousands of miles.  The only way, using basic HTTP protocols to get data from one to the other is with a REQUEST.

Now, using techniques like frames and|or ajax you can make those requests in such a manner that they do not cause the page to refresh.

If you go beyond the HTTP into a client that will maintain a connection with the server, such as Flash|Flex|Air you have a little more control of the pushing and pulling of data between the client and the server.

But when building Client|Server applications one must always be aware on what the client does, what the server does, and how data gets back and forth between them.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 21, 2011 Apr 21, 2011

OK ilssac, I understand that part.  However, my session variable gets updated when I do submit the page.

The issue is, I can't just submit again.  When that server field gets updated, then I need that form field

to update.  So yea, I'm in a pickle.  The issue is a user can select Next, then the page submits, and I

get data in the Session variable.  I wanted then upon a user clicking the SUBMIT button to get those

session vars and open up a new webpage using those session variables.  I was trying to do that by

setting a hidden field.

It appears what you are telling me is that I can't do this, and that I am forced to use the jQuery library

and use Ajax.  So, if I am FORCED to go that route, then can the Coldfusion server recognize the

jQuery library?  I would assume so.  Believe me, it would become a royal pain if I had to move

everything over to Apache and JRun.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 21, 2011 Apr 21, 2011
LATEST

edsarro1 wrote:

I wanted then upon a user clicking the SUBMIT button to get those

session vars and open up a new webpage using those session variables.  I was trying to do that by

setting a hidden field.

You DO NOT NEED to set hidden fields to get session data when the use clicks SUBMIT under nomal conditions.  A form SUBMIT is going to be a new request to the server where the SESSION variables are already located.  That is pretty much the whole point of the session scope, to maintain data from request to request.  You would then just use the session data on the form action page to do what you desire to do.

edsarro1 wrote:

It appears what you are telling me is that I can't do this, and that I am forced to use the jQuery library

and use Ajax.  So, if I am FORCED to go that route, then can the Coldfusion server recognize the

jQuery library?  I would assume so.  Believe me, it would become a royal pain if I had to move

everything over to Apache and JRun.

First of all jQuery is not the ONLY game in time.  One of the most popular, yes, but not the only game.  Including rolling your own ajax functionality because it really is not all that difficult to do.

NO ColdFusion does not "recognize" the jQuery library because it has NOTHING to do with it.  jQuery is a client JavaScript library.  ColdFusion is solely concerned with what goes on with the server.  In fact, one usually does not really "install" jQuery one just puts a line in the HTML page that points a <script...> tag to one of the major jQuery repositories.  But one can copy that to a local server, if one really feels the need to do so.  NOW, on the other hand, using ColdFusion CFML to dynamically make jQuery (or any other JavaScript syntax) to be sent to the client browser, just like it dynamically makes HTML to send to the browser, is a VERY POWERFUL ability.

I'm not sure why Apache and JRun are being brought up here.  They are really not hear or there.  ColdFusion is probably already running on JRun, and if Apache is your web server then it would be doing its job as well.

And finally, the latest versions of ColdFusion come with some built in, wizard like tags, that can be used to create some basic AJAX functionality to be used in the client browser.   There are entire chapters in the documentation about it.

But to reiterate.  IF you just want access to the SESSION scope variables at the time the from is submitted, there should be NOTHING special about doing this.  Just <cfoutput>#session.myVar#</cfoutput> on the action page should show this point.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources