Sunday, 19 October 2014

Declaring Seaside sub-components in the #children method

People often ask why they need to define the #children method on Seaside components. I wrote a long email today to the mailing list explaining how #children is currently used and why it's important and I thought it might be useful to post it here as well so it's easier to find and link to. 

When you render a child component you are implicitly defining a tree of components. #children simply allows the framework to walk the component tree explicitly. The reasons for needing to walk the tree explicitly have changed over time, which is part of the reason for the confusion.

At one point, for example, we used to walk the tree to give each component a chance to handle callbacks, so if your component wasn't in #children it would never even have seen its callbacks. That is no longer the case (which is actually a bit of a shame because decorations can no longer intercept them, but I digress).

If you look in the image for users of WAVisiblePresenterGuide and WAAllPresenterGuide, you will see the current cases where we need to traverse the tree:
  1. Calling #updateStates: for snapshotting/backtracking
  2. Calling #initialRequest: when a new session is started
  3. Executing tasks (they need to execute outside of the render phase to make sure the render phase does not have side effects)
  4. Calling #updateRoot:
  5. Calling #updateUrl:
  6. Displaying Halos for each component in development mode
  7. Generating the navigation path in WATree
  8. Detecting which components are visible/active to support delegation (#call:/#show:)
Keep in mind that basically all these things happen before rendering, so if you create new components inside #renderContentOn: they'll miss out: you should try to create your sub-components either when your component is initialized or during a callback. If your child component doesn't rely on any of the above (and doesn't use any child components itself that rely on any of these things) then technically everything will work fine without adding it to #children. But keep in mind that:
  • the framework may change in the future to traverse the tree for other reasons;
  • add-ons may depend on being able to walk the tree for other reasons; and
  • it's not great encapsulation to assume that, in the future, components you are rendering will never need any of the above nor start using sub-components that do. 
Finally, components are stateful by definition, so if you don't feel the need to persist your component between render phases, it probably shouldn't be a component. For stateless rendering you're better to subclass WAPainter directly or even WABrush: both of these are intended to be used and then thrown away and they will make it clearer in your mind whether or not you're using on things that depend on #children.

55 comments:

Willie Aames said...

I feel that with each new frontend framework, the amount of javascript code is increasing and increasing, to the point that, if I have a medium to large-sized application, my (pipelined) application.js may have a few hundreds of KBs. I'm now starting a new app using React, and with only a single CRUD it already has over 200 lines of React code defining some components. Should I only require these component files, and also any other javascript file that's not global, on the specific pages such as purevpn review where they are being used?

Anonymous said...

Informative article. A virtual private network, or just VPN, helps encrypt and secure your router against information theft, misuse and only fraud. A single DDWRT router VPN can protect traffic that is internet most of the networked computers, hence helping you save a huge expense for internet security and privacy. Furthermore, Purevpn will redress individual IPs also of every computer or device on the community, therefore helping you secure identities of computer on the World Wide Web. www.thevpnlab.com/reviews/purevpn-review

Zubair Hussain Khan said...

Hey Willie, you have shared an excellent review of PureVPN, I am a VPN user for 5 to 6 month I mostly use VPN to access geo-restricted content in the UK. Recently I bought Nord VPN, and it is fantastic.

georgperry said...

I feel that with each new frontend structure, the measure of javascript code is expanding and expanding, to the point that, in the event that I have a medium to huge estimated application, my (pipelined) application.js may have a couple of several KBs. I'm currently beginning another application utilizing React, and with just a solitary CRUD it as of now has more than 200 lines of React code characterizing a few segments. Would it be a good idea for me to just require these segment documents, and furthermore some other javascript record that is not worldwide, on the particular pages, for example, purevpn survey where they are being utilized?
Uk writing experts

Shern1933 said...

Do you find writing to be a difficult task? Have you procrastinated until the final month to write your dissertation? You do not have to panic just yet! With the assistance of British Dissertation Home, you can avail the dissertation writing services uk to get your dissertation written on any topic before the due date.

AB Assignment Help said...

A high-standard post with all imperative information about Assignment Help UK services. Looking forward to avail the premium services.

Steve Dalton said...

Do you find writing to be a tough undertaking? Have you procrastinated until the final month to jot down your dissertation? You should no longer panic simply yet! With the help of British Dissertation Home, you may avail the Quality Essay Writing Service UK to get your dissertation written on any subject matter earlier than the due date.

TECH FIRE said...

Many commentators were recommended purevpn, but make sure you have reviewed every vpns app before jump into conclusion. Check the detailed guide:
https://www.bestvpn.co/

Amy Wong said...

Damn so cool just yesterday found this site and today I know what's what good best online casino sites Now plans to sit here all your free time and fun and productive

haryjohn8feb said...

Excellent and nice post. It will beneficial for everyone. Thanks for sharing such a wonderful post. Avail No 1 Essay writing Services UK from certified PhD writers. It is extremely helpful for me. You can email us at info@ukdissertationhelp.co.uk or Phone Number - 020 8144 9988

Max Rusel said...

Thank you for sharing this. The blog is very informative. The given blog tends to provide essential information about the changes and modifications of the Web application development company.

Herryjony said...

Tracy Isselhardt
Technology can often have its own disadvantages: vulnerability to cyber threats and of course hackers is definitely one of them. This has begun to apply to car technologies as well. Vehicle security is crucial and car companies want to ensure that hackers are kept away from their customers

Alina Smith said...

Astounding article. Interesting to peruse. I truly love to peruse such a decent article. Much obliged! continue shaking ..SPSS Help

assignment help said...

Really informative and inoperative, Thanks for the post and effort! Please keep sharing more such a blog. assignment helps

petterson said...

I like your post seaside for children but I think it can be very dangerous for small children
buy dissertation online

Ajay Sharma said...

Such a nice blog.
AppSquadz is known as the best app development service provider company. We have a goal-oriented developers’ team that has managed carefully and punctual to deliver project on time. Mobile App Development Company

Assignmnet Helps said...

Extremely enlightening and defective, Thanks for the post and exertion! It would be ideal if you continue sharing all the more such a blog.assignment helps

Amanda said...

Welcome this is wonderful Blog… Thanks for sharing the blog.Provide the endeavor and experience a wide level of orchestrating has any sort of impact other than please visit our website page .research proposals

Spss Help said...

It is a infromative and good website.Please visit spss help

Research proposals said...

Thankful to you such an incredible sum for the post you do. I like your post and all you share with us is outstanding and valuable,research proposals

my crm system said...

I adored the article, continue refreshing intriguing articles. I will be an ordinary peruser. my crm system

my crm system said...

I wonder how you got so great. This is actually an entrancing online journal, loads of stuff that I can get into. One thing I simply need to state is that your Blog is so great! my crm system

Amanda said...

It's dependably scrambling and focal. it's an astoundingly cool blog. Interfacing is a particularly head thing. You have genuinely helped stores of people who visit the blog and give them goliath information. Respects my crm system

https://assignmenthelps.org/literature-review-writing said...

Surprising article. Intriguing to examine. I really love to scrutinize such a better than average article. Thankful! keep shaking .my crm system

https://assignmenthelps.org/literature-review-writing said...

Surprising article. Fascinating to scrutinize. I genuinely love to examine such a nice article. Thankful! keep shaking .my crm system

Research proposals said...

Such a bit of incredible data, Thankyou such a great amount for sharing this enlightening article.research proposals

Jacob Oram said...

You shared a detailed post about coffee and cake. Some experts think that coffee is injurious to health and it can harm children's health but some people consider it the resource of getting refreshment. What is your opinion on this topic? Coursework writing services.

Research proposals said...

A debt of gratitude is in order for setting aside the effort to talk about this, I feel unequivocally about it and love adapting more on this point.Please visit research proposals

Research proposals said...

Nice post! Its really interesting. This idea is great and very helpful for us.Please Visitresearch proposals

dissertation helps said...

Howdy this is overwhelming Blog… Thanks for sharing the blog.Provide the endeavor and experience a wide level of structure has any sort of impact other than please visit our page.dissertation helps

Amanda said...

This Is Really Great Work. Much thankfulness to You For Sharing Such A Good And Useful Information Here In The Blog math assignments

Amanda said...

I read your blog zone and this is stupefying web diary a zone.. a dedication of gratefulness is with or without together for putting the push to suit us. have a shocking day math assignments

Amanda said...

it is a general epic site I take in various things from the site you posted scattering articals so I what's determinedly expected to post a general confusing article my site math assignments

Amanda said...

Howdy this is overpowering Blog… Thanks for sharing the blog.Provide the undertaking and experience a wide degree of structure has any kind of effect other than please visit our page.math assignments

Amanda said...

It's astoundingly confounding article for me or each one considering the course that bit of room starting at now need to done different data that is the clarification it's in a general sense scrambling for me.math assignments

Jacob Oram said...

Some people think that coffee is very useful for our health and some people think that coffee is injurious to our health. What is your opinion about this topic? Assignment writing services.

Amanda said...

Astonishing post, you conferred to us. Here, perusers can get data about condition. Such kind of posts can construct our general data and limit. Thankful for sharing this respectable post. statistical analysis

Amanda said...

This Is Really Great Work. Much thankfulness to You For Sharing Such A Good And Useful Information Here In The Blog statistical analysis

Amanda said...

"I read your blog zone and this is astonishing web diary a zone.. a commitment of gratefulness is with or without together for putting the push to suit us. have an astonishing day statistical analysis

Amanda said...

Disarranging post. I was paying shocking character to and on this post and I am mixed! Obliging information. statistical analysis

Amanda said...

it is a general epic site I take in various things from the site you posted scattering articals so I what's truly expected to post a general stunning article my site statistical analysis

Amanda said...

Howdy this is overpowering Blog… Thanks for sharing the blog.Provide the undertaking and experience a wide degree of structure has any kind of effect other than please visit our page. statistical analysis

Amanda said...

I read your blog zone and this is surprising web journal a zone.. a responsibility of thankfulness is with or without together for putting the push to suit us. have a surprising day statistical analysis

Amanda said...

Disarranging post. I was paying stunning character to and on this post and I am blended! Obliging data. statistical analysis

Amanda said...

it is a general epic site I take in different things from the site you posted dissipating articals so I what's genuinely expected to post a general shocking article my site statistical analysis

Amanda said...

It's astoundingly stunning article for me or every one considering the course that bit of room beginning at now need to done various information that is the explanation it's from a general perspective scrambling for me.statistical analysis

Jacob Oram said...

A great post especially for children's health. Through this post, we can improve our children's health. Those people who are worried about their children's health, they can get knowledge from this post, and they can improve their children's health. Dissertation writing service.

Anna Stephen said...

This is lighting up post, superb work, I like this substance and wish to inspect more from you. a commitment of appreciation is all together for such an enlightening post. someone you loved lyrics

Anna Stephen said...

Greatly not puzzling subtleties gave by you. I am certain it would stimulate changing English understudies. Thankful to you for setting aside some push to made such a post for us. Continue blogging. someone you loved lyrics

Anna Stephen said...

Faltering! indisputably I have found something dazzling, This is what I was checking for quite a while. Appreciative to you for offering this information to us. Keep sharing new posts. killer queen lyrics

Anna Stephen said...

Affecting! Such a pulling in and obliging post this is. I super love it. It's so overpowering everything considered impacting. I am on a perpetually central level mixed. killer queen lyrics

Andy Sunak said...
This comment has been removed by the author.
Abhi verma said...

I am very happy to read this article . Thanks for giving us Amazing info. Fantastic post. I appreciate this post. If you are interested in cryptocurrency, then Here you can know How to Earn Bitcoin and Other Cryptocurrencies

mary Brown said...

IEEE Project Domain management in software engineering is distinct from traditional project deveopment in that software projects have a unique lifecycle process that requires multiple rounds of testing, updating, and faculty feedback. A IEEE Domain project Final Year Projects for CSE system development life cycle is essentially a phased project model that defines the organizational constraints of a large-scale systems project. The methods used in a IEEE DOmain Project systems development life cycle strategy Project Centers in India provide clearly defined phases of work to plan, design, test, deploy, and maintain information systems.


This is enough for me. I want to write software that anyone can use, and virtually everyone who has an internet connected device with a screen can use apps written in JavaScript. JavaScript Training in Chennai JavaScript was used for little more than mouse hover animations and little calculations to make static websites feel more interactive. Let’s assume 90% of all websites using JavaScript use it in a trivial way. That still leaves 150 million substantial JavaScript Training in Chennai JavaScript applications.

Term Paper Writing Services said...

Professional Creative Assignment Writing Services is very popular for students in search of creative essay writing services and custom creative writing services.