Raymond Camden's Blog Rss

Small update to LighthousePro

13

Posted in ColdFusion | Posted on 02-18-2008 | 3,809 views

Just a quick note to say I released a minor update to Lighthouse Pro. This last update has a few changes, but the main one is that if you are editing an issue and let your session timeout, after you login your changes are preserved. So if you had entered some lengthy notes, timed out, hit Save, when you login, you changes to the issue are preserved and stored.

There are a few ways you can do this, but here is how I did it. Also note I was only only concerned about people timing out in an issue edit. First off, in login.cfm, I look for a form post from the issue editor:

view plain print about
1<cfif structKeyExists(form, "issuetypeidfk")>
2    <cfset session.issueform = duplicate(form)>
3</cfif>

Then back in view.cfm, the file that handles editing issues, I simply added:

view plain print about
1<cfif structKeyExists(session, "issueform")>
2    <cfset structAppend(form, session.issueform)>
3    <cfset structDelete(session, "issueform")>
4</cfif>

Note that I clear out the session data. This is important so as to not keep restoring the edits for future editing.

Comments

[Add Comment] [Subscribe to Comments]

Excellent! My coworker had some issues with this previously (much swearing and shouting ensued which we could usually tell came from a long form post and was welcomed with a "Please login" screen). He was ecstatic :) I use Firefox, so I was able to keep my form posts when I clicked back, so it wasn't too much of an issue for me, but it will definitely be a nice addition.
I have not used Litehouse and i am not familar with the code.

How does the form variable still exists when you get sent to the login screen? If you were to do a cflocation and send them to the login page the form variable would not exist. Is login displayed in the application.cfm file if the user's session is old?
I use a cfinclude to load in the login page.
Hey Ray,
I added this code to our server (removed the old code and put the new files up on the server). Everything works great except for the "Reports" page. It works nicely in Firefox, but IE is throwing JS errors. I would troubleshoot it myself, but I figured there may be something quick and easy I'm missing. The 2 stats.cfm pages look to be exactly the same, so I'm not sure what changed from the last version to this one. The errors received are:
Line: 98 (and 117, 136, 155, 174)
Char: 1
Error: Object Expected
Code: 0
URL: http://myurl/stats.cfm

Any ideas?
Thanks.
Anyway you can send me your URL?
I would love to but the site is hosted internally :( As they're all JS errors, would saving the HTML page be enough?
Sure.
Looking at it again, I'm guessing it's this "/CFIDE/scripts/CF_RunActiveContent.js" This file does not exist, but I wasn't sure what CF was including to get that to show up (plus another guy set up the old LighthousePro, but I figured if I left the default.cfm alone and just copied over all of the other files, I'd be OK...but apparently not quite).
Yup, that was it. We've got some strange setup with CF here, so I just created a new CFIDE/scripts folder under the actual web directory (not the best way to do it, I know) and put the .js file in there and everything's working correctly now.
I have the same issue - I was able to use your code to successfully save forms, BUT it will not save uploaded files (like if i had a form for a file attribute on it).

Everything else gets saved except the attachment.... any ideas?
Check out how BlogCFC does it. I believe I actually delete the file but warn the user so they can reupload it.
Hmmm - does that mean there is no way to do it?

I suppose i could just allow the images to be uploaded and stored in a temp file, and then put some info in the session to move/rename the files after the form was ultimately submitted.

However that sounds a bit complex, since it would have to handle multiple forms, and I'd probably also have to create some cleanup functionality since some people inevitably would not finish their forms.
Well sure you can handle it - you just need to ensure you do the cleanup later if the user doesn't actually login again. In that first code block, just imagine a check against form.somefile, where form.somefile is a fileupload. If a value is there, process the upload, and after the user logs in, then you can do whatever you want to with it.

It's definitely possible, just non-trivial.

[Add Comment] [Subscribe to Comments]