???
???
???
??? ???
Chapter 7
[ 193 ]
Did you notice one annoying thing about our web application? As soon as we want
to make the styles.css stylesheet available for a page, we need to do the same
steps again and again??”insert a link into the page template, make the stylesheet
available to the page class as an asset and add a getter method to the page. Could we
somehow avoid copying and pasting the same code into different pages?
It would also be nice to have a link for switching locale on every page, but in that
case we would need to write even more code again and again, on every page.
As soon as we notice that some content or functionality is reproduced in the
application more than just once, we should think of creating a custom component.
This is exactly what we are going to learn in the next chapter??”how to create
interesting, powerful, non-trivial components that can be used and reused
throughout the application, or even in many different applications.
Creating Custom
Components
There are a few different reasons why one might want to create a custom component.
Quite often there are pieces of interface or functionality that are replicated on
different pages, so we have to write the same code again and again until we package
the repeating pattern into a custom component.
Pages:
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247