Search Results

Search found 4 results on 1 pages for 'cfwheels'.

Page 1/1 | 1 

  • Is this a good approach to dealing with tagging?

    - by Mel
    Can this code be optimized or re-factored? Is this an optimal approach to tagging? The following code is a callback in my posts model. It creates a record that associates a tag with a post in a QuestionsTags joiner table. When necessary, if a given tag does not already exist in the tags table, the function creates it, then uses its id to create the new record in the QuestionsTags table. The difficulty with this approach is the QuestionsTags table depends on data in the tags table which may or may not exist. The function assumes the following tables: tags(id, tagName), posts(tags) // Comma delimited list questionsTags(postId, tagId) The idea is to loop over a delimited list of tags submitted with a post and check to see if each tag already exists in the tags table If tag exists: Check to see if there's already a QuestionTag record for this post and this tag in the QuestionTags table. If yes, do nothing (the association already exists) If no, create a new QuestionTag record using the id of the existing tag and the postId If tag does not already exist: Create the new tag in the tags table Use its id to create a new QuestionsTags record Code /** * @hint Sets tags for a given question. **/ private function setTags() { // Loop over the comma and space delmited list of tags for (local.i = 1; local.i LTE ListLen(this.tags, ", "); local.i = (local.i + 1)) { // Check if the tag already exists in the database local.tag = model("tag").findOneByTagName(local.i); // If the tag exists, look for an existing association between the tag and the question in the QuestionTag table if (IsObject(local.tag)) { local.questionTag = model("questionTag").findOneByPostIdAndTagId(values="#this.postId#,#local.tag.id#"); // If no assciatione exists, create a new QuestionTag record using the tagId and the postId if (! IsObject(local.questionTag)) { local.newQuestionTag = model("questionTag").new(postId = this.id, tagId = local.tag.id); // Abort if the saving the new QuestionTag is unsuccesful if (! local.newQuestionTag.save()) { return false; } } } // If the tag does not exist create it else { local.newTag = model("tag").new(tagName = local.i, userId = this.ownerUserId); // Abort if the the new tag is not saved successfully if (! local.newTag.save()) { return false; } // Otherwise create a new association in the QuestionTags table using the id of the newly created tag and the postId local.newQuestionTag = model("questionTag").new(postId = this.id, tagId = local.newTag.id); // Abort if the new QuestionTag does not save correctly if (! local.newQuestionTag.save()) { return false; } } } } FYI: I'm using CFWheels in my application, which explains the ORM functions used.

    Read the article

  • Is it ok to store large objects (java component for example) in an Application variable?

    - by DustMason
    I am developing an app right now which creates and stores a connection to a local XMPP server in the Application scope. The connection methods are stored in a cfc that makes sure the Application.XMPPConnection is connected and authorized each time it is used, and makes use of the connection to send live events to users. As far as I can tell, this is working fine. BUT it hasn't been tested under any kind of stress. My question is: Will this set up cause problems later on? I only ask because I can't find evidence of other people using Application variables in this way. If I weren't using railo I would be using CF's event gateway instead to accomplish the same task.

    Read the article

  • How can i split up a component using cfinclude and still use inheritance?

    - by rip747
    Note: this is just a simplized example of what i'm trying to do to get the idea across. The problem I'm having is that I want to use cfinclude inside cfcomponent so that i can group like methods into separate files for more manageability. The problem I'm running into is when i try to extend another component that also uses cfinclude to manage it's method as demostrated below. Note that ComponentA extends ComponentB: ComponentA ========== <cfcomponent output="false" extends="componentb"> <cfinclude template="componenta/methods.cfm"> </cfcomponent> componenta/methods.cfm ====================== <cffunction name="a"><cfreturn "componenta-a"></cffunction> <cffunction name="b"><cfreturn "componenta-b"></cffunction> <cffunction name="c"><cfreturn "componenta-c"></cffunction> <cffunction name="d"><cfreturn super.a()></cffunction> ComponentB ========== <cfcomponent output="false"> <cfinclude template="componentb/methods.cfm"> </cfcomponent> componentb/methods.cfm ====================== <cffunction name="a"><cfreturn "componentb-a"></cffunction> <cffunction name="b"><cfreturn "componentb-b"></cffunction> <cffunction name="c"><cfreturn "componentb-c"></cffunction> The issue is that when i try to initialize ComponentA I get an the error: "Routines cannot be declared more than once. The routine a has been declared twice in different templates." The whole reason for this is because when you use cfinclude it's evaluated at RUN TIME instead of COMPILE TIME. Short of moving the methods into the components themselves and eliminating the use of cfinclude, how can i get around this or does someone have a better idea splitting up large components?

    Read the article

  • which MVC for coldfusion?

    - by mrjayviper
    newbie to MVC here. so please be gentle. I want to move one of our existing apps (currently located in http://www.companywebsitegoeshere.com/myapp1) to MVC. As can be seen in the URL, there are many apps running in the website which I intend to move at some stage. I don't have write access to the wwwroot (/var/www/html in my case) and the webserver is used by multiple developers across the company. I'm hoping I can have the MVC framework core files/folders + my app all located in in 1 subfolder. In the case of myapp1, all the filers and folders will be inside /var/www/html/myapp1 subfolder. Can you please point me to the right direction (links/guides/docs/videos/etc)? I've looked at several like cfwheels/mach-ii/fw1 but they seemed requires wwwroot access. Thanks! :)

    Read the article

1