• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1521
  • Last Modified:

Processing a Coldfusion cfform within a CFWindow.

There seems to be some redirection issue when processing a cfform within a cfwindow.

I have a list product page where I execute cfwindow code to delete a product. The code looks like this:

onclick="ColdFusion.Window.create('popupWindow#ProductID#','Alert!','/folderA/folderB/WindowSource.cfm?ProductID=#URLEncodedFormat(ToString(Productid))#',{x:100,y:100,height:300,width:400,modal:true,closable:false,draggable:false,resizable:false,center:true,_cf_refreshOnShow:true})" />  


Then the WindowContent page contains:

<cfif NOT isDefined("FORM.btnDelete")>

	<cfoutput>
	<!--- code to decrypt URL.ProductID --->
        Are you sure you would like to delete: <br>
        #decryptedProductName#?

	<cfform name="deleteForm" mehtod="post">
		<cfinput type="hidden" name="hiddenProduct" value="#URL.ProductID"#>
		<cfinput type="button" name="btnDelete" value="Yes" onClick="this.form.submit();">
	</cfform>
	<input type="button" onClick="javascript:Coldfusion.Window.hide('popupWindow#URL.RecordID#');" name="btnNo" value="No">
	</cfoutput>

<cfelse>

	<!--- // cfquery to delete specific record // --->

	<html>
	<head>
			<cfoutput>
				<script>
					closeTheWindow = function() {
					location.reload();
					ColdFusion.Window.hide('popupWindow#FORM.hiddenProduct#');
					}
				</script>
    			</cfoutput>

	</head>
	<body>

		<cfset AjaxOnLoad("closeTheWindow")> 
 	</body>
 	</html>

</cfif>

Open in new window


----------------------------------------------------------

Whenever I press the 'Yes' button the form submits and the browser opens up the WindowContent page.
It does not close the window and it does not delete the record.

Can someone offer an example of the correct way to use cfform withing a cfwindow?
0
Garbonzo_Horowitz
Asked:
Garbonzo_Horowitz
  • 3
  • 2
  • 2
2 Solutions
 
gdemariaCommented:

Not sure what all the code you're using is for, but cfform posts asynchronously within the cfwindow.

This will post within the window...

<cfform action="...thepath..">
    <input type="submit" name="doDelete" value=" Delete ">
</cfform>

Process the page and close the window...

0
 
Garbonzo_HorowitzAuthor Commented:
Thank you for your reply gdemaria.

I tried that with #cgi.script_name# in the action but it still opend up window content page.

Is that how you would do it?

0
 
gdemariaCommented:

Take the contents of your cfwindow and place it in a separate file...

 DeletePopUp.cfm

Inside that file... place your action at the top...

<cfif isDefined("form.doDelete")>
    ... process the delete..
    <script>
       close the window
     </script>
</cfif>


In your example, you are using this path...

  '/folderA/folderB/WindowSource.cfm?ProductID=#Productid#'

So in your example, this would also be the action for the cfform





And place the form below...


Your form's action path should be a relative path to this file "DeletePopUp.cfm"



0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Garbonzo_HorowitzAuthor Commented:
Are you saying I should include the new DeletePopUp.cfm in the WindowSource.cfm file or are you asking me to not use the WindowSource.cfm file?

I don't see the difference if you mean for me to include the DeletePopUp.cfm page.

Can you please elaborate just a little bit more on what you want me to separate out?

Perhaps it would be better if I explained a little bit further myself.

Please check out the files I included. "Explaination.txt" and "DeletePopUp.cfm".
Explaination.txt
DeletePopup.txt
0
 
_agx_Commented:
> <cfinput type="button" name="btnDelete" value="Yes" onClick="this.form.submit();">

Use a regular "submit" button. I think this.form.submit() bypasses some of the CF ajax stuff and that may be why it's not working as you expect.





0
 
Garbonzo_HorowitzAuthor Commented:
The forms action page had to point to the parent page and not the windowcontent page. Also I changed the this.form.submit to a regular submit.

Thank you for your help.
0
 
_agx_Commented:
> The forms action page had to point to the parent page and not the windowcontent page

Technically it doesn't have to. You can post the cfwindow form to itself. But since you probably want to refresh the parent list after deleting the record, posting to parent makes more sense.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now