Replace Function in Cold Fusion
Hello All,
The code below does the following: It finds an item in Spanish (in this case it's GetBasket.options, 2) and add `SPA` to the SKU code.
<cfif ListContains(GetBasket.options, 2)><option value="2"><cfset basketsku = GetBasket.SKU & "SPA"></option></cfif>
How do I do the following?
The SKU code is a 5 digit code for all languages. For example: the SKU code in English is 902013, but the SKU code for Spanish is 903013. As you can see the 3rd number is being replaced with 3. It will be standard for all items in Spanish. How do I modify the code above to replace the 3rd number with 3?
Thank you all very much in advance!
not sure if you found an answer to this question but if you use the Replace function you can do this.
Replace(DB.value, 2, 3 )
Similar Messages
-
Is there a Session End function in Cold Fusion?
In .net there's a session end function that allows you to
perform functions when a users session ends, does Cold Fusion have
anything like this? The reason I ask is I have a user who generates
multiple xml files with data and stores them to the hard drive
while they visit the site, but once they leave, I submit all those
xml files to a database and I'm trying to figure out the best way
to do this. It would be for multple users on the site. Anyone have
any ideas?Thanks, I suppose I can do that. I've never done a scheduled
job before, but it doesn't look too difficult to setup.
Thanks. -
How not to use Cold Fusion and Java
Overview
This write up is intended to give java developers that are
developing ColdFusion applications some beneficial information:
things that are not documented.
Scenario
The company builds enterprise class web application software
for fortune 500 companies. It had purchased a CF 7 based product,
had and existing proprietary J2EE based product, and needed to
integrate the two while meeting a host of new requirements. These
requirements were based on delivering a better user experience,
faster / cheaper integration, increased flexibility /
configuration, useablily, decreasing maintenance costs, the ability
to deploy in either install or ASP models. An initiative was
started to create a new framework that integrated the best of each
technologies. Tactically, this meant that we were to build a hybrid
CF and java application: one that used building blocks (decoupled /
cohesive components) that would allow applications to be rapidly
assembled, configured and deployed. This made sense on several
levels, the team was composed of Java and CF developers, the CF
rapid application development was very productive, there is great
functionality delivered in the CF platform and initial performance
tests showed no cause for alarm
The agreed upon design, based on requirements, and analysis
by both the CF and Java staff has us using CF in the presentation
layer, using a CF based MVC, use of CF based web services. The MVC
was deployed using CFC inheritance for model objects and views made
use of CF custom tags. The internals of the application, used a
rules engine, some proprietary java, ORM, and other J2EE
technology. The initial performance of the system was reasonable.
We pushed on with product implementation.
Then it was time to load test the application, and tune it.
Under load the response times were orders of magnitude slower,
sometimes the pages even timed out.
Armed with our profiler, oracle execution plans and we
charged ahead addressing issue after issue. Note that we took
meticulous care in tweaking the active thread pool and ensuring
that our CF setup was tuned for our application. None of the
observations here are a condemnation of the language; rather they
are aspects that, when considered together, not conducive for
building integrated java and CF frameworks that use a structured /
OO programming practices. Further detail can be provided on
request.
CFC inheritance should be avoided - resolution of variable
scope is expensive even if properly declared.
Since CF creates a class per method under the covers call
stacks become very large, especially if used in a loop. This is
nominally exacerbated by CF calls necessary to set up for the
method call (String.toUpper()).
Nesting of loops and if statements should be kept to a
minimum - the conditional for each lookup of logical operator like
LT, GT are synchronized. Under load this results in thread waits.
Jrun has as single thread pool - both http and web service
requests use the same pool. Under load this leads to thread
deadlock. There are work arounds, but they are painful.
Recursion should be avoided - we had a few recursive routines
and these had to be rewritten.
Custom Tags - should be used sparingly - each custom tag
makes a synchronized call to the license server - (This may be
fixed in CF 8)
Summary
In the end we got the performance to reasonable numbers, but
we ended up moving some code to java (Custom Tags) and getting rid
of 'good programming' practices (Inheritance, loops, etc), mandated
proper variable scoping for those things left over. We prototyped a
sans cold fusion implementation and had an order of magnitude
improvement in performance and number of requests served per
second.
The lesson? Use Coldfusion in its sweet spot: make a query,
iterate over the results and format for display. Extensive use of
structure programming techniques or OO CFCs should be avoided: they
will work but under load - but are better as a prototype. Building
frameworks in CF? Think twice, no three times, and, if you must, be
minimalist.
Textinteresting aslbert123,
Not that I doubt you, but could you answer some questions
about your implementation that was so slow:
1.) Did you put your CFCs in the application or server scope?
2.) Were you initializing your CFCs, via CreateObject or
<cfinvoke>, on every request?
3.) Are you sure that you were properly Var'ing every
variable in your methods? (people typically forget about query
names and loop iterator variables)
4.) Could you give examples of how your inheritence was set
up?
5.) For CustomTags, did you call them the old <cf_tag>
way or the newer, better-performing <cfimport> way?
6.) How did you connect CF to Java exactly?
Thanks,
Aaron -
Cold fusion 9 500 - Internal server error.
all of a sudden none of our cfm web pages work on a windows 8 server running iis 7 .... the server shows no errors in the event viewer .... occasionally functionality comes back w/o doing anything ...... cold fusion did have all the hotfixes updated a few months ago but i cant get to the admin page to give what the version is
thxsWell if you got over your misplaced indignation for a moment, let's see:
ColdFusion is what people will google for, so in the spirit of helping others who might have the same question as you later on, spelling it right will help the community.
Jason's observation that you give us absolutely nothing to go on so it's basically impossible to help you is a fairly poignant observation, right? You do want help? Right, so here's some suggestions:
Articulate your issue clearly, with sufficient detail that we can help you. Read this:
http://www.catb.org/esr/faqs/smartquestions.html
Secondly... being rude to someone like Jason who really is one of the most helpful people on
these forums is a pretty stupid idea. And just serves to make you look a bit of a [profanity edited out]. Esp. with the caps lock on.
But anyway, let's call that a false start. Give us the details of your issue, and we'll try to help.
Cheers.
Adam
Message was edited by: m.m.murphy -
Air,Flex ,Cold Fusion There is a problem with P4990 Release of AIR Updater
using Air/Flex/cf I am not able to connect to my Cold Fusion
component after running the P4990 UPdate this morning, It worked
fine on both an XP and Vista Machine running P4880 , but now even
after a restart my simple connection to the cfcomponent is hanging
and will not run.
this worked fine in the release I was running this morning,
runs fine in a browser just not after patching ?
two questions ,
where can I download the P4880 Release Again
and is this a bug or a change ? ,
if its a change what is the new way of connecting.
RayI read through the notes and iI even recreated my air file,
but it is still hanging , here is the html for the connection
to the app as well as the flex remote connection I am using, it all
works in the browser, but again just hangs in air after this update
<cfoutput>
<object
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="
http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"
name="VPR_Users" width="1003" height="650" align="middle"
id="VPR_Users">
<param name="movie"
value="/VS/Modules/Administration/plugins/users/ui/screens/VPR_Users.swf?u=#Application.V iper.userID#"
/>
<param name="quality" value="high" />
<param name="bgcolor" value="##869ca7" />
<param name="allowScriptAccess" value="always" />
<embed
src="/VS/Modules/Administration/plugins/users/ui/screens/VPR_Users.swf?u=#Application.Vip er.userID#"
quality="high" bgcolor="##869ca7"
width="1003" height="650" name="VPR_Users" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="
http://www.adobe.com/go/getflashplayer">
</embed>
</object>
</cfoutput>
FLEX CONNECTION CODE (flexgateway is my cfc)
<mx:RemoteObject id="VIPER" destination="ColdFusion"
source="VS.bin.engine.flexgateway" showBusyCursor="true">
<mx:method name="setUserInfo"
result="setUserInfoResult(event)"
fault="Alert.show(event.fault.message)"/>
</mx:RemoteObject>
the function that runs and hangs
private function init():void{
pUserID = Application.application.parameters.u;
VIPER.setUserInfo(pUserID);
the variable is entering into flex fine, the flex application
is loading into the air harness fine but when I run the page ,
it hangs like it is not even connecting. -
Does someone know a function or tag in Cold Fusion to resize
images. I need to place a table of thumbnails on the web page.
After clicking on a thumbnail, the larger equivalent of the image
needs to be loaded. The problem, so far, is to dinamically scale
down images to a thumbnail size and output them.
Any help is appreciated.YAHA1,
These links might help. Or just search the forums for
"thumbnail" or google for "ColdFusion+Image+thumbnail"
http://www.bpurcell.org/viewcontent.cfm?contentID=126
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=12 48691
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=3&threadid=12 50309 -
I want to find out whether coldfusion can talk with SVN ,the reason is I should be able to download the component from SVN to my local system modify and then add it again to back to SVN or directly upload a new component from my local system to SVN. Basically my cold fusion application sholud be able to talk with SVN to perform the above functions.
This is some dude named Dan's Prior Art, His site is dead but google gave a cached page... I can imagine all kinds of mods and uses for something like this...
Cool ColdFusion and Subversion integration
December 5th, 2007 Dan Skaggs Leave a comment Go to comments
I recently decided to outsource my souce code management to CVSDude. I had been running SVN on my VPS that I have at Slicehost and that had been running okay. However, I’m only good enough at SVN administration to get the server up and running and create a few repositories and there were other things that I needed to do with SVN that I frankly didn’t have time to learn how to do.
One of the things that I’d heard talked about that made life much easier was using Subversion’s various hooks to automate some things around different SVN events. I emailed tech support asking how we could configure the “post-commit” hook to update the files on my VPS each time I made a commit into the SVN module. The tech told me that they do this by configuring an HTTP call to a page (or script etc) on your server. That page then triggers an SVN update of the specific module.
After hearing this, I began thinking about how to use CFEXECUTE to trigger the SVN update and was actually surprised how simple it was. My VPS runs on Fedora Core 6, so, like any *nix operating system, you need to make sure permissions on the files are set so that the user which runs ColdFusion can write to the directories. Once that was accomplished, all it took was a few lines of code and we’re ready to start receiving HTTP callbacks from CVSDude’s servers.
CVSDude structures their SVN URLs in the format http://username-svn.cvsdude.com/modulename (or https://). All my modules are named in reverse domain order for the web site that it is for (for example, this one is ws.skaggsfamily.dan). I had already checked out all my modules into a specific directory.
The HTTP callback from CFSDude’s server has 4 URL parameters that they send over: root (full path to module), author (user), revision and date. So all I really had to do was grab the URL.root value and extract the name of the module, pass that to the CFEXECUTE tag and, voila, automatic updating of the module immediately after the commit.
There were only 2 gotchas that I had to figure out:
Put the full path to the svn executable
Add in your username and password to the string in the arguments attribute of CFEXECUTE
The code that I used is below. I’m sure there’s more that I could have done with it, but this is a good start I think.
<cfif structKeyExists(URL, “date”) AND URL.date NEQ “” AND
structKeyExists(URL,”author”) AND URL.author NEQ “” AND
structKeyExists(URL, “revision”) AND URL.revision NEQ “” AND
structKeyExists(URL, “root”) AND URL.root NEQ “”>
<cfset module = replaceNoCase(URL.root, “http://username-svn.cvsdude.com/”, “”)>
<cfexecute name=”/usr/bin/svn”
arguments=”up /var/sites/#module# –username yourUserName –password yourPassword”
timeout=”300″
variable=”result”>
</cfexecute>
<cflog log=”Application”
type=”information”
text=”#URL.author#:#URL.root#:#URL.revision# – #result#”>
<cfmail to=”[email protected]”
from=”[email protected]”
subject=”Server updated successfully”>
The server has been successfully updated with your lastest changes.
Details of the update are below:
Date: #URL.date#
Module: #URL.root#
Revision: #URL.revision#
Results:
#result#
</cfmail>
</cfif> -
I am currently using cold fusion 4.5, i need to upgrade to
coldfusion 8
Please let me know the codes developed in cold fusion 4.5
works in 8.
Is any tags & functions are depreciated in cold fusion 8http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags-pt0_19.html
There is also a Code Analyzer in the ColdFusion Administrator
that you could
use. Just download the Developer version of ColdFusion,
install it, and run
the analyzer.
Ken Ford
Adobe Community Expert - Dreamweaver
Fordwebs, LLC
http://www.fordwebs.com
"vijay rajagopal" <[email protected]> wrote
in message
news:foigmf$8b8$[email protected]..
>I am currently using cold fusion 4.5, i need to upgrade
to coldfusion 8
>
> Please let me know the codes developed in cold fusion
4.5 works in 8.
>
> Is any tags & functions are depreciated in cold
fusion 8
> -
Cold Fusion / developer edition
hey guys
sorry to ask you this but it has been hanging over my head
for a long period of time.
I have been unable to get my mind around the concept of "the
developer edition of Cold Fusion". from what i have learnt , i can
use it locally only. Does that mean that i wont be able to transfer
my cold fusion files onto a webhosting that supports ColdFusion??
Am i expected to present "my license to ColdFusion" to my web
provider every time I upload a website onto a webhosting?
Please someone explain to me what happens when i upload my
coldfusion-based website onto a webhosting. Will it stop working or
will my code get corrupted??
Cheers
MarosHi Maros
There are a few of things you will need to be aware of when
you move to the
server. First, be sure the mapping on the server is the same
as it is
locally, this especially concerns CFCs. In Dreamweaver if you
drag a CFC
function onto a page Dreamweaver will map the dot path to the
CFC including
the folder your site is in within the ColdFusion8\wwwroot
folder, naturally
this folder doesn't exist on your server since the entire
site is directly
in your root folder. Be sure to address this before going
live.
Also, make sure you move your database to the server and set
up the DSN,
using the exact same DSN name you used locally.
Finally, make sure your host supports the same version of CF
as you have
locally as well as the database if you are using MySQL or SQL
Server. If you
are using Access, be sure your host server is a Windows
sever.
Doing this should make for a smooth transition.
Lawrence Cramer *Adobe Community Ace*
Cartweaver.com
ASP, PHP, and ColdFusion Shopping Carts For Dreamweaver -
Problems with Cold Fusion Forms
Hey Everybody -
Pretty new to these forums and cold fusion in general. I
created a number of forms in cold fusion for a school. They sign up
for classes and when they fill out ALL text fields they
successfully submit the form and they see a success page. Sounds
great right? well kind of.
If a user doesnt fill out the entire form, and submits it
gives them an error with coldfusion errors. So I am faced with a
few choices. I can either: have the form forward them to an error
page instead of the coldfusion error, or if there's a way I can
fill in the null values so that there isnt a problem with nulls. I
want to have validation but I want it in a seperate page since I
dont have the room to add errors in the form itself.
Any help would be great. Thanks in advance.I always do ALL my form validations with a client-side JS
**and** with server-side CF.
I don't use <cfform>, I know <cfform> is
dependant on the java version the user has installed on their end.
I know I came across quite a few issues where on one machine the
<cfform> worked fine, and on another it konked out.
Anways, this is one of my most basic forms:
=============================================
PAGE1.cfm
<html>
<head>
<script>
function validate() {
var IA = document.ContactUs;
var errorMSG = "";
if(IA.FullName.value == "") {errorMSG += "Full Name\n";}
if(IA.Email.value == "") {errorMSG += "Email\n";}
if(errorMSG != "") {
alert("The following fields are required:\n\n" + errorMSG);
return false;
</script>
</head>
<body>
<form name="ContactUs" action="page1_x.cfm" method="post"
onSubmit="return validate();">
<table>
<tr>
<td align="right">Name: </td>
<td align="left"><input type="text" name="FullName"
maxlength="50" size="25"></td>
</tr>
<tr>
<td align="right">Email Address: </td>
<td align="left"><input type="text" name="Email"
maxlength="50" size="25"></td>
</tr>
<tr>
<td align="right">Comments: </td>
<td align="left"><textarea name="Comments"
cols="20" rows="5" id="comments"></textarea></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="SubmitContact"
value="Submit">
<input type="reset" name="Reset" value="Reset">
</td>
</tr>
</table>
</form>
</body>
</html>
=============================================
=============================================
page1_x.cfm
<cfif isdefined("FORM.SubmitContact") and FORM.FullName
NEQ "" and FORM.Email NEQ "">
<!--- is all is OK, do whatever it is you want to do.
--->
<cfelse>
<!--- if the submit button was no clicked, fullname and
email (required fields) not filled out, send them back to the form
--->
<cflocation url="page1.cfm?status=1" addtoken="no">
</cfif>
=============================================
Now, there is sooooo much more you can here for a full blown
error-proof script. You can also check if the e-mail is a valid
e-mail (server side), and if the field is a numeric field (like zip
code, phone number, etc) then check if that field is valid, etc.
This is just a run-of-mill simple form and validation
submission using both client-side JS and server-side code. -
Your Comments: iPlanet 6 & Cold Fusion
Need comments from anyone running Cold Fusion on iPlanet 6 ((even 4.1x
users) (Solaris 8/Unix)..
May need to do this, I need to know from actual users, not vendors,
about the performance or if anybody has a URL to a news article, etc...
Have been told that performance is terrible... I need to verify
this...
Thanks...
JerryThe problem is that the official response from Adobe is that they have deprecated ColdFusion from Dreamweaver 2014. They want ColdFusion Developers to move to CF Builder, but they are not going to make it a part of Creative Cloud so it will be a separate purchase. Adobe has basically abandoned the ColdFusion community, the community that built the demand for Dreamweaver. What's more, Adobe is not listening to those of use in the ColdFusion community and reinstalling the workings of CF back into Dreamweaver. What seems to be the view from some in the know is that CF Developers should use CF Builder to code the site, DW to design, and another program to FTP the files. Whereas before all we needed for more than 10 years was Dreamweaver. I am currently looking for another editor that will replace DW as well as Photoshop so I no longer have to deal with Adobe. If anyone knows of something, let me know and I will gladly spread the word after testing. Even before all this I dealt with Adobe on many issues with the ColdFusion server not handling code correctly. Their excuse was that they incorporated 3rd party code and couldn't always guarantee it would work correctly. My problem is I didn't pay the 3rd part developers hundreds of dollars for a ColdFusion license, but Adobe and they should make sure the code worked. I am completely baffled by Adobe and their self destructive ways of doing business. Unless they change their ways soon, they will be losing a lot of business based on all the posts I have read on various Forums.
-
Need to dial a phone number from Cold Fusion
My boss asked me if there was any way that a phone number
could be dialed from Cold Fusion. We have a website where at some
point we want to just click a button and dial that phone number. My
guess is that the conversation will then be carried through the
computer's microphone and speakers and using the computer's modem.
Let me know if there is a way, or what would be the easiest
way to accomplish this, even if it has to be using VOIP, since
that's an option for this project.
Thanks!Is this an internal site or an public-facing site? If you are
talking about using this tool in your intranet and you have a
modern phone system in place, there may be an API to interfacing
with your phone system. We use a TAPI interface to create a phone
dialer so our callcenter agents can dial a phone number on their
phone just by clicking on a link. I'm pretty sure there are a bunch
of freeware/shareware TAPI COM objects you can use floating around
the interwebs (If your phone system supports TAPI).
If you are talking about a public-facing website, then I'm
afraid I can't offer much advice other than to check out the Java
Communications lead that Ted gave you. -
How do you determine what version of PHP is on the cold fusion server
I am trying to find out what version of PHP is on my cold
fusion server, how do I do this? Does coldfusion come with
PHP?In the C:\Windows folder, locate the file called php.ini and
open it in Notepad.
<?php phpinfo() ?>
I answered it myself. Maybe it can help someone else. -
Can I use Replace function in a decode??
Hello,
I am trying to use replace function inside a Decode Function,
Here is how I am doing it:
select
SUBSTR (
DECODE (
IH.DRVD_ALT_MAIL_ADDR_PRIM_FLAG,
'N',
REPLACE (
ih.subs_addr_1
|| ' '
|| ih.subs_addr_2
|| ' '
|| ih.subs_city
|| ','
|| ih.subs_state_code
|| ' '
|| ih.subs_zip_code,
'Y',
REPLACE (
IH.PRINT_ALT_MAIL_ADDR_LINE_1
|| ' '
|| IH.PRINT_ALT_MAIL_ADDR_LINE_2
|| ' '
|| IH.PRINT_ALT_MAIL_ADDR_LINE_3
|| ' '
|| IH.PRINT_ALT_MAIL_ADDR_LINE_4
|| ' '
|| IH.PRINT_ALT_MAIL_ADDR_LINE_5
|| ' '
|| IH.PRINT_ALT_MAIL_ADDR_LINE_6,
) 1,
50
address from x
Can anyone please tell me what am I doing wrong here, It always gives me an error about missing a right parenthesis.
Thanks in advance.Hi Jimmy,
Looks like you are missing the first comma in the SUBSTR function
SELECT SUBSTR (
DECODE (
ih.drvd_alt_mail_addr_prim_flag,
'N', REPLACE (
ih.subs_addr_1
|| ' '
|| ih.subs_addr_2
|| ' '
|| ih.subs_city
|| ','
|| ih.subs_state_code
|| ' '
|| ih.subs_zip_code,
'Y', REPLACE (
ih.print_alt_mail_addr_line_1
|| ' '
|| ih.print_alt_mail_addr_line_2
|| ' '
|| ih.print_alt_mail_addr_line_3
|| ' '
|| ih.print_alt_mail_addr_line_4
|| ' '
|| ih.print_alt_mail_addr_line_5
|| ' '
|| ih.print_alt_mail_addr_line_6,
), -- HERE
1,
50
address
FROM xRegards
Peter -
Replace() function doesn't work in Application Designer?
I'm using PeopleSoft Application Designer 8.51. I'm trying to do a simple Replace function so I can escape single quotes rather than allow them to blow up the sql query.
&deptid = Replace(&deptid, "'", "''");
App Designer chokes when I hit Save: "Invalid function parameter type. (2,19)"
According to the docs I'm using this correctly: http://docs.oracle.com/cd/E26239_01/pt851h3/eng/psbooks/tace/book.htm?File=tace/htm/tace14.htm#H4095
Even if I try to execute the example right out of the documentation, I get the same error: REPLACE("StringFun", "Fun", "Number");
Is this a bug in app designer? REPLACE is a super common thing, it's not something obscure. How can this not work?
Thanks in advance.I figured this out. “Replace” is a strange duck function that relies on offsets. “Substitute” is the magic I needed, works just like I was expecting Replace to work. The documentation I was reading on Replace was for “ PeopleSoft Analytic Calculation Engine” rather than peoplecode. I’ll pay closer attention to that next time. Maybe this will help someone else...
Maybe you are looking for
-
Material download to CRM from R/3
Materials created in R/3 are downloaded via the MBDoc PRODUCT_MAT . In this BDoc there is a structure called COMM_PROD_VAR whose description says variant data. The same structure is present in SBDoc as PRDCT_OBJECT. In this the segment CUCFG
-
How to make the option none in the payment information from app store
how to make the none option in payment information in app store??????using iphone i made a purchase from my card then after i tried to make another purchase that is free but while doing this a massege appears "review your payment information" then it
-
We have about 20% of our workstations that are not getting the ZCM update to version 10.0.3. They are still at version 10.0.1. Is there any way to get a report showing all of these workstations? The console is just too slow to have to click on Config
-
Cross Tab export : Excel Data Only - Row headings are *bottom* aligned?
Hi All, Having a problem with Crystal 11 / BOXI. I have a Cross Tab working fine that has four Row groupings (labels on the left). In Preview mode, it looks as expected. Row #1 label appears on line 1. Row #1 label shows blank on line 2,3,4 etc until
-
Missing apps within creative cloud manager
Hello, I decided to remove Dreamweaver CS6 as I use Dreamweaver CC, and now when I open creative cloud the 'Home' tab shows what's installed but the 'Apps' tab is empty and displays a 'download error' but no code and yet does say contact customer sup