arrgh 22 Posting Whiz

That's not why it's failing. Just about everything is stored as a string in CF. Trimming only removes leading/trailing white space. If the field has any other value, it'll be evaluated by IsDate. So trimming does not buy you much here either.

What's an example of these "numeric" date values that are failing? Seems like you're trying to pass in something isDate doesn't understand.

isDefined is useless

With forms it's useful for checkboxes, radio buttons or multi-select lists. ie Fields that don't always exist.

arrgh 22 Posting Whiz

<cfif NOT ISDEFINED("form.Effective_Date")>

Text fields always exist. So IsDefined will do nothing.

the "AND isDate(form.Effective_Date)" should return a true or false

It will, but the code's not using IsDate ;-) It's checking if the value is an empty string "". Trim() the field and use IsDate instead.

arrgh 22 Posting Whiz

There is if you're passing reserved characters (like spaces) without escaping them. You're supposed to url encode them .. not hope the browser does it for you automatically ;)

arrgh 22 Posting Whiz

No. Nothing wrong with using reserved characters. As long as they're encoded properly.

arrgh 22 Posting Whiz

What's going to happen when the records increase to 35K, then 40K? Trying to do it all at once isn't scalable. The right way to do things is break the process into smaller batches.

arrgh 22 Posting Whiz

hmm not sure I'm following your first bit.

The 1st part was just, if you want to use CF code ... then use a .cfm page ;-)

edit the htaccess file I think to allow php scripts to run and be parsed in html files

That's the second option. You can do the same thing w/CF. Just not with the htaccess file. But personally I think that's a bad idea. Making such a global change for one small page is .. unwise IMO.

arrgh 22 Posting Whiz

Personally that's too many popup messages for me ;-) But what you're describing is done with javascript, not CF.
http://www.w3schools.com/js/js_popup.asp

You can incorporate the js into your form. You just have to tie it to the right event. Like in your form's OnSubmit() event.

arrgh 22 Posting Whiz

That's too much for 1 page. Set it up as a scheduled task. Have the task pull 500 records. Process them, then have the task reschedule itself if there's more records to process.

arrgh 22 Posting Whiz

Not sure why it needs to be in an html page. Creating a small .cfm script that can be used from any page is the simplest. The other option is to configure the CF server to process .html pages (ie so any cfm code is executed). But that's a major change with big ramifications. So I'd think twice before doing it ..

arrgh 22 Posting Whiz

Any time parameter values contains special characters, you have to encode them ie Use UrlencodedFormat

arrgh 22 Posting Whiz

Hm... it could still be a network problem or just the db going away. That type of error isn't easy to diagnose. You'd need a packet sniffer. So happens there's a similar problem with the built in driver. A great thread about it here:

http://forums.adobe.com/message/3396333

Just for kicks, you might try the suggestion of adding a validation query to your dsn settings. See if that has any effect.

arrgh 22 Posting Whiz

Is the db on the same server as CF?

arrgh 22 Posting Whiz

Looks like you're using the jtds driver. I usually use the built in one (though it has problems too). Honestly I've never seen that specific error. Google only returns 94 results for it ;-) It's possible it's a weird driver problem. But connection reset errors could also be caused by a legitimate problem reaching the db. For example, if the db were on another server which couldn't be reached for some reason. ie Temporary network problems.

You could try switching drivers, but first does the error go away if you refresh the same page?

arrgh 22 Posting Whiz

The error means there's some problem connecting to your database. The cause could be a lot of things.

- has something changed with your db recently
- which db type are you using?
- does the error happen every time or just sporadically?

arrgh 22 Posting Whiz

Now the problem is whenever the user reregisters again the ids wont match

Registering is a one time event. It should never happen more than once.

its really problematic because whenever the user forgets the password user is registering again such that there are duplicate entries.

The application shouldn't allow that to happen. That's what "Forgot your password" links are for ;-)

Assuming you're not joking about this ... truthfully it sounds like the application is doing things the wrong way. Do a search on coldfusion login tutorial. There are plenty of examples on the right way to design login pages.

Good Luck

arrgh 22 Posting Whiz

Styling dynamic values is difficult at best. You have to at least know what type of value you're working with. And it has to be kept separate from any html. Otherwise, it's impossible to do it reliably imo.

arrgh 22 Posting Whiz

I've had those weeks before .. and they're hell. But since you are parsing/manipulating html, sad to say that's par for the course, lol.

Yeah, lately there's almost no action here. Adobe's forum is the go-to-place I guess.

arrgh 22 Posting Whiz

I would answer, but looks like you're already being helped on the adobe forums :P

arrgh 22 Posting Whiz

return a reference to this component

I just meant return the object you created. That's basically what <cfreturn this> does. When used inside a component, THIS means "the component itself".

<cfcomponent>
<cffunction name="init" output="false" returntype="MyComponent">
  ....
    <!--- Return the component so the calling page can use it --->
     <cfreturn this>
  </cffunction>
</cfcomponent>

The reason you do that is so the calling page can use the component's functions

<!--- "myObj" now contains a MyComponent object --->
<cfset myObj = createObject("component", "MyComponent").init(dsn="My DSN")>

<!--- So you can call any of MyComponent's functions --->
<cfset result = myObj.someFunctionName()>
arrgh 22 Posting Whiz

init() is just a standard convention most people adopt with components. The init() function initializes any variables needed by the component's functions. Then returns a reference to the current component.

ie

Test.cfm
<cfset myObj = createObject("component", "MyComponent").init(dsn="My DSN")>

MyComponent.cfc
<cfcomponent>
    <cffunction name="init" output="false" returntype="MyComponent">
         <cfargument name="dsn" type="string">
         <!--- initialize variables used within this component --->
         <cfset variables.dsn = arguments.dsn>
         <!--- return a reference to this component --->
         <cfreturn this>
    </cffunction>
</cfcomponent>

And also scopes(VARIABLES and THIS) while writing an init function in a component

The documentation is a better source of information on the VARIABLES and THIS scope. But the main difference is VARIABLES is private. Values stored in that scope are only available to functions w/in the component. The THIS scope is public. Anything you store in THIS can be viewed or changed by the component *and* the calling page. Usually the VARIABLES scope is preferred.

http://livedocs.adobe.com/coldfusion/8/buildingComponents_29.html

arrgh 22 Posting Whiz

Like I said, I think have to html escape the tags to preven them from being evaluated
ie < becomes &lt; and > becomes &gt;

But I'm not sure even that would work. What are you trying to do exactly?

arrgh 22 Posting Whiz

The only way I know of is to use CFSAVECONTENT. But IIRC you have to escape CF tags. Otherwise, they're evaluated immediately instead of being treated as a plain string.

<cfsavecontent variable="putme">
.. whatever code you want here. 
...tags will be evaluated unless they're escaped 
</cfsavecontent>
<!--- see what the contents look like ... --->
<cfdump var="#putme#">

<cfset #contents# = #Replace(contents, "<!--ReplaceMe -->", "#putme#", "all")#>

Btw: You don't need all those excess # signs!

<cfset contents = Replace(contents, "<!--ReplaceMe -->", putme, "all")>
arrgh 22 Posting Whiz

Glad you figured it out. Just be aware CONTAINS matches substrings too. So sometimes it matches more than you want it too. Also, if the cffile code is the same for all 3, just write it once. The code'll be simpler

ie

<CFDIRECTORY Name="GetFiles" ACTION="List" DIRECTORY="D:\home\wwwroot\technet\Uploads\" filter="*.pdf">
<cfset mydatetime=now()>
<!--- removed excess # signs --->
<CFLOOP QUERY="GetFiles">
<cfif GetFiles.Name Contains 'ABCInc'>
  <cfset Property = 'ABC'>
<cfelseif GetFiles.Name contains 'XYZ'>
  <cfset Property = 'XYZ'>
<cfelse>
  <cfset Property = 'BadCollection'>
