1

I am using javascript to control the creation of a cfwindow object in ColdFusion.

The cfwindow is attached to a form that allows users to choose a signle or multiple records and assign or unassign them to a single record.

Most forms in cfwindow provide the user with the ability to enter form elements and then submit, then the window is destroyed and the parent window is refreshed displaying the results. In my case, the user may perfrom multiple submissions in the window object before being done.

The flow is as this:

  1. User open record.
  2. User clicks button which is bound to the creation of the cfwindow object.
  3. The user assigns or unassigns records to the parent record.
  4. The cfwindow object refreshes upon each submit of the assignment.
  5. User closes (destroys) the window object using the close button.
  6. The parent window refreshes.

Now, I have everything, but #4 working. The window does refresh; however, it does not show the changes (assigned or unassigned) records. I confirmed that the data layer works and changes are made to the table; however, it is not displayed to the user.

So, I need some help with the onSuccess control of the form. BTW, I am using cfform.

Here are my code samples. If you look at the bottom of addedit.cfm you will see code for cfmodule. This page is the same as cfassign.cfm. The only difference is that I created a new form since cfwindow does not allow the same form to be used between parent and child, when cfmodule does.

addedit.cfm

 <!------------------------------------------------------------------

ATTRIBUTES ------------------------------------------------------------------->

---> ---> Administration Information Course ID Date Record Created Created By Date Updated Updated By Training Course Information • Course Code • Course Title Course Description ( 200 Character Limit ) ---> • Category . . . Select From List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Frequency . . . Select From List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Status . . . Select From List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • Training Method . . . Select From List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Duration Course Cost • Initial Required Yes No • Launch Required Yes No Comments ( 200 Character Limit ) function cleanup() { //when onHide, destroy the contents of cfwindow ColdFusion.Window.destroy('prerequisite',true); //reload the parent page to display changes window.location.reload(); } function showWin(id) { //do we have one? try {ColdFusion.Window.destroy('prerequisite',true); } catch(e) { } ColdFusion.Window.create('prerequisite','Assign Pre-requisites for #qryCourses.Course_Title#','cfassign.cfm?id='+id,{height:400,width:1150,modal:false,refreshOnShow:true}); //Assign variable when getting window object ob=ColdFusion.Window.getWindowObject('prerequisite_body'); //Command to force the center of the window ob.center(); //Cleanup the window when closed ColdFusion.Window.onHide('prerequisite',cleanup); } cfassign.cfm --->
<cfif StructKeyExists(form, "btnUnassignCourses") and StructKeyExists(form, "AssignedCourses") and len( form.AssignedCourses ) gt 0>
    <!--- Remove courses as pre-requisites from the parent course. --->
        <cfquery name="RemoveCoursePrerequisite" datasource="#Request.App.DSN#" >

        </cfquery>

<cfelseif StructKeyExists(form, "btnAssignCourses") and StructKeyExists(form, "UnassignedCourses") and len( form.UnassignedCourses ) gt 0>
    <!--- Add course as pre-requisites for the parent course. --->
        <cfquery name="AddCoursePrerequisite" datasource="#Request.App.DSN#" >

        </cfquery>
</cfif>

         <table>
             <tr>
                 <div class="ModuleFullName">
             <td>
                <div class="fieldWrapperControl">
                    <label>Assigned Courses (#qryAssignedCourses.Recordcount#)</label>
                    <cfselect
                        name="AssignedCourses"
                        style="font-size:.8125em; height:200px; width:500px;"
                        query="qryAssignedCourses"
                        display="Course_Description"
                        value="ID"
                        queryposition="below"
                        editable="no"
                        multiple="true">
                    </cfselect> 
                </div>

            </td>
            <div class="fieldWrapperButton">
            <td style="vertical-align:middle;">

                <cfinput type="submit" name="btnAssignCourses" value="<<" style="display:block;" />
                <cfinput type="submit" name="btnUnassignCourses" value=">>" style="display:block;" />
            </td>

            </div>
            <td>
                <div class="fieldWrapperControl">
                    <label>Unassigned Courses (#qryUnassignedCourses.Recordcount#)</label>
                    <cfselect
                        name="UnassignedCourses"
                        style="font-size:.8125em; height:200px; width:500px;"
                        query="qryUnassignedCourses"
                        display="Course_Description"
                        value="Unassigned_ID"
                        queryposition="below"
                        editable="no"
                        multiple="true">
                    </cfselect> 
                </div>
            </td>
            </tr>
            <tr>
                <td colspan="3" style="font-size:.9em;"><label>** Press and hold down the Ctrl OR Shift key to select multiple courses.</label></td>
            </tr>
            </table>

vasquezmi
  • 41
  • 2
  • 5
  • It would help to see some code, but if you are doing a regular form submit then the whole page is going to be submitted as the form is part of the overall page. I believe you are looking for a submit via ajax. – Sean Coyne Dec 18 '10 at 16:54
  • 1
    @Sean: If using cfform and a cfdiv or cfwindow then the submission will be via AJAX. @Vasquezmi: Can you post some code? My guess is you may need to use ColdFusion.navigate() – Sam Farmer Dec 18 '10 at 21:37

2 Answers2

1

in this case i think refreshonshow doesnot work since you want your window to be refreshed on submit. So call some function from the child window . And code for that child window must exist in script part of parent window.

In my situation i used this way hope this may be helpful.

function test(name) 
{
    ColdFusion.Window.hide(name);
    window.location.reload();
}

So i have given a button called hide window in my child window and when this button is clicked test() function will be activated due to this code in child window.

onClick="javascript:test('#url.empname#')"
uvk
  • 43
  • 7
1

I blv you should add the attribute refreshonShow="true" in your cfwindow

Yoosaf Abdulla
  • 3,722
  • 4
  • 31
  • 34