martes, 30 de enero de 2007
CFGRID Edition
When a user inserts or deletes a row in a grid or changes any cells in a row and submits the grid, ColdFusion creates the following arrays as Form variables:
Array name
Description
gridname.colname
Stores the new values of inserted, deleted, or updated cells. (Entries for deleted cells contain empty strings.)
gridname.Original.colname
Stores the original values of inserted, deleted, or updated cells.
gridname.RowStatus.Action
Stores the type of change made to the grid rows: D for delete, I for insert, or U for update.
Note: The periods in these names are not structure separators; they are part of the text of the array name.
ColdFusion creates a gridname.colname array and a gridname.Original.colname array for each column in the grid. For each inserted, deleted, or changed row in the grid, ColdFusion creates a row in each of these arrays.
For example, the following arrays are created if you update a cfgrid tag called mygrid that consists of two displayable columns (col1, col2) and one hidden column (col3):
Form.mygrid.col1
Form.mygrid.col2
Form.mygrid.col3
Form.mygrid.original.col1
Form.mygrid.original.col2
Form.mygrid.original.col3
Form.mygrid.RowStatus.Action
The value of the array index increments for each row that is added, deleted, or changed, and does not indicate a grid row number. All rows for a particular change have the same index in all arrays. Unchanged rows do not have entries in the arrays.
If the user makes a change to a single cell in col2, the following array elements contain the edit operation, the edited cell value, and the original cell value:
Form.mygrid.RowStatus.Action[1]
Form.mygrid.col2[1]
Form.mygrid.original.col2[1]
If the user changes the values of the cells in col1 and col3 in one row and the cell in col2 in another row, the information about the original and changed values is in the following array entries:
Form.mygrid.RowStatus.Action[1]
Form.mygrid.col1[1]
Form.mygrid.original.col1[1]
Form.mygrid.col3[1]
Form.mygrid.original.col3[1]
Form.mygrid.RowStatus.Action[2]
Form.mygrid.col2[2]
Form.mygrid.original.col2[2]
The remaining cells in the arrays (for example, Form.mygrid.col2[1] and Form.mygrid.original.col2[1]) have the original, unchanged values.
miƩrcoles, 3 de enero de 2007
ColdFusion Memory Usage Stats
<cfset runtime = CreateObject("java","java.lang.Runtime").getRuntime()>
<cfset freeMemory = runtime.freeMemory() / 1024 / 1024>
<cfset totalMemory = runtime.totalMemory() / 1024 / 1024>
<cfset maxMemory = runtime.maxMemory() / 1024 / 1024>
<cfoutput>
Free Allocated Memory: #Round(freeMemory)#mb
Total Memory Allocated: #Round(totalMemory)#mb
Max Memory Available to JVM: #Round(maxMemory)#mb
</cfoutput>
From these numbers we can also determine the percent of free allocated memory available, and also the percent of avalaible memory allocated
<cfset percentFreeAllocated = Round((freeMemory / totalMemory) * 100)>
<cfset percentAllocated = Round((totalMemory / maxMemory ) * 100)>
<cfoutput>
% of Free Allocated Memory: #percentFreeAllocated#%
% of Available Memory Allocated: #percentAllocated#%
</cfoutput>
Fuente: http://www.petefreitag.com/item/115.cfm
miƩrcoles, 27 de diciembre de 2006
Formatting Numbers for Currency Display in JavaScript
Formatting numbers so they confirm to a specific format can be deceivingly tricky. For example, one of the most common tasks is to format a number for currency display- an integer followed by two decimals. You may be tempted to use number rounding to first shift the number's decimal places (via multiplication), round it, then shift the decimal back (via division) to pound the number into your hard earned dollar, though that won't work in many cases. For example, consider the number 120. Number rounding certainly won't get you to 120.00.
To easily format numbers for a specific number of trailing decimals or total digits (aka padding), JavaScript 1.5 introduces the below two nifty methods:
Number.toFixed(x): Formats any number for "x" number of trailing decimals. The number is rounded up, and "0"s are used after the decimal point if needed to create the desired decimal length.
Number.toPrecision(x): Formats any number so it is of "x" length. Also called significant digits. A decimal point and "0"s are used if needed to create the desired length.
-Number.toFixed()
The best way to see all the subtleties of toFixed() is to see it in action:var profits=2489.8237
profits.toFixed(3) //returns 2489.824 (round up)
profits.toFixed(2) //returns 2489.82
profits.toFixed(7) //returns 2489.8237000 (padding)
Displaying any number in currency format can't get any easier!
-Number.toPrecision()
To toPrecision() now:var anumber=123.45
anumber.toPrecision(6) //returns 123.450 (padding)
anumber.toPrecision(4) //returns 123.5 (round up)
anumber.toPrecision(2) //returns 1.2e+2 (you figure it out!)
toPrecision() is useful if your number must be of a certain length.
Browser Considerations
Now, as noted, our two heros above are JavaScript 1.5 methods. What this means is that they'll only work in IE5.5+ and NS6+. The issue of legacy browsers not performing the desired formatting operation not withstanding, how do you ensure that these two methods at least degrade well? Well, by using method detection in your code. For example:var profits=2489.8237
if (profits.toFixed) //if browser supports toFixed() method
profits.toFixed(2)
For those of you who also need to ensure legacy browsers such as IE5 also perform the desired number formatting operation, well, then it's time to roll your own function.
Article credits: George Chiang is the webmaster for JavaScriptKit.com, where he writes tutorials and scripts pertaining to JavaScript and web design.
lunes, 18 de diciembre de 2006
ColdFusion (4.5.1 and 5): Server crashes when using JDK 1.3 on Solaris or Linux
cfobject tag for Java objects. This article describes a workaround for this issue. Customers experiencing this issue may find the following error message in their server.log:
# HotSpot Virtual Machine Error, Internal Error
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
"Fatal","TID=11","01/18/01","09:56:03",
"Caught a fatal signal (11)
Solution
For JDK version 1.3 to work with ColdFusion Server on Solaris or Linux, use the following steps:For Linux:
- Add JAVA_HOME to the start script under CFHOME.
The start script is typically located at: /opt/coldfusion/bin under default installations. On Red Hat Linux, if you use the RPM, install JDK in the default location; the JAVA_HOME would be located at:Note: RPM is the native way to install, remove, manage programs on Red Hat Linux systems via the Redhat Package Manager. It will find potential conflicts, prior versions, and so forth. By default, it installs a product according to its default location, specified by the product, which in the case of JDK is located at /usr/java/.# Set during install
CFHOME=/opt/coldfusion
ODBCINI=$CFHOME/odbc/odbc.iniJAVA_HOME=/usr/java/jdk1.3
On Red Hat Linux, if you install from the tar.gz file, you can choose the path location. Installing from a tar.gz file unpacks the program wherever the archive is located at the time of execution. For instance, if you chose: /usr/java/jdk1.3/jre/lib/i386/hotspot/libjvm.so as the JDK path location, you would define your JAVA_HOME as JAVA_HOME=/usr/java/jdk1.3. - Based on your JAVA_HOME, configure the LD_LIBRARY_PATH within the start script noted in Step 1.
For instance, if your JAVA_HOME is /opt/j2re1_3_0, your LD_LIBRARY_PATH is:LD_LIBRARY_PATH=$CFHOME/lib:$JAVA_HOME/jre/lib/i386/hotspot:
$JAVA_HOME/jre/lib/i386/native_threads:$JAVA_HOME/jre/lib/i386/
(Although the above snippet appears on two lines, it should be entered as one line.) - Go to the ColdFusion Administrator page. Click the Java tab and add/modify the following settings:
- Java Virtual Machine Path: Specify the path to the libjvm.so (this location varies depending on where you installed the JDK).
- Add System Option:
java.lang.Compiler=NONE - Add Implementation Option:
-XX:+AllowUserSignalHandlers
- Stop and restart the ColdFusion processes.
For Solaris:
- Add JAVA_HOME to the start script under CFHOME.
The start script is typically located at: /opt/coldfusion/bin under default installs. If the JDK was installed with the default settings, the JAVA_HOME would be located at:# Set during install
CFHOME=/opt/coldfusion
ODBCINI=$CFHOME/odbc/odbc.iniJAVA_HOME=/opt/j2re1_3_0 - Based on your JAVA_HOME, configure the LD_LIBRARY_PATH within the start script noted in Step 1.
For instance, if your JAVA_HOME is /opt/j2re1_3_0, your LD_LIBRARY_PATH is:LD_LIBRARY_PATH=$CFHOME/lib:$JAVA_HOME/jre/lib/sparc/hotspot:
$JAVA_HOME/jre/lib/sparc/native_threads:$JAVA_HOME/jre/lib/sparc/
(Although the above snippet appears on two lines, it should be entered as one line.)
In summary, you must add the following entries to the LD_LIBRARY_PATH variable in the start script:$JAVA_HOME/lib/sparc
$JAVA_HOME/lib/sparc/native_threads
$JAVA_HOME/lib/sparc/hotspot - Go to the ColdFusion Administrator. Click the Java tab and add/modify the following settings:
- The Initial Heap Size setting for the "JVM and Java Settings" must be set at minimum to 4096Kb. The default setting is 1024Kb. With the default setting, the server crashes or becomes unresponsive. Increase this setting.
- Java Virtual Machine Path: Specify the path to the libjvm.so (this location varies depending on where you installed the JDK). In most cases, the libjvm.so file is located at: $JAVA_HOME/jre/lib/sparc/client/.
- Add System Option: java.lang.Compiler=NONE.
- Add Implementation Option: -XX:+AllowUserSignalHandlers.
- Stop and restart ColdFusion processes.
Note: Ensure that when defining the location of your libjvm.so file in the ColdFusion Administrator to specify the version of the libjvm.so in the /sparc/client directory.
viernes, 15 de diciembre de 2006
Manejo del Form Scope en ColdFusion
Processing form variables on action pages
The action page gets a form variable for every form control that contains a value when the form is submitted.
Note: If multiple controls have the same name, one form variable is passed to the action page with a comma-delimited list of values.
A form variable’s name is the name that you assigned to the form control on the form page. Refer to the form variable by name within tags, functions, and other expressions on an action page.
On the action page, the form variables are in the Form scope, so you should prefix them with "Form." to explicitly tell ColdFusion that you are referring to a form variable. For example, the following code references the LastName form variable for output on an action page:
#Form.LastName#
The Form scope also contains a list variable called Form.fieldnames. It contains a list of all form variables submitted to the action page. If no form variables are passed to the action page, ColdFusion does not create the Form.fieldnames list.
jueves, 7 de diciembre de 2006
Instalacion de ColdFusion en Windows 2003 Server
Para instalar ColdFusion en Windows 2003 se tiene que activar el instalador (Install Anywhere)
dentro de los permisos de instalacion del Servidor siguiendo estos pasos:
1. Control Panel
2. System
3. Advanced
4. Performance --> Settings
5. Data Execution Prevention
6. Turn on DEP for all programs and services except those I select
7. Add...
8. Seleccione el archivo exe de instalacion de ColdFusion
9. Aplique los cambios
10. Intente de nuevo
Publicar