liigo wrote:

Two things that I can't understand easily, just in the HelloWord application.
With the HelloWord demo application code following:



package wicket.examples.helloworld; import wicket.markup.html.WebPage; import wicket.markup.html.basic.Label; public class HelloWorld extends WebPage { public HelloWorld() { add(new Label("message", "Hello World!")); } }



"add" what to where? why "add" it?
why "new" a component? Does not the components EXSIST in the markup file?
Why not "attach" it?
again, I'm a newbie of Wicket!

The most important thing to be aware of is that the Wicket component model implements the Composite design pattern (see Design Patterns, by Gamma et al) in the same way as many other UI frameworks (e.g. awt, Swing) do. In the Wicket component model almost everything inherits from the base Component class. Simple components such as labels and buttons are examples of components. Another class, Container, inherits from Component and adds functionality to hold instances of other components. Things such as panels, and more importantly Pages extend Container.

Given this understanding of the class hierarchy, the add method is quite logical. It can be read as 'add the given component into the current container'. The component you add may be an actual component or may be another container that in turn can hold its own components or containers. In the HelloWorld example, the label component is being added to the HelloWorld container which is a type of WebPage, which in turn extends Page, which extends Container. Do a google search for 'Composite Design Pattern' or look at the Design Patterns book for a more detailed description.

Components DO NOT EXIST in the markup file. Components EXIST in the Component/Container model as Java objects. The markup file just tells the component where it should insert is output in the resulting generated HTML page. Therefore, you need to think of your Java code as the primary hierarchy of components and the markup as just a view onto those markup objects.

Think of it like a house. The Wicket framework provides the main structural elements of the house (walls, joists, beams, floors, roof). You then ADD NEW components such as plumbing, a boiler, wiring, windows, doors and so on. Finally you create the visual appearence (the markup) in terms of wallpaper, carpets, paint, a bathroom suite, fancy radiators and so on. If you think of it like this, Wickets approach is much more natural than many web frameworks which require you to build your own structural elements or to leave out the plumbing and wiring until after you have decorated!



Another question, Tapestry 4.0 plan to remove the prefix "I" of the Name of interfaces clsss such as IRequestCycle,IPage, (rename to RequestCycle,Page, and so on).
and there is a lot of discussions on why or not do this at tapestry-user@jakarta.apache.org (http://news.gmane.org/thread.php?group=gmane.comp.java.tapestry.user)
Maybe Wicket will do the same thing? Just before 1.0 released?



Have a look at the mail list archive. We has a good debate on the subject with a whole range of view points. In the end we decided that the existing naming strategy was very consistent and meaningfully applied and that changing it would just be creating more work for ourselves for very little benefit.

Hope that clears up your questions and helps with your understanding of Wicket. We look forward to hearing how you get on with using the framework.
regards,
Chris



liigo, 2005-4-23



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to