Entries for month: June 2009

Coldfusion interview Questions with answers Part 4

No Comments »

69. What is CFScheduler?
It provides a programmatic interface to the ColdFusion scheduling engine. It can run a CFML page at scheduled intervals, with the option to write the page output to a static HTML page. This feature enables you to schedule pages that publish data, such as reports, without waiting while a database transaction is performed to populate the page.

77. What is CFTransaction?
For enterprise database management systems that support transaction processing, instructs the database management system to treat multiple database operations as a single transaction. It provides database commit and rollback processing. See the documentation for your database management system to determine whether it supports SQL transaction processing.
Syntax

<cftransaction 
action = "begin|commit|rollback|setsavepoint"
isolation = "read_uncommitted|read_committed|repeatable_read"
savepoint = "savepoint name">
</cftransaction>

78. Can we have more than Data Source within CFTransaction?
No.Datasource Names For All The Database Tags Within CFTRANSACTION Must Be The Same.
The workaround for the problem of CFTRANSACTION with different data source,
   Use same datasource in CFQUERY
   but inside the cfquery prefix the table with desired database in the query.
    <CFTRANSACTION>
      <cfquery datasource=same>
         SELECT * FROM TableName
      </cfquery>
      <cfquery datasource=same>
        SELECT * FROM other.dbo.TableName
      </cfquery>
    </CFTRANSACTION>

79. What are the different attributes in CFQuery?

Attribute

Description

name

Name of query. Used in page to reference query record set. Must begin with a letter. Can include letters, numbers, and underscores.

blockFactor

Maximum rows to get at a time from server. Range: 1 - 100. Might not be supported by some database systems.

cachedAfter

Date value (for example, April 16, 1999, 4-16-99). If date of original query is after this date, ColdFusion uses cached query data. To use cached data, current query must use same SQL statement, data source, query name, user name, password.
A date/time object is in the range 100 AD-9999 AD.
When specifying a date value as a string, you must enclose it in quotation marks.

cachedWithin

Timespan, using the CreateTimeSpan function. If original query date falls within the time span, cached query data is used. CreateTimeSpan defines a period from the present, back. Takes effect only if query caching is enabled in the Administrator.
To use cached data, the current query must use the same SQL statement, data source, query name, user name, and password.

dataSource

Name of data source from which query gets data. You must specify either dbtype or dataSource.

dbtype

Results of a query as input. You must specify either dbtype or dataSource.

debug

  • yes, or if omitted: if debugging is enabled, but the Administrator Database Activity option is not enabled, displays SQL submitted to the data source and number of records returned by query.
  • no: if the Administrator Database Activity option is enabled, suppresses display.

maxRows

Maximum number of rows to return in record set.

password

Overrides the password in the data source setup.

result

Name for the structure in which cfquery returns the result variables. For more information, see Usage.

timeout

Maximum number of seconds that each action of a query is permitted to execute before returning an error. The cumulative time may exceed this value.
For JDBC statements, ColdFusion sets this attribute. For other drivers, see the driver documentation.

username

Overrides user name in the data source setup.

 

80. What is Query in Query?

ColdFusion allows developers to reuse existing queries by running queries against them in memory. This gives you the advantage of being able to avoid the often costly performance hit of going back to the database to manipulate data that the application server has already recently called. A standard <cfquery> statement can be used to call a query variable in memory as though it were simply a table of data in an available data source. Query variables can even be joined, which provides interesting possibilities for joining data from disparate information sources.

How to check if checkbox is checked using jQuery

JQuery No Comments »

There are 3 ways in jQuery to find a check box is checked or not.

// First way 
$('#checkBox').attr('checked'); 
// Second way 
$('#edit-checkbox-id').is(':checked'); 
// Third way for jQuery 1.2
$("input[@type=checkbox][@checked]").each( 
    function() { 
       // Insert code here 
    } 
);
// Third way == UPDATE jQuery 1.3
$("input[type=checkbox][checked]").each( 
    function() { 
       // Insert code here 
    } 
);

 

First two methods return true or false. True if that particular checkbox was checked or false if it is not checked. The third method iterates though all checkboxes with checked attribute defined and performs some action.

Coldfusion interview Questions with answers Part 3

ColdFusion No Comments »

41. What is CFInclude?
Cfinclude is like substituting a block of code in the page where you are putting the cfinclude tag. The variables in the called page will have the same scope as in the calling page.

