I've got one app that uses what amounts to an embedded UDF for
generating select boxes, lists of links, and/or text lists (rather
like valuelist()) for the UI.

For good or ill, at the moment it's embedded in a business object
(it's due to be refactored) because it seemed appropriate at the time.
There are two methods for generating UI elements, one is called mList
(for Managed List - my own internal convention) and it outputs either
select/options, HTML anchor tags, or a text-only list of the DB column
relevant to that business object. It's parameterized as follows:
<cfargument name="type" default="text" hint="required to give type of
content generated">
<cfargument name="url" default="" hint="required if type=url in order
to generate links">
<cfargument name="name" default="" hint="reqired if type=select to
give select element a name property">
<cfargument name="staff_id" default="" hint="optional, will generate a
list for specificed staff_id">
<cfargument name="catch_id" default="" hint="optional, passed-in
company_id to mark selected when type=select">
<cfargument name="jump" type="boolean" default="false" hint="option,
generates a Go button and JS function for jump-style menu">
<cfargument name="style" type="string" default="" hint="optional -
supplies a style sheet class selector to include for URL or Select">
<cfargument name="startempty" default="false" type="boolean"
hint="optional - adds a blank option to start of select">

It works fantastic, and I'm using it for probably 5 separate objects
on innumerable screens in the application.

Also, there's xList (x=child object, i.e. userList(), companyList(),
etc.) that works the opposite of mList. If mList lists all the
companies in tbl_company in any of the 3 formats, then xList lists all
the employees for company_id in tbl_user. I'm sure there's a more
unified, encapsulated, cohesive, rational, sensible, and altruistic
way to do this... but it works so well. The way I implemented it, I
generally use cfinvoke to pull it into my forms unless I've got an
active instance of the relevant object in which case I'll just do
objName.mList(parm1, parm2, parm3)... BUT... for an administrative
page for adding new/editing existing employees in the system (which
supports multiple employers), I'll do this:

(at top)

user = createObject("component","cfc.user").init(310,true)
// 310 = user_id in DB, true means INIT uses CFRETURN to send instance
back to caller
.... much more HTML ...
<cfinvoke component="cfc.company" method="mList"
catch_id="#user.getUserId()#" ...>
.... even more HTML ...
There's more parameters to pass in, but that's the gist of how it works.

Now, I know, I shouldn't have UI generators in the business object. Or should I?

>From one perspective, no. UI and BL must be strictly separate. But...
but... see... well, if a business object is meant to maintain and
manage the business objects in the model, then how is it not
acceptable for it to fetch data and generate output relevant to the BO
for which it is reponsible? It's still being controlled by the
controller, it's still PART OF the model, and I'm still not embedding
any logic IN the page.

So my question is this: What real, explicable reason to I have for NOT
putting this in a BO... what's the rationale for creating separate
model objects for logic and for UI generation even though the BO is
technically responsible for managing access to the data in question?

I'm not expressing this very well, so I hope someone else understands
well enough to either answer or restate. If not, I'll try again later.

Laterz,
J
On Thu, 3 Mar 2005 11:43:09 -0500, Michael Dinowitz
<[EMAIL PROTECTED]> wrote:
> I'm starting this topic to get peoples feelings on the subject. Do you use
> CFCs for UI? Do you have a good reason to do so? Do you see a reason to use
> it (or not) vs. CFINCLUDEs or CFMODULEs?
> 
> According to commonly discussed practices in the community (and in part of
> the Macromedia docs), UI elements should not go inside of CFCs.
> According to the Macromedia CFC examples, UI can go inside CFCs.
> According to the makeup of the CFCOMPONENT and CFFUNCTION tags, the ability
> exists explicitly (the output attribute).
> According to many of the OO books I've been reading, there's no reason for
> UI not to be within an object.
> 
>  


-- 
Continuum Media Group LLC
Burnsville, MN 55337
http://www.web-relevant.com
http://cfobjective.neo.servequake.com

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:197393
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to