-- Topica Digest --
RE: Two questions related to form reuse
By [EMAIL PROTECTED]
RE: Two questions related to form reuse
By [EMAIL PROTECTED]
Check before deleting: where to put it?
By [EMAIL PROTECTED]
RE: Check before deleting: where to put it?
By [EMAIL PROTECTED]
------------------------------------------------------------
Date: Sat, 22 Jun 2002 07:09:52 -0400
From: "Dan O'Keefe" <[EMAIL PROTECTED]>
Subject: RE: Two questions related to form reuse
1) If you are going to the edit page, and it is a link, you have to pass the
id as a URL param. However, I typically do not make the param a part of the
XFA, but just add it to the end of the link:
<a
href="#request.self#?fuseaction=#request.XFA.delete#&groupID=#session.groupI
D#">Edit</a>
2) Best practice is to use the reuseform tag available at www.fusebox.org.
Dan
-----Original Message-----
From: Ney Andr� de Mello Zunino [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 22, 2002 5:38 AM
To: Fusebox mailing list
Subject: Two questions related to form reuse
Hello.
I have two questions regarding form reuse. Since this is the first time
I am building a real FB3-based application, I am not sure whether I am
doing things in the most appropriate way.
Imagine a page displaying a list of products and a link to add a new
item. Clicking on a product will display a page with its details. This
is possible because each of the links includes an 'id' attribute in the
URL. From the 'details' page, a user may choose to edit the product's
information. The switch of the circuit containing these fuseactions
could include:
<cfcase value="addItem">
<cfset pageTitle = "Add item">
<cfset buttonLabel = "Add">
<cfinclude template="dspEditForm.cfm">
</cfcase>
<cfcase value="details">
<cfset xfa.edit = "products.editItem">
<cfinclude template="qryDetails.cfm">
<cfinclude template="dspDetails.cfm">
</cfcase>
<cfcase value="editItem">
<cfset pageTitle = "Edit item">
<cfset buttonLabel = "Update">
<cfinclude template="qryDetails.cfm">
<cfinclude template="actSetFormVariables.cfm">
<cfinclude template="dspEditForm.cfm">
</cfcase>
The dspEditForm is shared by both the addItem and the editItem fuses.
The title of the page and the label of the button are configured via
simple variables. Inside the dspEditForm fuse, the form fields are
cfparam'ed to zero (i.e. unless values are provided, the form fields
will be blank).
Now for the questions:
1) From the list of products, a user can click an item to see its
details. The item's id is included in the URL, so when we get to the
'details' fuseaction, the id will be available both to the query that
will retrieve data and to the page that will display the results. This
last one will also include a link to edit the information being shown.
However, the target of this link is set through an XFA; in this case, it
is 'xfa.edit', which equals 'products.editItem'. How should the current
item's id be passed on to the 'editItem' fuseaction? Should it be
included in the XFA (i.e. xfa.edit =
"products.editItem&id=#attributes.id#") or should a variable be set?
What is the best practice here?
2) When reusing a form to edit an item, that item's data must be loaded
first and transferred to the form fields. In the example above, there is
an action fuse called 'actSetFormVariables.cfm' that will copy the
results of the query into variables that the display fuse with the form
will read from. It works, but again, what is the best practice here?
Thank you,
--
Ney Andr� de Mello Zunino
Media and Technology Laboratory
Campus Computing Centre
United Nations University
------------------------------
Date: Sat, 22 Jun 2002 11:30:47 -0500
From: "Tom Nunamaker" <[EMAIL PROTECTED]>
Subject: RE: Two questions related to form reuse
Just use a CFPARAM tag to set a default of 0 to the groupID. If the
groupID is zero, use a querySim to set all of the fields in the form to
NULL for an insert form. Otherwise, it fills in the form with real data
for an update.
Tom
-----Original Message-----
From: Dan O'Keefe [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 22, 2002 6:10 AM
To: [EMAIL PROTECTED]
Subject: RE: Two questions related to form reuse
1) If you are going to the edit page, and it is a link, you have to pass
the id as a URL param. However, I typically do not make the param a part
of the XFA, but just add it to the end of the link:
<a
href="#request.self#?fuseaction=#request.XFA.delete#&groupID=#session.gr
oupI
D#">Edit</a>
2) Best practice is to use the reuseform tag available at
www.fusebox.org.
Dan
-----Original Message-----
From: Ney Andr� de Mello Zunino [mailto:[EMAIL PROTECTED]]
Sent: Saturday, June 22, 2002 5:38 AM
To: Fusebox mailing list
Subject: Two questions related to form reuse
Hello.
I have two questions regarding form reuse. Since this is the first time
I am building a real FB3-based application, I am not sure whether I am
doing things in the most appropriate way.
Imagine a page displaying a list of products and a link to add a new
item. Clicking on a product will display a page with its details. This
is possible because each of the links includes an 'id' attribute in the
URL. From the 'details' page, a user may choose to edit the product's
information. The switch of the circuit containing these fuseactions
could include:
<cfcase value="addItem">
<cfset pageTitle = "Add item">
<cfset buttonLabel = "Add">
<cfinclude template="dspEditForm.cfm">
</cfcase>
<cfcase value="details">
<cfset xfa.edit = "products.editItem">
<cfinclude template="qryDetails.cfm">
<cfinclude template="dspDetails.cfm">
</cfcase>
<cfcase value="editItem">
<cfset pageTitle = "Edit item">
<cfset buttonLabel = "Update">
<cfinclude template="qryDetails.cfm">
<cfinclude template="actSetFormVariables.cfm">
<cfinclude template="dspEditForm.cfm">
</cfcase>
The dspEditForm is shared by both the addItem and the editItem fuses.
The title of the page and the label of the button are configured via
simple variables. Inside the dspEditForm fuse, the form fields are
cfparam'ed to zero (i.e. unless values are provided, the form fields
will be blank).
Now for the questions:
1) From the list of products, a user can click an item to see its
details. The item's id is included in the URL, so when we get to the
'details' fuseaction, the id will be available both to the query that
will retrieve data and to the page that will display the results. This
last one will also include a link to edit the information being shown.
However, the target of this link is set through an XFA; in this case, it
is 'xfa.edit', which equals 'products.editItem'. How should the current
item's id be passed on to the 'editItem' fuseaction? Should it be
included in the XFA (i.e. xfa.edit =
"products.editItem&id=#attributes.id#") or should a variable be set?
What is the best practice here?
2) When reusing a form to edit an item, that item's data must be loaded
first and transferred to the form fields. In the example above, there is
an action fuse called 'actSetFormVariables.cfm' that will copy the
results of the query into variables that the display fuse with the form
will read from. It works, but again, what is the best practice here?
Thank you,
--
Ney Andr� de Mello Zunino
Media and Technology Laboratory
Campus Computing Centre
United Nations University
------------------------------
Date: Sun, 23 Jun 2002 15:31:55 +0900
From: =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?= <[EMAIL PROTECTED]>
Subject: Check before deleting: where to put it?
Hello.
Say you have a fuseaction called 'deleteProduct' which is responsible
for removing a product from the database (duh). The removal, however,
can only be carried on if the product in question has no dependencies
(i.e. is not referenced from other tables). If dependencies exist, a
page should inform the user that the action cannot be done. The question
is: what is the most appropriate place to put this logic in? Would it be
acceptable to have it in the cfcase body (1)?
1.
<cfcase value="deleteProduct">
<cfinclude template="qryProductDependencies.cfm">
<cfif qryProductDependencies.recordCount eq 0>
<cfinclude template="actDeleteProduct.cfm">
<cfinclude template="dspProductDeleted.cfm">
<cfelse>
<cfinclude template="dspCannotDeleteProduct.cfm">
</cfif>
</cfcase>
Or would it be better to keep all logic out of the switch, having an
action fuse to take care of the decision and other fuseactions to do the
actual deleting and displaying of messages (2)?
2.
<cfcase value="deleteProduct">
<cfinclude template="qryProductDependencies.cfm">
<cfset xfa.canDelete = "products.doDelete">
<cfset xfa.cannotDelete = "products.cannotDelete">
<cfinclude template="actVerifyAction.cfm">
</cfcase>
<cfcase value="doDelete">
<cfinclude template="actDeleteProduct.cfm">
<cfinclude template="dspProductDeleted.cfm">
</cfcase>
<cfcase value="cannotDelete">
<cfinclude template="dspProductDeleted.cfm">
<cfinclude template="dspCannotDeleteProduct.cfm">
</cfcase>
I would appreciate hearing from the more experienced folks about which
approach is better. I have a feeling that the latter, though apparently
an overkill for this particularly simple example, is better structured
and would promote reusability more easily. But, anyway, I am just a
newbie. If I were sure, I would not be asking. :) Please, I know I have
been posting a lot of these "which is better or what is the best
practice for this case" questions, but the thing is, when I learn a new
thing, I like to learn it right from the beginning. I hope that is not a
problem to anyone here. My wish is that other people who are just
starting too can share the great feedback that we get here.
Best regards,
--
Ney Andr� de Mello Zunino
Media and Technology Laboratory
Campus Computing Centre
United Nations University
------------------------------
Date: Sun, 23 Jun 2002 15:11:37 +0800
From: "Kay Smoljak" <[EMAIL PROTECTED]>
Subject: RE: Check before deleting: where to put it?
Hi Ney,
I think that these kind of decisions are really up to you as an
architect - either approach is neat and understandable, so it really
depends what *you* think is best. My own personal preference is to make
the switch as easy to follow as possible, which means putting
conditional logic within it, but also trying to keep it as consise as
possible - I wouldn't break a fuseaction up unless there was a lot going
on in it.
I would probably use a variation on your first version - I would change
the conditional however, so that your first fuse returns a boolean value
as to whether the product has dependencies or not. This will allow you
to change the logic used to determine if the product can be deleted or
not more easily. I would also cflocate to a generic "action has been
completed" fuse, so that if your user hit the refresh button the action
wouldn't run again.
<cfcase value="deleteProduct">
<cfset xfa.confirm = "#fusebox.thisCircuit#.confirm">
<cfinclude template="qryProductDependencies.cfm">
<cfif isDeleteable>
<cfinclude template="actDeleteProduct.cfm">
<cflocation url="#request.baseURL##self##xfa.confirm#">
<cfelse>
<cfinclude template="dspCannotDeleteProduct.cfm">
</cfif>
</cfcase>
Hope that's helpful,
Kay.
> -----Original Message-----
> From: Ney Andr� de Mello Zunino [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, 23 June 2002 2:32 PM
> To: Fusebox mailing list
> Subject: Check before deleting: where to put it?
>
>
> Hello.
>
> Say you have a fuseaction called 'deleteProduct' which is responsible
> for removing a product from the database (duh). The removal, however,
> can only be carried on if the product in question has no dependencies
> (i.e. is not referenced from other tables). If dependencies exist, a
> page should inform the user that the action cannot be done.
> The question
> is: what is the most appropriate place to put this logic in?
> Would it be
> acceptable to have it in the cfcase body (1)?
>
> 1.
>
> <cfcase value="deleteProduct">
> <cfinclude template="qryProductDependencies.cfm">
> <cfif qryProductDependencies.recordCount eq 0>
> <cfinclude template="actDeleteProduct.cfm">
> <cfinclude template="dspProductDeleted.cfm">
> <cfelse>
> <cfinclude template="dspCannotDeleteProduct.cfm">
> </cfif>
> </cfcase>
>
> Or would it be better to keep all logic out of the switch, having an
> action fuse to take care of the decision and other
> fuseactions to do the
> actual deleting and displaying of messages (2)?
>
> 2.
>
> <cfcase value="deleteProduct">
> <cfinclude template="qryProductDependencies.cfm">
> <cfset xfa.canDelete = "products.doDelete">
> <cfset xfa.cannotDelete = "products.cannotDelete">
> <cfinclude template="actVerifyAction.cfm">
> </cfcase>
>
> <cfcase value="doDelete">
> <cfinclude template="actDeleteProduct.cfm">
> <cfinclude template="dspProductDeleted.cfm">
> </cfcase>
>
> <cfcase value="cannotDelete">
> <cfinclude template="dspProductDeleted.cfm">
> <cfinclude template="dspCannotDeleteProduct.cfm">
> </cfcase>
>
> I would appreciate hearing from the more experienced folks
> about which
> approach is better. I have a feeling that the latter, though
> apparently
> an overkill for this particularly simple example, is better
> structured
> and would promote reusability more easily. But, anyway, I am just a
> newbie. If I were sure, I would not be asking. :) Please, I
> know I have
> been posting a lot of these "which is better or what is the best
> practice for this case" questions, but the thing is, when I
> learn a new
> thing, I like to learn it right from the beginning. I hope
> that is not a
> problem to anyone here. My wish is that other people who are just
> starting too can share the great feedback that we get here.
>
> Best regards,
>
> --
> Ney Andr� de Mello Zunino
> Media and Technology Laboratory
> Campus Computing Centre
> United Nations University
>
> >
------------------------------
End of [EMAIL PROTECTED] digest, issue 832