42. What is CFModule?
Cfmodule is really a custom tag call. It is, in fact, a way to call a custom tag without needing to place it in the "customtags" folder, or in the same folder as the calling process.

44. What is the difference between Custom tag and Coldfusion Component?
    Custom tags have a single entry point; CFCs can have multiple entry points. This makes it possible to create a single component that does many related actions. (To do that with custom tags you'd need multiple tags or cumbersome switch processing.)
    Custom tags have no formalized parameter passing and validation mechanism; CFCs do. In other words, unlike custom tags, CFCs can validate passed data, enforce data types, check for required parameters, and optionally assign default values.
    Custom tags cannot persist; CFCs can. Custom tags are blocks of code that are executed as is, while CFCs are objects and can be treated as such.
    Custom tags are designed to contain code; CFCs are designed to contain both code and data.
    Custom tags are accessible only by ColdFusion and only locally; CFCs can be accessed as web services, opening up a whole new world of reuse possibilities.

45. What is CFX tag? What is the use?
The CFX interface is the original ColdFusion extensibility interface. It is fast and powerful, and allows for tags to be written in Java or in C/C++. CFX tags are executables that must be registered in the ColdFusion Administrator so as to bind an alias with the name of the actual executable. Using the CFX interface, it is possible to write extensions that cannot be written using other interfaces.

46. What is Coldfusion component?
ColdFusion Components are essential building blocks used in creating tiered, structured, and scalable applications. Unlike Custom Tags, which are primarily used to encapsulate processing, and UI abstractions, ColdFusion Components are designed to black-box processing, transactions, back-end integration, and the like.

48. How can you invoke CFC?
Method 1:

<cfinvoke>
    <cfinvoke component="user" method="Get" returnvariable="usr">
    <cfinvokeargument name="id" value="#id#">
</cfinvoke>

Method 2:

<!--- Load CFC as an object --->
<cfobject component="user" name="userObj">
<!--- Invoke method --->
<cfinvoke component="#userObj#" method="Get" id="#id#" returnvariable="usr">

Method 3:

<cfscript>
// Load CFC as an object
userObj=CreateObject("component", "user");
// Invoke method
user_id=userObj.Get(id);
</cfscript>

Method 4: URL Invocation
CFCs can also be invoked on the command line directly; every CFC has a URL that points to it. When invoking CFCs via URLs, the method and any arguments are passed as URL parameters, as seen here:
http://localhost/users/user.cfc?method=get&id=1

50. What are the different ways to access CFC?
Same as 48

51. What is CFobject?
CFC can be instantiated as an object, using the <cfobject> tag.

52. What is CreateObject?
CreateObject() is a functional equivalent of the <cfobject> tag. CreateObject() can be used to instantiate CFCs just like <cfobject> can, but there is one notable difference: As a function, CreateObject() can be used in a <cfscript> block (whereas <cfobject> cannot).

56. How can you call the external exe files?
using cfexecute tag, we can call the external exe files.Below example executes the Windows NT version of the netstat network monitoring program, and places its output in a file.
<cfexecute name = "C:\WinNT\System32\netstat.exe"
arguments = "-e"
outputFile = "C:\Temp\output.txt"
timeout = "1">
</cfexecute>

57. What is cfexecute? What are the attributes? What is the drawback of using this?
CFExecute is a tag used to execute developer-specified process on server computer. It has some restrictions like; it cannot run in windows 2003 and cannot run a batch file.

AttributeDescription
name Absolute path of the application to execute. On Windows, you must specify an extension, for example, C:\myapp.exe.
arguments Command-line variables passed to application. If specified as string, it is processed as follows:
* Windows: passed to process control subsystem for parsing.
* UNIX: tokenized into an array of arguments. The default token separator is a space; you can delimit arguments that have embedded spaces with double-quotation marks.
If passed as array, it is processed as follows:
* Windows: elements are concatenated into a string of tokens, separated by spaces. Passed to process control subsystem for parsing.
* UNIX: elements are copied into an array of exec() arguments.
outputFile File to which to direct program output. If no outputfile or variable attribute is specified, output is displayed on the page from which it was called.
If not an absolute path (starting a with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the GetTempDirectory function.
timeout Length of time, in seconds, that ColdFusion waits for output from the spawned program.
* 0: equivalent to nonblocking mode.
* A very high value: equivalent to blocking mode.
If the value is 0:
* ColdFusion starts a process and returns immediately. ColdFusion may return control to the calling page before any program output displays. To ensure that program output displays, set the value to 2 or higher.
* If the outputFile attribute is not specified, any program output is discarded
variable Variable in which to put program output. If no outputfile or variable attribute is specified, output is displayed on page from which it was called.

58. What is WDDX? Where all are applicable?
For XML to work, both sender and recipient must agree on an XML language, and all data must be well formed according to that language. WDDX is Macromedia's contribution to the XML community. It is an open-source XML DTD (Document Type Definition) that defines generic data types such as strings, arrays, structures, and recordsets. WDDX is an XML language that defines data not any specific implementation, but raw data itself. This can make data sharing via XML quick and painless (it doesn't require that an XML language be agreed upon).

Coldfusion interview Questions with answers Part 2

ColdFusion No Comments »

21. What is Scope Variables?
A variable's scope is determined by its origin. The scope determines a number of properties about the variable, such as its life span, timeout, and storage location, and therefore, how it can be used.

22. What is the different type of Scope variables?

Scope Description
Application Contains variables that are associated with one, named application on a server. The cfapplication tag name attribute or the Application.cfc This.name variable setting specifies the application name.
Arguments Variables passed in a call to a user-defined function or ColdFusion component method.
Attributes Used only in custom tag pages and threads. Contains the values passed by the calling page or cfthread tag in the tag's attributes. 
Caller Used only in custom tag pages. The custom tag's Caller scope is a reference to the calling page's Variables scope. Any variables that you create or change in the custom tag page using the Caller scope are visible in the calling page's Variables scope.
CGI Contains environment variables identifying the context in which a page was requested. The variables available depend on the browser and server software.
Client Contains variables that are associated with one client. Client variables let you maintain state as a user moves from page to page in an application, and are available across browser sessions. By default, Client variables are stored in the system registry, but you can store them in a cookie or a database. Client variables cannot be complex data types and can include periods in their names.
Cookie Contains variables maintained in a user's browser as cookies. Cookies are typically stored in a file on the browser, so they are available across browser sessions and applications. You can create memory-only Cookie variables, which are not available after the user closes the browser. Cookie scope variable names can include periods.
Flash Variables sent by a Flash movie to ColdFusion and returned by ColdFusion to the movie.
Form Contains variables passed from a Form page to its action page as the result of submitting the form. (If you use the HTML form tag, you must use method="post".)
function local Contains variables that are declared inside a user-defined function or ColdFusion component method and exist only while a function executes.
Request Used to hold data that must be available for the duration of one HTTP request. The Request scope is available to all pages, including custom tags and nested custom tags, that are processed in response to the request. This scope is useful for nested (child/parent) tags. This scope can often be used in place of the Application scope, to avoid the need for locking variables. Several chapters discuss using the Request scope.
Server Contains variables that are associated with the current ColdFusion server. This scope lets you define variables that are available to all your ColdFusion pages, across multiple applications.
Session Contains variables that are associated with one client and persist only as long as the client maintains a session. They are stored in the server's memory and can be set to time out after a period of inactivity.
This Exists only in ColdFusion components or cffunction tags that are part of a containing object such as a ColdFusion Struct. Exists for the duration of the component instance or containing object. Data in the This scope is accessible from outside the component or container by using the instance or object name as a prefix.
ThisTag Used only in custom tag pages. The ThisTag scope is active for the current invocation of the tag. If a custom tag contains a nested tag, any ThisTag scope values you set before calling the nested tag are preserved when the nested tag returns to the calling tag. The ThisTag scope includes three built-in variables that identify the tag's execution mode, contain the tag's generated contents, and indicate whether the tag has an end tag. A nested custom tag can use the cfassociate tag to return values to the calling tag's ThisTag scope.
Thread Variables that are created and changed inside a ColdFusion thread, but can be read by all code on the page that creates the thread. Each thread has a Thread scope that is a subscope of a cfthread scope.
thread local Variables that are available only within a ColdFusion thread.
URL Contains parameters passed to the current page in the URL that is used to call it. The parameters are appended to the URL in the format ?variablename = value[&variablename=value...]; for example www.MyCompany.com/inputpage.cfm?productCode=A12CD1510&quantity=3. Note: If a URL includes multiple parameters with the same name, the resulting variable in the ColdFusion URL scope consists of all parameter values separated by commas. For example, a URL of the form http://localhost/urlparamtest.cfm? param=1&param=2&param=3 results in a URL.param variable value of 1,2,3 on the ColdFusion page.
Variables (local) The default scope for variables of any type that are created with the cfset and cfparam tags. A local variable is available only on the page on which it is created and any included pages (see also the Caller scope).


23. What is Application Variables? How can you clear these variables?
These are special scope variables that are available to all pages in an application for all clients.
Data is stored in application server memory.
You must use the Application scope prefix in the variable name.

<!--- To delete all application variables--->
<cfset StructClear(Application)>
<!--- To delete a particular variable in session --->
<cfset StructDelete(Application, "varName")>


24. What is Session Variables? How can you clear these variables?
These are special scope variables that are available for a single client browser for a single browser session in an application.
Data is stored in application server memory.
You must use the Session scope prefix in the variable name.

<!--- To delete all session variables --->
<cfset StructClear(Session)>
<!--- To delete a particular variable in session --->
<cfset StructDelete(Session, "varName")>

25. How can you list out all the Session variables in an Application?
use cfdump to show entire session value in Development environment.

<cfdump var="#session#">

Session variables are in stored in structure format. So you loop through the collection to show the session variables.

<cfoutput><cfloop  collection=#session# item="key">
    #key# : #structFind(session,key)#<br />
</cfloop></cfoutput>

26. How can you delete the session variables?

<!--- To delete all session variables --->
<cfset StructClear(Session)>
<!--- To delete a particular variable in session --->
<cfset StructDelete(Session, "varName")>


27. What is a client variable?
These are special scope variables that are available for a single client browser over multiple browser sessions in an application.
Data is stored as cookies, database entries, or Registry values.
No need to use the Client scope prefix in the variable name
Value must be simple variables. Can not be arrays, structures, query objects, or other objects.

28. What is the default storage for client variable?
client variables stored in registry, database or in client cookie.By default, ColdFusion stores this in the Registry.it is more appropriate to store the information as client cookies or in a SQL database.

29. What is URL token?
Combination of CFID & CFTOKEN is called as urltoken. If user disabled the browser cookie, It is used to track a user's browser session.

30. What is Cookie Variables?
Cookies are server specific simply stored variables stored in files in the browser's file system. It used to track state maintenance(browser session) of a user.

31. What is the difference between Client and Session variables?
Session variables can be used to dump complex data structures like arrays and structures.But client variable are used only in case of simple variables.

32. What is Structure? What are the different functions in Structure?
ColdFusion structures consist of key-value pairs. Structures let you build a collection of related variables that are grouped under a single name. A structure's key must be a string. The values associated with the key can be any valid ColdFusion value or object. It can be a string or integer, or a complex object such as an array or another structure. Because structures can contain any kind of data they provide a very powerful and flexible mechanism for representing complex data. check Structure functions here.

33. What is the difference between Structure and Array?
In structure one can combine variables of different datatype in to a common data type Whereas arrays are sequentially stored values of the same datatype.

34. How can you set common footer?
Using cfinclude, we can include footer file in all pages. We can OnRequestEnd.cfm file or OnRequestEnd method in Application.cfc also to include footer file.

35. What is OnRequestEnd.cfm? When it will execute?
Just as the Application.cfm page runs before the code on an application page, an OnRequestEnd.cfm page runs, if it exists, after each application page in the same application.The OnRequestEnd.cfm page must be in the same directory as the Application.cfm page ColdFusion uses for the current page. ColdFusion does not search beyond that directory, so it does not run an OnRequestEnd.cfm page that resides in another directory.The OnRequestEnd.cfm page does not run if there is an error or an exception on the application page, or if the application page executes the cfabort or cfexit tag. Page flow given below

Application.cfm -> CFM page -> OnRequestEnd.cfm

36. Can we have multiple OnRequestEnd.cfm in an Application? How its works?
Yes, We can have. The OnRequestEnd.cfm page must be in the same directory as the Application.cfm page ColdFusion uses for the current page. ColdFusion does not search beyond that directory

39. Where we can place the custom tag?
Custom tags can be stored in any of the following locations. ColdFusion will search for them in the order listed.
    In the same directory as the calling page - while this is easy for demonstration purposes, it's not very practical, as it means that the custom tag is only available within that directory.
    In a directory (or subdirectory of a directory) specified in ColdFusion Administrator under Extensions -> Custom Tag Paths.
    In the cfusion/CustomTags directory or one of its subdirectories.

40. What are the different ways to call custom tag?
  using cf_  filename of custom tag
  using cfmodule tag
  using cfimport  tag

Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds