martes, 30 de enero de 2007

CFGRID Edition

How user edits are returned

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

Here are some code to find out some info about the memory usage of CFMX or BlueDragon. The Java API provides three methods in the java.lang.Runtime class: freeMemory, totalMemory, and maxMemory. These methods provide information about the JVM's memory usage, and its easy to access them with CFML:

<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