There are patterns you can use to achieve this in Guice. I would warn
you that using the method you describe above puts a lot of faith into
the framework for constructing your UI exactly how you want. You might
be better off using a factory or a builder to construct the UI. Then
you can have multiple implementations of that.
-bp
On Dec 20, 2008, at 3:09 PM, Luis wrote:
>
> Sorry if I am asking something too basic but I am totally new to
> Guice.
>
> What stops me for thinking that this is a great framework is that all
> the examples I have seen use objects with a very fixed and predefined
> object graphs. For example object A always contains objects B and C,
> and so forth. But often one needs to create more complex structures,
> where a given object contains a list of other objects, and this list
> varies for each instance. A typical example is for GUIs: using an
> imaginary windowing framework,
>
> Window win = new Window();
> win.add(new Label("Name: ");
> win.add(new InputField());
> win.add(new Button("OK));
> win.add(new Button("Cancel");
> // etc...
>
> So even if I say:
>
> class Window {
> @Inject public void add(Component c) {
> // blabla...
> }
> }
>
> I don't see how can I use Guice to build the above "win" instance...
> and later use it to create another Window instance containing other
> stuff, possibly nesting components such as tabbed panes or whatever.
>
> Is that beyond the capabilities of Guice? I haven't used Spring
> either, but from reading its documentation, it seems to accept
> building beans containing lists, maps, and other arbitrary graphs.
> If Guice does not intend to implement a full Builder Pattern, how do
> you recommend to extend it or combine it with other framework?
>
> Thanks in advance,
>
> Luis.
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---