Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Cory P. #1
CFC accessor method inserting carriage returns
I've created a bean type object called userBean. I query a Microsoft SQL
Server database and populate the bean object with the data.
userBean.setLastName(my_query.lastName);
When I use the accessor method, the data has a carriage return prepended to it.
[#userBean.getLastName()#]
A CFOUTPUT reveals
[
Phillips]
Has anyone seen anything like this? This is very annoying when working with
forms. I would rather abondon the idea of CFC's over injecting code into my
accessor methods to trim all white space characters, just because I don't trust
the integrity of CFCs.
I have used CFC's very little but I've done lots of object oriented
programming in Java and Python.
<cfquery name="load_user" datasource="#DATA_SOURCE#">
select *
from users
where uid = 1
</cfquery>
<cfscript>
userBean = createObject("component",
"#COMPONENT_URL#.gov.nasa.user_bean");
userBean.setFirstName(load_user.firstName);
userBean.setLastName(load_user.lastName);
userBean.setLoginId(load_user.loginId);
</cfscript>
<cfoutput>
Before[#userBean.getLastName()#]After
</cfoutput>
-------- Sniplet of Bean CFC -----------------
<cfcomponent>
<cfset this.lastName = "" />
<cffunction name="setLastName" returntype="void" access="public">
<cfargument name="lastName"
type="string"
required="true"
hint="The users last name">
<cfset this.lastName = #arguments.lastName# />
<cffunction name="getLastName" returntype="string" access="public">
<cfreturn this.lastName />
</cffunction>
</cffunction>
</cfcomponent>
Cory P. Guest
-
Removing carriage returns...
Here is the code that I am using to try and remove the Carriage Returns and Line Feeds and replace them both with spaces: ... -
replacing carriage returns in file
Hi, I have a file that I want to import into excell. In order to do that it must be delimited in some manner, because currently it is formatted... -
XML, carriage returns and special characters.
Hi, I'm trying to add dinamic content to my site using Flash and XML. Here is an example: <?xml version="1.0" encoding="utf-8"?> <PHOTOS>... -
replacing carriage returns?
so... i'm trying to remove all carriage returns in the input i get from GET, and am trying to replace them with three dots... however, this... -
Extra carriage returns - why?
John Andrews wrote: From previous post in thread: perl -pe 's/NEVERFOUND/NEVERFOUND/g' < foo > bar Hmmmmmm...I was unable to duplicate... -
Cory P. #2
Re: CFC accessor method inserting carriage returns
Update - this appears to produce the more desired result. The myLastName
variable does not contain the carriage return. Why would setting a local
scaler variable produce different results?
<cfset myLastName = #userBean.getLastName()# >
<cfoutput>
Before[#myLastName#]After
</cfoutput>
-------------- Results ---------------------------
Before[Phillips]After
Cory P. Guest



Reply With Quote