</cfif>
<cffile action="rename"
    source="D:/home/wwwroot/technet/Uploads/#GetFiles.Name#"
    destination="D:/home/wwwroot/technet/property/#property#/temp/#DateFormat(DateAdd('d', -1, MyDateTime),'mm dd, yyyy')# #Name#">

</CFLOOP>
arrgh 22 Posting Whiz

Ok I like the sound of that much better...lol

Since I'm often on the bottom rung, I've learned to "adjust" my perception of things ;-)

arrgh 22 Posting Whiz

... or it makes you "smart", me "smarter" and them "friggin geniuses". It's all in the spin ;-)

arrgh 22 Posting Whiz

I actually went to houseoffusion.com

Smarter brains than mine live there. So hopefully you'll have better luck. lol

arrgh 22 Posting Whiz

Btw ... if you're going to open another question on this, I'd suggest including *exactly* what you happen, with specific variable and field names, etc.. Don't make the reader guess ;-)

arrgh 22 Posting Whiz

If I knew more jquery I'd say change it make the field names unique. Then you could process it easily as product1,product2, etc.. But that's beyond my skills for now ;)

Yeah, there's an art to asking a "good" question. I'm fine with small stuff. But I really suck asking about big conceptual stuff. lol. Usually people have no clue what I mean. Some people are amazing at it. Their descriptions simple and concise. They get great answers ... when I couldn't even form the question...let alone the answer. lol

arrgh 22 Posting Whiz

Well I tried that.,...I think...lol. I clicked the ajax function button which outputted the "list" as needed, but then when I click my page submit button, I still got a data undefined error.

Right. Because that variable doesn't exist... The ajax function and your <form> *don't* send the same data the same way

Ajax uses-> URL scope
Your <form> uses-> FORM scope

Ajax sends a complex structure -> URL.data[ItemName].vendorName ...etc...
Your <form> sends simple strings -> FORM.vendor, FORM.product, etc..

ie exactly what's in your <form>
<input type="text" class="vendor-input" name="vendor" />
<input type="text" class="product-input" name="product" />

You can't just plug the ajax into a larger <form>, POST it have it work right out of the box. You won't get an error, but your code isn't set up to handle it. It's something you have to add.

At this point I'm totally lost ;-/ ... I thought you were trying to do a simple preview of JUST the vendor/product stuff. But it's starting to sound like much more than that ... There's a lotta stuff on that page you linked. If you're trying to incorporate this section (vendors/products) with that whole big form .. you've got your work cut out for you. I'm sure it's possible, but it's beyond my skills. And with my brain mainly focused on my work, I've kinda lost track of what you're trying to do at this point ;-)

arrgh 22 Posting Whiz

Now one thing I will mention is that I have other form elements on this page.

Yeah, but they're not inside the same <form> right? So you could process that form data separately, like have a "preview" and "submit" button for just that form.

arrgh 22 Posting Whiz

You shouldn't need a query. Just use string functions as you loop through #GetFiles#. Either use left() to get X characters, or if there's always a space after the client name, use list functions. Then grab the file extension and create the new file name

<!-- split for readability --->
<cfset clientName = listFirst("abc xxxxx.pdf", " ")>
<cfset ext     = listLast("abc xxxxx.pdf", ".")>
<cfset theDate = DateFormat(DateAdd('d', -1, MyDateTime),'mmmm dd, yyyy'))>
<cfset newName = theDate & clientName &"."& ext>

It should never run across a file that already exist as it uses the date as part of the file name when it renamed. And if it does it will make it unique when it renames

Well date alone isn't as unique as date + timestamp. As far as renaming, it'll overwrite any existing file. If you don't want that, you have to handle the making it unique yourself.

arrgh 22 Posting Whiz

It's doable with string and date functions. But do the files always follow a standard pattern

ie file name = {clientName}_xxxxxx.pdf?

In your example they don't. abc_activity.pdf and client ABCInc. Also, if the file name already exists in the client directory, how do you want to handle it?

arrgh 22 Posting Whiz

