Re: More Complicated RegEx Replace

2012-07-02 Thread Peter Boughton

 This is the replace statement a regex guru gave me 
 to wrap a variable found in a string in a span tag. 

Not sure you can call them a guru when the only piece of regex used is a pair 
of parentheses which are entirely unnecessary. *shrug*

Here's a simpler version that does exactly the same thing:

REReplaceNoCase
( answer
, search_string
, 'span class=keyword\0/span'
, 'all'
)

However, what that isn't doing is escaping potential regex metacharacters 
inside search_string (which could then result in unexpected behaviour).

If you can't guarantee there will not be any metacharacters present, you need 
to do this:

REReplaceNoCase
( answer
, search_string.replaceAll('[$^*()+\[\]{}.?\\|]','\\$0')
, 'span class=keyword\0/span'
, 'all'
)

(Which prefixes the relevant characters with a backslash to escape them.)


Anyhow, as for your actual problem, regex is not a good tool for parsing HTML 
(which is what you're asking to be done by excluding tag attributes from 
matching).

What you need to do is use a HTML parsing library, such as jSoup, to isolate 
the text segments within HTML tags, and loop through performing your replace 
operation on each of those in turn (recursing down through any child tags as 
required).

Using jSoup, this can be achieved with the textNodes() method, to access the 
individual segments of text and child nodes:
http://jsoup.org/apidocs/org/jsoup/nodes/Element.html#textNodes()

If you're unfamiliar with using JARs in CF, Ben Nadel has a post on using jSoup 
with CF10:
http://www.bennadel.com/blog/2358-Parsing-Traversing-And-Mutating-HTML-With-ColdFusion-And-jSoup.htm
 


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351784
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: 3 or 5 selects related? cf7 - jquery?

2012-07-02 Thread morchella

ok i am not getting it. this is what i have
the cfc that uses JSONUtil to initialize results, but dont htink i am
passing them back?

!--- get Metric ---
cffunction name=getMetrics access=remote
 cfargument name=business_unit type=string required=yes!--- (xxa,
xxv, ET) ---
 cfset var qry_Metric = arrayNew(1)
 cfset var i = 1
  cfset var metric = structNew()
   !--- getMetrics body ---
cfquery name=qry_Metric datasource=#Application.DSN#
  SELECT metric_id, metric
  FROM chart_data
INNER JOIN metric ON metric.id = chart_data.metric_id
  WHERE 1 = 1
cfif isDefined(business_unit) AND #business_unit# NEQ 
  AND business_unit = '#business_unit#'
  /cfif
  GROUP BY metric_id
  ORDER BY metric_id
/cfquery
   cfset qry_Metric = #JSONUtil.serialize(qry_Metric)#!--- This is
serilizing in JSON? ---
   cfdump var=#qry_Metric# /
   cfreturn qry_Metric
cfloop index=i from=1 to=#arguments.business_unit*2#!--- Not
sure what this is looping?, not the query result above? ---
 cfset metric.metric = ..
 cfset metric.metric_id = i
 cfset arrayAppend(qry_Metric, metric)
/cfloop
cfreturn qry_Metric
/cffunction


---
the script on the calling page, i dont think i can returnformat json...
maybe i need to call JSONUtil  again?

//first, detect when initial DD changes
$(#business_unit).change(function() {
//get what they selected
var selected = $(option:selected,this).val();
//no matter what, clear the other DD
//Tip taken from:
http://stackoverflow.com/questions/47824/using-core-jquery-how-do-you-remove-all-the-options-of-a-select-box-then-add-on
$(#metric_id).children().remove().end().append(option
value=\\Select a Metric x/option);
//now load in new options if I picked a state
if(selected == ) return;
alert(selected); return;

$.getJSON(Training.training_trends_cf.test.cfc?method=getMetricsreturnformat=json,{business_unit:selected},
function(res,code) {
 alert(getJSON); return; alert(res); return;
var newoptions = ;
for(var i=0; ires.length; i++) {
//In our result, (metric_id)ID is what we will use for the
value, and (metric)NAME for the label
newoptions += option value=\ + res[i].metric_id + \
+ res[i].metric + /option;
}
$(#metric_id).children().end().append(newoptions);
});
});
})


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351785
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: CF Polymorphism use

2012-07-02 Thread Dan O'Keefe

Thanks Matt,

That's true, but super is limited to only one level I believe. How about if
I wanted to execute the method in the animal object?

Dan



On Fri, Jun 29, 2012 at 3:08 PM, Matt Quackenbush quackfu...@gmail.comwrote:


 Since oCat extends feline, you'd be looking for super.makeSound().

 // oCat
 function makeSound()
 {
 super.makeSound();
 }


 HTH


 On Fri, Jun 29, 2012 at 7:49 AM, Dan O'Keefe dan.oke...@gmail.com wrote:

 
  I have an animal object with a method call makeSound().
 
  Then I have a feline object that extends animal with a method called
  makeSound().
 
  Then I have an object named cat that extends feline with a method called
  makeSound().
 
  If I instantiate the cat object and call it oCat, I can call
  oCat.makeSound() and get the cat sound.
 
  QUESTION IS, how do I call the makeSound() method in the feline object
 via
  the oCat handle?
 
  I am told it is possible but I have not been able to find out exactly
 how.
  I did read you need to pass a type reference to it but not sure what that
  means. Would it be oCat.makeSound(feline) ??
 
  --
  Dan O'Keefe
 
 
 

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351786
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Replace Question

2012-07-02 Thread Peter Boughton

This is a case for Regular Expressions (RegEx):

REReplaceNoCase(answer, '(#search_string#)', 'span
class=keyword\1/span', 'all')#


Heh, just seen this after the other thread, so guess I'll repeat what I said 
there:

Using parentheses is completely unnecessary. Use \0 in the replacement string 
instead.

If search_string is (for example) $10 or :) or a+b^c or whatever then 
simply using it as a regex_pattern will cause problems.
To solve this means escaping the meta-characters, for example, 
search_string.replaceAll('[$^*()+\[\]{}.?\\|]','\\$0')

Putting both those together results in:

REReplaceNoCase
( answer
, search_string.replaceAll('[$^*()+\[\]{}.?\\|]','\\$0')
, 'span class=keyword\0/span'
, 'all'
)

(Though of course, as noted in the other thread, this doesn't deal with HTML.) 


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351787
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: 3 or 5 selects related? cf7 - jquery?

2012-07-02 Thread Raymond Camden

On Mon, Jul 2, 2012 at 8:21 AM, morchella morchella.delici...@gmail.com wrote:

 ok i am not getting it. this is what i have
 the cfc that uses JSONUtil to initialize results, but dont htink i am
 passing them back?


cfset qry_Metric = #JSONUtil.serialize(qry_Metric)#!--- This is
 serilizing in JSON? ---

(I changed my mind while I wrote this, so please read it all.)

Remember though - when you call a CFC in CF7, it will either be
encoded in WDDX by default. That's why I said you probably want to
call a CFM instead. The CFM calls your CFC, gets the result,
serializes it, and outputs the JSON.

My memory is a bit vague here, but if I remember right...

CF6 let you call CFCs via AJAX, but you ALWAYS got WDDX back.
CF7 let you get WDDX or use returnformat=plain to NOT do any
translation on the result.

So... actually - and I hope this isn't too confusing now. Your CFC
should return qry_Metric as defined above.

Your URL, the one you use in Ajax, should include returnformat=plain
to tell CF Dude, don't do anything to my result. When your CFC
returns the string (JSON is a string), it should be left alone then.


-- 
===
Raymond Camden, Adobe Developer Evangelist

Email : raymondcam...@gmail.com
Blog : www.raymondcamden.com
Twitter: cfjedimaster

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351788
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: CF Polymorphism use

2012-07-02 Thread Dave Watts

 That's true, but super is limited to only one level I believe. How about if
 I wanted to execute the method in the animal object?

Presumably, the feline object already extends the makeSound method of
the animal object, right? Why wouldn't you just have the cat object
extend the makeSound method of the feline object? Why would you want
to skip a generation, so to speak? That seems like it would be poor
design.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351789
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


viewport tag question

2012-07-02 Thread Matt Williams

My apologies for the non-CF related question (though the site is
running on CF), but I know folks here are so well-rounded I'll throw
it out.

I'm struggling with getting a site to scale correctly on mobile
devices. I have tried the viewport tag with various settings, but
don't really understand the tag that well. The current code has this:
meta name=viewport content=width=960, initial-scale=1, maximum-scale=1
I have tried setting the width=device-width and it didn't seem to help.

Site in question: http://amaproracing.com/
In portrait mode on whatever device (seems consistent across various
phones and tablets), it loads with only a portion (30%?) of the width
showing. You can pinch the screen to zoom out and get the entire site.
Landscape mode seems to be ok for most devices.

Does anyone have a solid understanding of how to set the viewport tag
up so it is good in both portrait and landscape orientations?

Banging my head,

-Matt

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351790
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: viewport tag question

2012-07-02 Thread Matt Williams

Sorry, to get to the non-mobile site, you should use this url:
http://amaproracing.com/?mo=1

It's the full site that is the problem, not the mobile site.
-Matt


On Mon, Jul 2, 2012 at 10:19 AM, Matt Williams mgw...@gmail.com wrote:
 My apologies for the non-CF related question (though the site is
 running on CF), but I know folks here are so well-rounded I'll throw
 it out.

 I'm struggling with getting a site to scale correctly on mobile
 devices. I have tried the viewport tag with various settings, but
 don't really understand the tag that well. The current code has this:
 meta name=viewport content=width=960, initial-scale=1, maximum-scale=1
 I have tried setting the width=device-width and it didn't seem to help.

 Site in question: http://amaproracing.com/
 In portrait mode on whatever device (seems consistent across various
 phones and tablets), it loads with only a portion (30%?) of the width
 showing. You can pinch the screen to zoom out and get the entire site.
 Landscape mode seems to be ok for most devices.

 Does anyone have a solid understanding of how to set the viewport tag
 up so it is good in both portrait and landscape orientations?

 Banging my head,

 -Matt

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351791
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: CF Polymorphism use

2012-07-02 Thread Cameron Childress

Dan-

As Dave pointed out, I'd typically make a standard assumption in most
design that each subtype would automatically call super on extended methods
/ interfaces. This would mean that each level would contain the
super.makeSound() to chain them all together as you go up the path
of inheritance.

-Cameron

On Mon, Jul 2, 2012 at 9:22 AM, Dan O'Keefe dan.oke...@gmail.com wrote:


 Thanks Matt,

 That's true, but super is limited to only one level I believe. How about if
 I wanted to execute the method in the animal object?

 Dan



-- 
Cameron Childress
--
p:   678.637.5072
im: cameroncf
facebook http://www.facebook.com/cameroncf |
twitterhttp://twitter.com/cameronc |
google+ https://profiles.google.com/u/0/117829379451708140985


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351792
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Announcement: ColdBox Developer Week - FREE training

2012-07-02 Thread Brad Wood

Team ColdBox is excited to announce an entire week of free ColdBox training 
coming up at the end of this month-- July 23rd through 27th.  We've lined up 15 
sessions of beginner and advanced topics from ColdBox experts all around the 
world.  Please check out the session schedule on the official CBDW page of our 
site and get signed up now.

http://www.coldbox.org/cbdw

What the heck IS ColdBox?  ColdBox is an event-driven, convention-based 
ColdFusion Development Platform.  
Read more about ColdBox here:
http://www.coldbox.org/about

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: b...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351793
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: 500 - Internal server error

2012-07-02 Thread Gonzo Rock

RightOn you guys!

Turns out that both Justin and Michael's tips were successful...
either or both of the switches together made the the cferror routine
that we built run properly. Yes! and Thank You!  Now as for Carl's
parameter limit... don't know how that might be useful unless of
course we run into this again and have a zillion parameters being
passed to CF ;-)

I would think we would want to pass the typical IIS errors and check
that in the CFAdmin settings... but it is clearly not necessary.
However we do have it checked in all our other installs... both
Windows and Linux and all is well everywhere except with this new
install... which is apparently fixed now. So this brings up the
question now of what's the full purpose of the CFAdmin setting and
it's use with the IIS setting for Details vs Custom IIS error pages?

Thanks!
Gonzo

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351794
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: 500 - Internal server error

2012-07-02 Thread Justin Scott

 ... So this brings up the question now of what's the full
 purpose of the CFAdmin setting and it's use with the IIS
 setting for Details vs Custom IIS error pages?

Basically IIS is looking at the response codes from an application and
when it sees anything other than normal 200 (OK) code (and some
others, such as 30X redirects), it will look at the error handling
settings to see how it should respond to the user.  If the custom
errors are enabled for the visitor in question, then it will use
whatever is set in the IIS settings (e.g. display a static HTML file,
a generic error code, redirect to a page, etc.).  This is to prevent
any sensitive information from leaking out of the server in the case
of an error (such as the info that would normally come from a robust
error handling exception in ColdFusion).  IIS is helping to protect
the security of the application and handle error conditions for you.

The setting in the CF admin controls what status code is sent out when
there is an error.  Normally when CF encounters an error it will send
a 500 (Internal Server Error) code which IIS then intercepts and
handles as described above.  If you change this setting, you can have
CF send a 200 (OK) code even in the event of an error which bypasses
the IIS error handling routines and allows whatever output CF
generates (page, error page, custom error handler output, etc.) to get
through just like any other regular content.  IIS just sees it as a
normal response at that point and allows it through.


-Justin

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351795
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: 500 - Internal server error

2012-07-02 Thread Russ Michaels

for CF sites it should be fine to simply enable errors in IIS as all your
errors are going to be returned by CF anyway.
The only exception would be if your running a mixed site with CF and other
technology.
In which case as long as you separate your technologies into different
folders, you can put a web.config into each folder with different settings.
So CF could have errors enable and asp.net disabled for example.
Or you could simply create a custom error on IIS and have
that displayed instead.

have you tried using the sitewide error template in CF, I don't think
that causes the server 500 error.


On Mon, Jul 2, 2012 at 6:56 PM, Justin Scott leviat...@darktech.org wrote:


  ... So this brings up the question now of what's the full
  purpose of the CFAdmin setting and it's use with the IIS
  setting for Details vs Custom IIS error pages?

 Basically IIS is looking at the response codes from an application and
 when it sees anything other than normal 200 (OK) code (and some
 others, such as 30X redirects), it will look at the error handling
 settings to see how it should respond to the user.  If the custom
 errors are enabled for the visitor in question, then it will use
 whatever is set in the IIS settings (e.g. display a static HTML file,
 a generic error code, redirect to a page, etc.).  This is to prevent
 any sensitive information from leaking out of the server in the case
 of an error (such as the info that would normally come from a robust
 error handling exception in ColdFusion).  IIS is helping to protect
 the security of the application and handle error conditions for you.

 The setting in the CF admin controls what status code is sent out when
 there is an error.  Normally when CF encounters an error it will send
 a 500 (Internal Server Error) code which IIS then intercepts and
 handles as described above.  If you change this setting, you can have
 CF send a 200 (OK) code even in the event of an error which bypasses
 the IIS error handling routines and allows whatever output CF
 generates (page, error page, custom error handler output, etc.) to get
 through just like any other regular content.  IIS just sees it as a
 normal response at that point and allows it through.


 -Justin

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351796
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: CF Polymorphism use

2012-07-02 Thread Dan O'Keefe

Thanks Cameron, that makes sense.

I agree with Dave's position and guess I should have pointed out I do not
have a valid use case for this, but only trying to sort through the
limitations of a question posed to me.

Thanks,
Dan


On Mon, Jul 2, 2012 at 7:56 AM, Cameron Childress camer...@gmail.comwrote:


 Dan-

 As Dave pointed out, I'd typically make a standard assumption in most
 design that each subtype would automatically call super on extended methods
 / interfaces. This would mean that each level would contain the
 super.makeSound() to chain them all together as you go up the path
 of inheritance.

 -Cameron

 On Mon, Jul 2, 2012 at 9:22 AM, Dan O'Keefe dan.oke...@gmail.com wrote:

 
  Thanks Matt,
 
  That's true, but super is limited to only one level I believe. How about
 if
  I wanted to execute the method in the animal object?
 
  Dan
 


 --
 Cameron Childress
 --
 p:   678.637.5072
 im: cameroncf
 facebook http://www.facebook.com/cameroncf |
 twitterhttp://twitter.com/cameronc |
 google+ https://profiles.google.com/u/0/117829379451708140985


 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:351797
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm