ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 4th, 2005, 03:19 PM
Bastion Bastion is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 181 Bastion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 4 h 25 m 11 sec
Reputation Power: 5
CFC and HTML

I'm building an application. I have a table full of teams. I will have a select box containing said teams on different pages. Like so:

<!--- the query --->
<cfquery name="getTeams">
SELECT *
FROM team_list
ORDER BY team_title
</cfquery>

<!--- the select statement --->
<select name="sport_category">
<option value="0">No Specific Team</option>
<cfoutput query="getTeams"><option value="#ID#">#team_title#</option></cfoutput>
</select>

I'm planning to use a CFC to run the getTeams query (the query that pulls the team information). However, what would be the best way to construct the select box code?

My options, the way I see it are:
1. use an include file that contains the select box html and calls the CFC.
2. Set up the select box code as a string within the CFC and return it as a string.
3. create a custom tag.
4. Have the HTML code on every page (which I won't seriously consider).

What would be the best (and fastest way)? Is there a way to pop out HTML using a CFC that I haven't found in my research?

Any help is appreciated!

Reply With Quote
  #2  
Old March 4th, 2005, 03:59 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 25 m 55 sec
Reputation Power: 53
CFC's are primarily meant to handle business logic, not presentation. If you want to use a CFC to provide the query, simply write a CFC method that returns a query and call it from your form.

<cfset getTeams = myCFC.getTeams() />
<select name="sport_category">
<option value="0">No Specific Team</option>
<cfoutput query="getTeams"><option value="#ID#">#team_title#</option></cfoutput>
</select>

Or if you are using MVC, have your controller call the method and then your display page won't even have to know that a CFC is being used.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old March 7th, 2005, 08:37 AM
Bastion Bastion is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 181 Bastion User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 4 h 25 m 11 sec
Reputation Power: 5
Quote:
Originally Posted by kiteless
CFC's are primarily meant to handle business logic, not presentation. If you want to use a CFC to provide the query, simply write a CFC method that returns a query and call it from your form.

<cfset getTeams = myCFC.getTeams() />
<select name="sport_category">
<option value="0">No Specific Team</option>
<cfoutput query="getTeams"><option value="#ID#">#team_title#</option></cfoutput>
</select>


That's what I thought. I was just hoping I missed something in my researcy I'll probably use an include so at least the select box code is in one location. Thanks for your help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > CFC and HTML


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT