This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/* ************** Setting Cookie by cfscript in ColdFusion 10 *********** */ | |
//Type - 1 | |
variables.cookieTest = structNew(); | |
variables.cookieTest['value'] = "This is test Cokkie by me by using cfscript"; | |
variables.cookieTest['expires'] = "10"; | |
variables.cookieTest['secure'] = "yes"; | |
variables.cookieTest['domain'] = "cf10"; | |
cookie.myNewCookie = variables.cookieTest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
//New Type Structure declaration introduced in ColdFusion 10 | |
request.employee = { | |
name: "Upendra Roul", | |
ID: "06-800", | |
JobTitle: "ColdFusion Developer" | |
}; | |
writeDump(request.employee); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="fb-root"> </div> | |
<script> | |
(function(d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0]; | |
if (d.getElementById(id)) | |
return; js = d.createElement(s); | |
js.id = id; | |
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=154111381338316"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfsavecontent variable="request.htmlString"> | |
<div id="fb-root"> </div> | |
<script> | |
(function(d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0]; | |
if (d.getElementById(id)) | |
return; js = d.createElement(s); | |
js.id = id; | |
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=1234567890"; | |
fjs.parentNode.insertBefore(js, fjs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
request.inputString = "RajaRamMohamRoy"; | |
request.outputString = rEReplace(request.inputString, "([a-z])([A-Z])", "\1 \2", "ALL"); | |
writeOutput("<b>Input String:</b>" & request.inputString & "<br/>"); | |
writeOutput("<b>Output String:</b>" & request.outputString & "<br/>"); | |
/* | |
Here regular expression we have used is "([a-z])([A-Z])" | |
then replacing that matching pattern with "\1 \2". Which means we are searching for a string | |
which lower case and upper case letter consecutively. Like aA or bC. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="shortenURLByGoogleAPI" access="public" returntype="Struct" hint="Takes long url as input parameter returns a struct containing both short and long url"> | |
<cfargument name="longURL" required="true" type="string" hint="Long URL value" /> | |
<cfset var httpReturnStruct = structNew() /> | |
<cfset var inputParameter = {"longUrl" = arguments.longURL } /> | |
<cfhttp url="https://www.googleapis.com/urlshortener/v1/url" method="post" result="httpReturnStruct"> | |
<cfhttpparam type="header" name="Content-Type" value="application/json" /> | |
<cfhttpparam type="body" value="#serializeJSON(inputParameter)#" /> | |
</cfhttp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.allaire.cfx.* ; | |
public class HelloColdFusion implements CustomTag | |
{ | |
public void processRequest( Request request, Response response ) | |
throws Exception | |
{ | |
String strName = request.getAttribute( "NAME" ) ; | |
response.write( "Hello, " + strName ) ; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
//function defined in cfm page which will add two number and will return the value | |
function addTwoNumber(num1, num2) { | |
return num1 + num2; | |
} | |
varriable.x = variables.addTwoNumber; //Function defined in this page is assigned to the variable x | |
writeOutPut("Call to addTwoNumber : " & varriable.x(10,12)); //Function call to AddTwoNumber by using variable | |
variables.y = createObject("component", "test").addTwoNum; // Function defined in test.cfc is assigned to variable y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component { | |
public function addTwoNum(num1, num2) { | |
return num1 + num2; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
public boolean function ListCompare(required string list,required string sublist,string delim=",") { | |
var local = {}; //Local scope declaration | |
local.qryFilterResult = queryNew(""); //Declaring query object to hold filtered list | |
try { | |
/* Creating a query object from the list passes in the argumnet */ | |
local.qryOriginalList = queryNew(""); | |
queryAddColumn(local.qryOriginalList, "listElement", "CF_SQL_VARCHAR", listToArray(arguments.list, arguments.delim)); |
OlderNewer