Your question's a little confusing. What's your real goal in plain english, not code? To identify files by client, or somethin else ...?

Also, what is a #Property# in this context?

arrgh 22 Posting Whiz

lol. I didn't mean to sound like you don't know how ajax works. Just that you weren't using the form as it was intended to work. ie You were using a submit button to do a plain form post the old way. Instead of a plain button to do an ajax call (method=get) and display the content on the same page.

So, why then couldnt I take the code...jquery/ajax...out of that page, paste it into my template, using the same builderAction.cfm "action" within the ajax function, and display it that way.

Sorry .. I'm brain dead today. Not sure what you mean by template. ie Are you talking about having everything (jquery and action) on the same page? That should work as long as you structure it correctly.

arrgh 22 Posting Whiz

Your choice. I think you're totally misunderstanding how the example's supposed to work, lol. Forget about the code for a sec and think about what the 2 pieces of code are doing conceptually.

You're trying to do it old style
page1.cfm => go to => page2.cfm to see preview

The whole point of ajax is to avoid leaving the page. So users can see preview changes quickly, and you don't have to worry about maintaining the state form page to page. Technically you still send data to page2.cfm. But you display the results on the original page. It's no more complex than updating the content of an element with javascript.

document.getElement('myDiv').innerHTML = "See I just changed the content!";
arrgh 22 Posting Whiz

Well think about it :) Your code isn't doing the same thing as the example. The example sends data via ajax and displays the results w/out even leaving the current page. You're doing a form post, which obviously leaves the page. Not to mention sends the data in the FORM, not URL, scope. So obviously the sample code won't work.

arrgh 22 Posting Whiz

I've no idea what your final code looks like. So I'm not sure what to suggest :)

arrgh 22 Posting Whiz

It's actually pretty easy. Just deserialize the results.

<cfset results = deserializeJSON(url.data)>

Each "item" is a structure. They "key" is the item name, and the "value" are the details (category, vendors, etc..). So loop through it like in the sitepoint article.

<cfloop collection="#results#" item="itemName">
    <cfset item = results[itemName]>
    <cfdump var="#item#" label="Item Name #itemName#">
</cfloop>

If you look at the dump of each "item", that structure contains 2 keys: "category" and "vendors". Category name is a simple string you can access using #item.category#

Now "Vendors" is another structure. The "key" is a vendor name and the "value" is an array of products. To extract the values, loop through it the same way

<cfloop ....>
   ... 
   <cfloop collection="#item.vendors#" item="vendorName">
       <cfset productArray = item.vendors[vendorName]>   
       <cfdump var="#productArray #" label="Products for vendor: #vendorName#">
   </cfloop>
  ...
</cfloop>

Then loop through the product array to get each value. For CF8+ it's a simple "array" loop

....
   <cfloop array="#productArray #" index="productName">
       ...do something with #productName#....
   </cfloop>
....

Obviously you have to *do* something with the values. But now that you see how to extract them, the rest is easy.

arrgh 22 Posting Whiz

Hey, I just tried it .. and that's a fantastic example! I'm not smart enough to write it, but it's great. Everything's organized into a structures and arrays. Just loop through it and extract what you need.

arrgh 22 Posting Whiz

lol. The confusion is spreading ;-)

But I guess I took his response as him being highminded. I said I wasnt mad, and I'm not, but just felt like if someone tells you your doing something wrong and then offers some code for you to "use", then they ought to be willing to help you further long if you've already said "it's over my head".

Yeah, but you have to articulate "what specifically" you need help with :-) ie "I've tried X code and expected Y results. But instead I'm getting Z results." Otherwise people don't know how to answer you. Or worse it sounds like saying "write the code for me". I admit the guy was definitely blunt. But I don't think he was trying to be a jerk. Otherwise, he wouldn't have bothered putting together a custom example for you in the first place :-)

I'm not a jquery guru. So I don't completely understand his sample either. But if it were me, I'd run the example and post it to an action page. Then dump the results and go from there. If it's just structures and arrays, which I think it is, it might not be so bad and I might actually be able to help!

