Description

The cf_window Custom tag allows ColdFusion developers to easily leverage the extjs framework. This tag is a wrapper for the Ext.Window class and makes it easy to create windows. The tag is intended to provide cfwindow functionality to users not on ColdFusion 8. Anyone using ColdFusion 8 could still take advantage of this because it makes use of Ext 2.0 and at the time of this CF8 was still using 1.1. The credit for this project really goes to Jack Slocum (he lives like 10 min from me and I have never met him) and the Ext JavaScript framework team. That is the real code, I am just providing an easier avenue for ColdFusion developers to drive down. Most of the attribute and method descriptions were taking directly from the Ext documentation.

http://extjs.com/


Usage

<cfimport prefix="ext" taglib="cfext">
<html>
<head>
   <title>cf_window Basic Window Example #1</title>
   <ext:include widget="cfwindow"/>
</head>

<body>
   
   <ext:window title="A Basic Window" width="300" height="200">
      I am <strong>html</strong> content for your window
   </ext:window>   
   
</body>
</html>

Attributes

This is a list of tag attributes, the purpose of the attribute and the default value.

cf_window Custom tag attributes
Attribue Purpose Default
Id A name that will be used to uniquely identify the window object. cf_UUID()
Title The text to display in the title bar of the window empty str
Width The width of this component in pixels 0
Height The height of this component in pixels 0
minWidth The minimum width in pixels allowed for this window. Only applies when resizable = true. 100
minHeight The minimum height in pixels allowed for this window. Only applies when resizable = true. 100
initShow A Boolean value that specifies whether to display the window when the containing page first appears. false
resizable True to allow user resizing at each edge and corner of the window, false to disable resizing true
draggable True to allow the window to be dragged by the header bar, false to disable dragging true
maximizable True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button and disallow maximizing the window false
collapsible True to make the panel collapsible and have the expand/collapse toggle button automatically rendered into the header tool button area, false to keep the panel statically sized with no button false
modal True to make the window modal and mask everything behind it when displayed, false to display it without restricting access to other UI elements false
autoScroll True to use overflow:'auto' on the panel's body element and show scroll bars automatically when necessary, false to clip any overflowing content false
closable True to display the 'close' tool button and allow the user to close the window, false to hide the button and disallow closing the window. true
closeAction The action to take when the close button is clicked. The default action is 'close' which will actually remove the window from the DOM and destroy it. The other valid option is 'hide' which will simply hide the window by setting visibility to hidden and applying negative offsets, keeping the window available to be redisplayed via the show method. true
animateTarget Id or element from which the window should animate while opening null
iconCls A CSS class that will provide a background image to be used as the panel header icon null
bodyStyle Custom CSS styles to be applied to the body element padding:5px
centerWindow Centers the window. true
x If centerWindow is false, sets the page x position of the window. 0
y If centerWindow is false, sets the page y position of the window. 0
autoLoad A valid url to load as the content. If autoLoad is not supplied the tag will attempt to load content between the start and end tag. null
source External URL to load in a iframe of the window. null

Examples

Example Description
Basic Example This is an example of how to create a very basic window. The problem with this window is that we have not given it a id. If you do not create an id for the window instance one will be created for you but it is a unique name that you will never know. This example shows how to create a window but you will never be able to display it without knowing the id of the window. View the source of this example so you can see that the tag assigns a unique id to the window. Please move on to the next example.
Show Window on load This example will create the same basic window from our first example. Again you will notice we did not assign it an id so the tag will create one for us, only this time we do not need to know the name of the window because we are using initShow="true" to automatically show the window when the page loads.
Window Id Example If you have been paying attention you should have an understanding of why we need to identify our window. In this example we will give our window a name and then make it visible by using the show() method. It is important to understand that when you show your window and then close it the window has been destryoed and can no longer be used. Later on we will have an example of how to simply "hide" the window instead of destroying it.
Multiple Windows All the examples up to this point have been a single window. This example will show you how to create multiple windows on one page. If you have not guessed yet the only trick to this is giving each windoow a unique name. As a side not because we are not setting any positions in this example they will move on top of eachother but because windows are draggable by default you can move one of the windows out of the way.
Hide On Close As I mentioned earlier every time you create a window and close it you are destroying the window from the dom. There are some times where you may just want to hide the windw. For example your application has an about screen, there is no reason to create and destory this window everytime it is requested. To handle instances like this you can override the close action by setting the closeAction attribute to hide. This will hide the window so you can open and close it has many times as you like
Custom Close In the last example we looked at how we can change the close action to hide. What happens if we close the window and we really do need to destroy the window. Lucky for us their is a built in method close that will destroy the window from the dom. You can prove this theory by showing the window, clicking the close button to hide the window and then clicking the show button to make the window visible again. Now try and show the window and use the close link. You will no longer be able to show the window because it has been destroyed from the dom.
Collapsible Windows If you set the collapsible attribute to true you will see an expand/collapse toggle button automatically rendered into the header tool button area. This is handy when you have multiple windows on a screen and want to provide the user a way to save some screen space by collapsing the window.
Maximizable Window If you set the maximizable attribute to true you will display the 'maximize' tool button and allow the user to maximize the window. When the window is maximized the button will change to a restore button so the user can restore the window to the size it was before maximzing.
Modal Window Modal windows are great because they bring all attention to the window. When a window is modal you are unable to interact with anything else on the screen but the window.
Auto Scroll Example If you set the auto scroll attribute to true the window will use overflow:'auto' on the panel's body and show scroll bars automatically when necessary. Without auto scroll set the content would just be clipped. This example shows 2 windows, the first does not have auto scroll enabled and you can tell that would really be a pain for a user. The second uses auto scroll and everyone is happy because of it.
Animate Target Example The animate target attribute is a nice why of adding style and animation to your window. By padding an element id to the animateTarget attribute we will create a flyout affect animation for our window. You will also notice the window is animated when the close button is clicked.
Icon Example This example shows you how to customize your window by adding an icon to it.
Position Example This default behavior of a window is to center itself. You can override this by setting centerWindow to false. When this attribute is set to false the window position will rely on the x and y attributes. By default these values are 0 but you can set them to any number.
Position Example #2 This example will show you how you can use the set and get position methods. The get position will output the x and y of the window. Using the set position method you can programatically move the window to another location on the screen.
Size Example This examle will show you how to use the getSize() and setSize() methods. Using these methods you can determine the size of a window as well as change the size of it. One thing to note with this example. If you resize a window it does not automatically get centered for you, you can ceter the window after you have resized it using the center method.
Change Title Example This is just a quick example of how you can use the set title to change the title after window has been created and set visible.
Auto Load Example This example shows how you can load content from another template. It also demonstrates that all content in between the start and end tag is ignored when loading content from a url.
Contacts Example This is typical application example. In our example we have a list of contacts each with a contactId. Here we are going to define all of the attributes of our window but we are not going to show it. Next we create a listing of contacts, this could pull from a table but for our example it will be static. To the view the details of each record we will call out showDetails method that will capture the contactId. We then show the record and then using the method load we can load an external url and display the details for this contact. This again is static but could easily be dynamic. Do not forget to change the close action of the window to hide or this example will not work.
Gray Theme Example By default all windows use the aero theme, if you want to change the theme simply pass a theme attribute to the include tag. The only available option right now is gray.
Full Path Example This was added to hopefully solve a path issues where people were not calling the cfext folder from the root. Take for example my domain and lets say that my cfext folder was in danvega.org/cfwindow/cfext and I was trying to use the tag from danvega.org/cfwindow/whatever. Well the whole reason that does not work is because the Ext resources are never imported. A quick fix I found was to supply a path to the cfext folder. In my case it would be http://www.danvega.org/cfwindow/.
Source Example The source example shows how you can use an external URL and load it right into the window. The autoLoad attribute will only load local files for security reasons, this is a way to get around that.
Source Example #2 Another Example!

Project Details

cf_window was created by Dan Vega. You can find out more about the project using the link below or by contacting me.
Project URL: http://cfwindow.riaforge.org
Ext JavaScript Framework http://extjs.com/
Author Website: http://www.danvega.org
Author Email: danvega@gmail.com

License

LICENSE
Copyright 2008 Dan Vega

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Support This Project