Example: admin/users/edit contains my edit.cfm page and from within my
Users controller if i am doing a save and i try to
renderPage(action=edit) it returns an error saying it cant find /views/
users/edit which is correct since its actually one level deeper inside
a folder called admin.
--
You received this message because you are subscribed to the Google Groups "ColdFusion on Wheels" group.
To post to this group, send email to cfwh...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.
the url looks like this: http://cfcollections.dev/document-types/create
which is the function inside the controller but since my view template
is actually nested inside the admin folder this where the disconnect
happens.
This works fine with routes but once it comes to form interaction and
returning errors when using validation I am unable to get back to the
view with the error message and params.
I can use redirectTo( back="true") just fine but then I lose my params
and the error message.
So close but yet so far :)
On Apr 11, 6:20 pm, Chris Peters <ch...@clearcrystalmedia.com> wrote:
> What happens if you do renderPage(action="admin/edit")? A curious little
> experiment. :)
>
> On Sun, Apr 11, 2010 at 5:07 PM, cbchumley <cbchum...@gmail.com> wrote:
> > Problem: renderPage does not allow routes so how would one accomplish
> > handling views that have subfolder heirarchy.
>
> > Example: admin/users/edit contains my edit.cfm page and from within my
> > Users controller if i am doing a save and i try to
> > renderPage(action=edit) it returns an error saying it cant find /views/
> > users/edit which is correct since its actually one level deeper inside
> > a folder called admin.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ColdFusion on Wheels" group.
> > To post to this group, send email to cfwh...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cfwheels+u...@googlegroups.com<cfwheels%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfwheels?hl=en.
<cfset renderPage(action="../yourpath")>
When I want to render views from other folders I need to "get out" of
the current controller folder
> > > cfwheels+u...@googlegroups.com<cfwheels%2Bunsubscribe@googlegroups.c om>
Here is the view folder structure
views
--- admin
------documenttypes
-----------index.cfm
-----------edit.cfm
-----------view.cfm
Using routes I can traverse nested views with no problem, using
redirect to I can traverse with no issues using redirecTo(back=true)
however i lose any params that were submitted by the form.
I honestly think the framework needs to be able to allow nested views
and the internal wheels $createControllerClass method modifed to allow
for this. That is my next step to look at but wan't to avoid going
down that path until absolutely necessary.
> > > > cfwheels+u...@googlegroups.com<cfwheels%2Bunsubscr...@googlegroups.c om>
I use nested views all the time, you shouldn't t need to modify the
framework
Andy
Cause i have tried everything even including
renderPage(template="...") to no avail.
Would be curious to see how your handling this
On Apr 12, 7:19 am, Andy Bellenie <andybelle...@googlemail.com> wrote:
> I think Raul meant renderPage(template=...)
>
> I use nested views all the time, you shouldn't t need to modify the
> framework
>
> Andy
>
Regardless of setting renderPage(action="admin/documenttypes/edit") or
renderPage(template="admin/documenttypes/edit")
Any other suggestions. This is driving me MAD :)
On Apr 12, 7:19 am, Andy Bellenie <andybelle...@googlemail.com> wrote:
> I think Raul meant renderPage(template=...)
>
> I use nested views all the time, you shouldn't t need to modify the
> framework
>
> Andy
>
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
Trying to add a record and doing validation this is what i am getting
now:
Controller:
<cffunction name="create">
<cfset documentTypes =
model("documentType").new(params.documentTypes)>
<!--- Verify that the document type creates successfully --->
<cfif documentTypes.save()>
<cfset flashInsert(success="The document type was created
successfully.")>
<cfset redirectTo(action="index") />
<!--- Otherwise --->
<cfelse>
<cfset flashInsert(error=errorMessagesFor("documentTypes"))>
<cfset tabHeading = "Add" />
<cfset formAction = "create" />
<cfset renderPage(template="/admin/documenttypes/edit/") />
</cfif>
</cffunction>
This will return the correct view now - BUT:
1) URL looks like this - http://cfcollections.dev/documenttypes/create
(notice that its not showing cfcollections.dev/admin/documenttypes/
edit)
2) The edit.cfm view has some variables that i set in the create
function of the controller but since renderPage() actually just
displays the view i lose those variables i am setting and am having to
set them in my create function prior to calling the renderPage()
So suggestions on what I need to do to get url to display correctly
and how to get the variables to remain without having to resort to
session variables for them.
BTW - Thanks for everyone's help on this. I will eventually have my
self wrapped around this and will write a series of articles on the
framework at communitymx.com
On Apr 12, 1:44 pm, cbchumley <cbchum...@gmail.com> wrote:
> Alright so getting closer:
>
> Trying to add a record and doing validation this is what i am getting
> now:
>
> Controller:
> <cffunction name="create">
> <cfset documentTypes =
> model("documentType").new(params.documentTypes)>
>
> <!--- Verify that the document type creates successfully --->
> <cfif documentTypes.save()>
> <cfset flashInsert(success="The document type was created
> successfully.")>
> <cfset redirectTo(action="index") />
> <!--- Otherwise --->
> <cfelse>
> <cfset flashInsert(error=errorMessagesFor("documentTypes"))>
> <cfset tabHeading = "Add" />
> <cfset formAction = "create" />
> <cfset renderPage(template="/admin/documenttypes/edit/") />
> </cfif>
> </cffunction>
>
> This will return the correct view now - BUT:
>
> 1) URL looks like this -http://cfcollections.dev/documenttypes/create
so re-reading through the CFWheels document the suggestion is to not
use renderPage() but to use redirectTo() except for when you are
returning errors to the form which is my case.
So if my edit.cfm page is within my admin.documenttypes folder then
how should my route on the startformTag look and how would i then be
able to use the same form for adds and edits (dynamically change the
route)?
Also how do i still handle any variables other than form elements on
the page since method in the controller isnt getting called and they
dont seem to exist anymore when using renderPage().
This seems a lot damn harder than it needs to be.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
All this seems to work fairly well with Routes and traversing the
views works fine. My only issue is with returning back to a view.
I can take your advice and move back to a single level nesting but I
am not sure that will still fix the issue I am having.
I have read your documentation. I am considered a ColdFusion expert
so I don't beleive its my lack of knowledge with ColdFusion.
Although the site is fairly well documented there are holes in it and
maybe I am just trying to push the framework beyond it desired level.
BTW. These forums are very well maintained and I do appreciate the
answers i have gotten.
I just wish someone had 10 minutes to do a Skype call with me so they
could see what i am working on and then maybe it's just something
simple i am missing.
On Apr 12, 2:30 pm, Per Djurner <per.djur...@gmail.com> wrote:
> Ok, you may not like this reply but here it comes anyway :)
> I really think you would benefit by sticking to the Wheels conventions until
> you know the framework really, really well.
>
> What is your reason for wanting more folder levels for views?
>
> > > > > > > >>>>> cfwheels+u...@googlegroups.com<cfwheels%2Bunsu...@googlegroups.com>
> > <cfwheels
> > > > > > > >>>>> %2Bunsubscr...@googlegroups.c om>
> > > > > > > >>>>> .
> > > > > > > >>>>> For more options, visit this group at
> > > > > > > >>>>>http://groups.google.com/group/cfwheels?hl=en.
>
> > > > > > > > --
> > > > > > > > You received this message because you are subscribed to the
> > Google
> > > > > > > > Groups "ColdFusion on Wheels" group.
> > > > > > > > To post to this group, send email to cfwh...@googlegroups.com
> > .
> > > > > > > > To unsubscribe from this group, send email to
> > cfwheels+u...@googlegroups.com<cfwheels%2Bunsu...@googlegroups.com>
> > > > > > > > .
> > > > > > > > For more options, visit this group athttp://
> > groups.google.com/group/cfwheels?hl=en
> > > > > > > > .
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ColdFusion on Wheels" group.
> > To post to this group, send email to cfwh...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cfwheels+u...@googlegroups.com<cfwheels%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
Your create view
Your routes
Your controller action
> ...
>
> read more »
Do you have any examples of how your handling nested views more than
one level deep and how your rendering the view when passing errors
back to the view page that you can send me offline.
I emailed both Chris and Mike but so far your the only one I know that
is using nested views more than one level deep.
On Apr 12, 2:47 pm, Andy Bellenie <andybelle...@googlemail.com> wrote:
> cbchumley,
>
> There's no reason at all why you can't use nested views, from the sound of
> it that's now working.
>
> The other problem you mentioned has no specific solution, depending on the
> kind of data the view is using there is always a neat way of dealing with
> it.
>
> You already have the documentTypes model available to that view, so any data
> that is related to that should come from their. I do my best when designing
> controllers to create no more than one variable per controller method if
> possible, and quite often none at all. This makes re-using views a lot
> easier.
>
> Perhaps you could list the variables you're using in your view and then I
> can be more specific.
>
> Wheels requires a bit of a philosophical shift from using coding patterns.
> You get the hang of it very quickly :)
>
> Best,
> Andy
>
> ...
>
> read more »
--
To unsubscribe from this group, send email to cfwheels+u...@googlegroups.com.
Thanks - I hope you dont mind but I emailed you offline
> On 12 April 2010 19:54, cbchumley <cbchum...@gmail.com> wrote:> Andy - its sort of working. The view is rendering but the url is not
> > cfwheels+u...@googlegroups.com<cfwheels%2Bunsu...@googlegroups.com>
"I do my best when designing controllers to create no more than one
variable per controller method if possible, and quite often none at
all. This makes re-using views a lot easier."
I did not understand this one variable per controller thing. Do you
mean you wrap all the variables needed by a view into a struct so that
its easy to know which external variables are being used by the view?
Also, I feel it would be really nice to have a document which outlines
general cfwheels design best practices. This forum is like a treasure
trove of such principles but they are all scattered in different
discussions.
Could we have something like a design principle cheat sheet?
On Apr 12, 11:47 pm, Andy Bellenie <andybelle...@googlemail.com>
wrote:
> cbchumley,
>
> There's no reason at all why you can't use nested views, from the sound of
> it that's now working.
>
> The other problem you mentioned has no specific solution, depending on the
> kind of data the view is using there is always a neat way of dealing with
> it.
>
> You already have the documentTypes model available to that view, so any data
> that is related to that should come from their. I do my best when designing
> controllers to create no more than one variable per controller method if
> possible, and quite often none at all. This makes re-using views a lot
> easier.
>
> Perhaps you could list the variables you're using in your view and then I
> can be more specific.
>
> Wheels requires a bit of a philosophical shift from using coding patterns.
> You get the hang of it very quickly :)
>
> Best,
> Andy
>
> ...
>
> read more »
I think some additional screencasts and sample apps are a great idea,
it's something I'd like to help with as we work towards 1.1 - lots to
do though!
On Apr 13, 4:40 pm, Andy Bellenie <andybelle...@googlemail.com> wrote:
> That was 1 variable per controller METHOD :)
>
> I think some additional screencasts and sample apps are a great idea,
> it's something I'd like to help with as we work towards 1.1 - lots to
> do though!
>
> ...
>
> read more »
For example, you might need a variable called formAction if you're
using a common edit page for both creates and updates. But instead of
creating a variable in the controller, put a method in teh root model
that returns either 'create' or 'update' depending on whether or not
the model is new.
So formAction now becomes model.formAction()
More often than not the titles etc are the same as your controller
names and methods, so default them that way in a filter.
<cfset pageTitle = Humanize(params.controller) & " - " &
Humanize(params.action)>
and so on.
Don't repeat yourself. If you need to do anything more than once then
there's a good chance you can rationalise it.
Thanks for your ideas
:)
On Apr 13, 4:50 pm, Andy Bellenie <andybelle...@googlemail.com> wrote:
> A struct doesn't help, that just packages them all together. The point
> is not to create them at all. It can require some creative thinking
> but often you're using variables instead of methods.
>
> For example, you might need a variable called formAction if you're
> using a common edit page for both creates and updates. But instead of
> creating a variable in the controller, put a method in teh root model
> that returns either 'create' or 'update' depending on whether or not
> the model is new.
>
> So formAction now becomes model.formAction()
>
> More often than not the titles etc are the same as your controller
> names and methods, so default them that way in a filter.
>
> <cfset pageTitle = Humanize(params.controller) & " - " &
> Humanize(params.action)>
>
> and so on.
>
> Don't repeat yourself. If you need to do anything more than once then
> there's a good chance you can rationalise it.
>
> ...
>
> read more »
Thanks :)
On Apr 13, 6:01 pm, Chris Peters <ch...@clearcrystalmedia.com> wrote:
> Would you also say that this is a good case for using filters too? I've
> become a huge fan of using them to DRY up variables that end up getting set
> across multiple methods in a controller (or controllers plural).
>
> On Tue, Apr 13, 2010 at 7:50 AM, Andy Bellenie <andybelle...@googlemail.com
>
>
>
> > wrote:
> > A struct doesn't help, that just packages them all together. The point
> > is not to create them at all. It can require some creative thinking
> > but often you're using variables instead of methods.
>
> > For example, you might need a variable called formAction if you're
> > using a common edit page for both creates and updates. But instead of
> > creating a variable in the controller, put a method in teh root model
> > that returns either 'create' or 'update' depending on whether or not
> > the model is new.
>
> > So formAction now becomes model.formAction()
>
> > More often than not the titles etc are the same as your controller
> > names and methods, so default them that way in a filter.
>
> > <cfset pageTitle = Humanize(params.controller) & " - " &
> > Humanize(params.action)>
>
> > and so on.
>
> > Don't repeat yourself. If you need to do anything more than once then
> > there's a good chance you can rationalise it.
>
> ...
>
> read more »
> ...
>
> read more »
> ...
>
> read more »