arrgh 22 Posting Whiz

I hope you didn't take my remarks the wrong way. I just didn't have a clue where to begin with your question on the other forum. As strange as it sounds, it was as overwhelming to me as jquery probably is to you right now ;-)

arrgh 22 Posting Whiz

That's not javascript. It's cfscript. You can't use CF <tags> in cfscript. Either rewrite the code to use tags OR write a wrapper cffunction that you can call from cfscript.

This isn't for cfinvoke. But here's an example of a wrapper function for a tag
http://www.cflib.org/udf/Abort

arrgh 22 Posting Whiz

Yeah, I saw that thread. Being fair that's not what he was saying :P I think the questions were just to broad/ambiguous to be answered. I know some of the background, and even I was intimidated by the sheer scope of it ;-) No joke, I wasn't even sure what the question was .. let alone where to begin trying to answer it.

I think we both love learning and teaching. But there's only so much you can do in a forum post. Forums are good for small, specific questions. Broad comments like "how do I make it work" or "tried everything, and nothing works" aren't questions that can be answered. They just sound like someone is asking others to write the code for them. I know that not's what you were doing. I'm just trying to explain why they responded the way they did. I think if you'd tried the code, and come back with a specific problem (however small), the response would have been better.

arrgh 22 Posting Whiz

It'll only work for components. But something like the code below. See the docs for more details on cfinvoke.
http://livedocs.adobe.com/coldfusion/8/Tags_i_10.html

<cfinvoke
    component="cfcs.objectfactory"
    method="init"
    returnVariable="objFactory"
    argumentCollection="#settings#"
    >
<cfset aplication.factory = objFactory>
arrgh 22 Posting Whiz
1) <cfset myBook.author = "Teed Younger">
... or ....
2) <cfset myBook["author"] = "Teed Younger">

Personally, I prefer syntax 1 (dot notation). Either is okay unless your key name isn't a valid variable name. Like it has spaces or dashes in it ie myBook["some-author"]. Then you must use syntax 2.

arrgh 22 Posting Whiz

Figures the back slashes are actually in the code. lol. That one must have gotten past the editor.

Yeah, the article is definitely outdated. Most of it still applies. But StructInsert isn't as commonly used now as it was in 2003 Nowadays most people just use array notation. Simpler and more intuitive.

For the lazy, there's even shortcuts in CF8+. So instead of doing

<cfset myBook = structNew()>
<cfset myBook.publishYear = "2005">
<cfset myBook.ISBN= "ABCD123456">

You can do it all in one line

<cfset myBook = {publishYear = "2005", ISBN= "ABCD123456"}>

But it's mostly personal preference. For long structures, the line by line approach is perfectly fine.

arrgh 22 Posting Whiz

Btw, where is this tutorial? It sounds outdated.

arrgh 22 Posting Whiz

I followed the code exactly

I hope not ... because that code is wrong :) Two things are messing it up
1) Assuming the \\ is not a typo. Get rid of them.
2) The function is StructInsert ... not StructureInsert

But that function isn't used as much as it used to be. Most times it's simpler to just use array notion. That's my preference. But all of these are valid

<cfset StructInsert(myBook, "author", "Teed Younger", true)>
   ... or ....
   <cfset myBook.author = "Teed Younger"> 
   ... or ....
   <cfset myBook["author"] = "Teed Younger">

<cfset a = StructureInsert(myBook, "author", "Teed Younger", 1)>

It's not the cause of the error, but there's no need to capture the result if you're not using it.

<cfset StructInsert(myBook, "author", "Teed Younger", true)>
arrgh 22 Posting Whiz

One i use the single path link without database it works, but with database dynamic link, it wont play.

You mean it works with a hard coded path but not when you use variables? Do a view source and look at the html generated. Compare it to the hard-coded-working version and see how it differs.

arrgh 22 Posting Whiz

Whether you trash the existing code or not is up to you. I suspect their point was that doing all this parsing and html coding manually is... well somewhat unusual ;-)