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

Welcome to Dream.In.Code
Become an Expert!

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




CFWindow taking over

 

CFWindow taking over

xheartonfire43x

2 Jul, 2009 - 06:28 AM
Post #1

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 267



Thanked: 2 times
My Contributions
I have a CFWindow that opens up in my contact managment application so that the user can add the contact to "groups" (by company, family, friends, whatever) So I have 2 select drop-down lists with 2 submit buttons in the center. The form submits to an engine and then back to the CFWindow. Problem is that after the user submits the form once the second time they try the CFWindow takes up the entire browser window. I am not sure why.

window_editgroups.cfm
CODE

<cfform action="/CRE/common/engine.cfm" method="post">
    <input type="hidden" name="process" value="editgroups">
    <cfinput type="hidden" name="member_id" value="#URL.id#">
    <cfif isDefined('URL.nogroup') AND URL.nogroup EQ "Y">
        <tr>
            <th colspan="3"><span class="requiredfield">You must specify a group to add/remove.</span></th>
        </tr>
    <cfelseif isDefined('URL.error') AND URL.error EQ "Y">
        <tr>
            <th colspan="3"><span class="requiredfield">There was an error processing your request.  Please try again.</span></th>
        </tr>
    <cfelseif isDefined('URL.member') AND URL.Member EQ "Y">
        <tr>
            <th colspan="3"><span class="requiredfield">Already a member of that group.</span></th>
        </tr>
    </cfif>
    <tr>
        <th>Contact's Groups</th>
        <th>&nbsp;</th>
        <th>Available Groups</th>
    </tr>
    <tr>
        <td>
            <cfselect name="groupRemove" query="getMemberGroups" display="name" value="id" size="10" width="75" multiple="true" style="width:150px;"></cfselect>
        </td>
        <td valign="middle">
            <cfinput type="button" name="remove" value=">>"><br />
            <cfinput type="submit" name="add" value="<<">
        </td>
        <td>
            <cfselect name="groupAdd" query="getOtherGroups" display="name" value="id" size="10" width="75" multiple="true" style="width:150px;"></cfselect>
        </td>
    </tr>
    <!---<tr>
        <th colspan="3"><input type="button" name="close" value="Close" onClick="ColdFusion.Window.hide('EditGroups');"></th>
    </tr>--->
</cfform>


engine.cfm
CODE

        <cfdump var="#FORM#">
        <!--- No group selected --->
        <cfif NOT isDefined('FORM.groupadd') AND NOT isDefined('FORM.groupRemove')>
            <cflocation url="/CRE/contacts/window_editgroup.cfm?nogroup=Y&id=#FORM.member_id#">
        <!---For adding a group --->
        <cfelseif isDefined('FORM.add')>
            <cfquery name="checkGroup" datasource="#CRE_Userdatabase#" username="#CRE_Username#" password="#CRE_password#">
                SELECT id FROM groupmembers
                WHERE contact_id = <cfqueryparam value="#FORM.member_id#">
                    AND group_id = <cfqueryparam value="#FORM.groupadd#">
            </cfquery>
            <cfif checkGroup.recordcount LT 1>
                <cfquery result="addGroupMember" datasource="#CRE_Userdatabase#" username="#CRE_username#" password="#CRE_password#">
                    INSERT INTO groupmembers(group_id,contact_id)
                    VALUES(<cfqueryparam value="#FORM.groupadd#">,
                        <cfqueryparam value="#FORM.member_id#">)
                </cfquery>
            <cfelse>
                <cflocation url="/CRE/contacts/window_editgroup.cfm?id=#FROM.member_id#&member=Y">
            </cfif>
        <!--- For removing from group --->
        <cfelseif isDefined('FORM.remove')>
            <cfquery name="removeGroupMember" datasource="#CRE_Userdatabase#" username="#CRE_username#" password="#CRE_password#">
                DELETE FROM groupmembers WHERE id = <cfqueryparam value="#FORM.groupremove#">
            </cfquery>
        </cfif>
        <cflocation url="/CRE/contacts/window_editgroup.cfm?id=#FORM.member_id#">
    </cfcase>


User is offlineProfile CardPM
+Quote Post


xheartonfire43x

RE: CFWindow Taking Over

6 Jul, 2009 - 09:19 AM
Post #2

D.I.C Regular
***

Joined: 22 Dec, 2008
Posts: 267



Thanked: 2 times
My Contributions
So I found out that ColdFusion's CFWindow and other Ajax layout tags will always do this. That is just the way they work. The way that I fixed it was to put the form submission at the top of the page and do it that way.
User is offlineProfile CardPM
+Quote Post

_Leonard_

RE: CFWindow Taking Over

10 Sep, 2009 - 12:46 AM
Post #3

New D.I.C Head
*

Joined: 7 Sep, 2009
Posts: 11


My Contributions
QUOTE(xheartonfire43x @ 6 Jul, 2009 - 09:19 AM) *

So I found out that ColdFusion's CFWindow and other Ajax layout tags will always do this. That is just the way they work. The way that I fixed it was to put the form submission at the top of the page and do it that way.


I use cfwindow quite a bit in my development and if I understand what it is you are trying to accomplish, perhaps using this concept might work for you. I will try to explain how it is I use cfwindow and perhaps you can take the concept and mold it into yours.

Keep all your code/process on a single .cfm page and break it up with <cfelseif IsDefined> sections. By using this process, I was able to keep an entire operation functioning within a <cfwindow>. If you need to do a second process, add a <cfelseif IsDefined> that contains the exact code as when they first started. Then when they proceed from this point, it would be as if they were starting all over again.

Like I said if I understand what it is your are trying to accomplish, this might get you on the right track with <cfwindow>. This is how I have worked around the quirkyness of <cfwindow>.

Leonard

Something like this.

CODE

<cfif IsDefined('form.btn_whatever')>

<!--- Code / content here  --->

<cfelseif IsDefined('form.btn_whatever')>

<!--- Code / content here  --->

<cfelseif IsDefined('form.btn_whatever')>

<!--- To escape db functions/activity, I escape
the process with a <cflocation> tag like such.--->

<cflocation url="this_doc.cfm?ops_status=Successful" addtoken="no">

<cfelseif IsDefined('url.ops_status') AND Trim(url.ops_status) eq "Successful">

<!--- Then finish off with things --->

<cfelse>

<!--- Start content here --->

</cfif>

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 05:26PM

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