setLayout() in controller method

135 views
Skip to first unread message

Serkan Tüten

unread,
Dec 18, 2014, 9:10:53 AM12/18/14
to framew...@googlegroups.com
Hi

I'm trying to show a different layout for a login page. My controller (security.cfc) has a function called login where I use setLayout(). When the second argument is set to true, only my view gets rendered (see second trace). If it is false, both layouts get rendered (see first trace). The third trace is correct: no second argument for setLayout() and request.layout = false inside layout. Shouldn't that be possible with the second argument set to true?


Files:
/controllers/
/controllers/security.cfc

public void function login( struct rc ) {
   variables.fw.setLayout( 'html5' , true );
}

/layouts/
/layouts/default.cfm
/layouts/html5.cfm

/views/
/views/main/default.cfm
/views/security/login.cfm

setLayout() second argument false: HTML from /layouts/html5.cfm AND /layouts/default.cfm are rendered.

0ms1mssetupApplication() called
1mssetupRequest() called
1ms1msmain.setMetaDataqueuing controller
2mssecurity.loginqueuing controller
2msApplication.cfcno before controller to call
2msmain.beforeno before controller to call
2msmain.setMetaDatacalling item controller
2mssecurity.beforeno before controller to call
2ms1mssecurity.logincalling item controller
3mssecurity.afterno after controller to call
3msmain.afterno after controller to call
3msApplication.cfcno after controller to call
3mssecurity.loginbuilding view queue
3mssecurity.loginfound view /views/security/login.cfm
3mssetupView() called
3ms1msrendering /views/security/login.cfm
4ms1mshtml5.defaultbuilding layout queue
5mshtml5.defaultfound section-specific layout /layouts/html5.cfm
5mshtml5.defaultfound default layout /layouts/default.cfm
5msrendering /layouts/html5.cfm
5msrendering /layouts/default.cfm
5mssetupResponse() called

setLayout() second argument true: only the view /views/security/login.cfm is rendered!

0mssetupApplication() called
0mssetupRequest() called
0ms166msmain.setMetaDataqueuing controller
166mssecurity.loginqueuing controller
166msApplication.cfcno before controller to call
166msmain.beforeno before controller to call
166msmain.setMetaDatacalling item controller
166mssecurity.beforeno before controller to call
166ms20mssecurity.logincalling item controller
186mssecurity.afterno after controller to call
186msmain.afterno after controller to call
186msApplication.cfcno after controller to call
186ms1mssecurity.loginbuilding view queue
187mssecurity.loginfound view /views/security/login.cfm
187mssetupView() called
187ms5msrendering /views/security/login.cfm
192ms1mshtml5.defaultbuilding layout queue
193mssetupResponse() called


This generates the correct output: setLayout( 'html5' ) in controller AND request.layout = false in layout html5.cfm

0mssetupApplication() called
0mssetupRequest() called
0ms1msmain.setMetaDataqueuing controller
1mssecurity.loginqueuing controller
1msApplication.cfcno before controller to call
1msmain.beforeno before controller to call
1msmain.setMetaDatacalling item controller
1mssecurity.beforeno before controller to call
1mssecurity.logincalling item controller
1mssecurity.afterno after controller to call
1msmain.afterno after controller to call
1msApplication.cfcno after controller to call
1mssecurity.loginbuilding view queue
1mssecurity.loginfound view /views/security/login.cfm
1mssetupView() called
1msrendering /views/security/login.cfm
1mshtml5.defaultbuilding layout queue
1mshtml5.defaultfound section-specific layout /layouts/html5.cfm
1mshtml5.defaultfound default layout /layouts/default.cfm
1ms138msrendering /layouts/html5.cfm
139msaborting layout rendering
139mssetupResponse() called

FW/1 3.0 setLayout() can suppress additional layouts


Local config: FW/1 3.0 B1, Railo-Express (4.2.1.008) on OS X 10.10.1
Remote config: Railo 4.1.x on Windows (?)

Sean Corfield

unread,
Dec 18, 2014, 2:35:37 PM12/18/14
to framew...@googlegroups.com
setLayout() takes an action so you are specifying the equivalent of "html5.default".

The second argument assumes such a layout exists and that you want to use only that layout.

You do not have an item-specific layout, only a section-specific layout.

If you had /layouts/html5/default.cfm then your call to setLayout() would do what you expect.

Sean

--
--
FW/1 on RIAForge: http://fw1.riaforge.org/
 
FW/1 on github: http://github.com/framework-one/fw1
 
FW/1 on Google Groups: http://groups.google.com/group/framework-one
---
You received this message because you are subscribed to the Google Groups "framework-one" group.
To unsubscribe from this group and stop receiving emails from it, send an email to framework-on...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)



Serkan Tüten

unread,
Dec 19, 2014, 8:25:02 AM12/19/14
to framew...@googlegroups.com
thank you for your answer! I thought it will still implicitly find the section-specific layout and render it… now I know better :)

found section-specific layout /layouts/html5.cfm
rendering /layouts/html5.cfm
Reply all
Reply to author
Forward
0 new messages