Thursday, March 31, 2011

Re: Overriding panel's iterator() prevents clickHandler from being called.

Ah, I finally see what you are doing with that iterator. You are
using that to find and remove the item elements from the view.

What you are doing "wrong" is just abusing an existing method. You
generally try to not change the contracts of methods by overriding
them and assigning them different functionality, as it tends to break
existing code, and just be confusing.

There are many ways to do this kind of thing. The simplest would
probably be to define a new method "getItemElementsIterator" or
whatever else you want to call it, and return the flow panels iterator
that you want with that new method.

-Ben

On Mar 30, 10:35 pm, Vhann3000 <vhann3...@gmail.com> wrote:
> On Mar 30, 12:26 pm, Vhann3000 <vhann3...@gmail.com> wrote:
>
> > Second, I may very well be wrong, but the way I understand it, if I
> > don't override the ScrollPanel's iterator(), then it will return the
> > VerticalPanel (as the VerticalPanel is the sole child widget of the
> > ScrollPanel). Of course, I don't want that, I want to be able to list
> > the VerticalPanel's child widgets with
> > scrollVerticalPanelInstance.iterator().
>
> I just tested and, indeed, if I don't override the iterator(), it just
> lists the
> nested Panel:
>
> public class ScrollFlowPanel extends ScrollPanel {
>         private FlowPanel fPanel;
>
>         public ScrollFlowPanel() {
>                 fPanel = new FlowPanel();
>                 super.add(fPanel);
>
>                 for (Iterator i = iterator(); i.hasNext(); ) {
>                         GWT.log("Widget class = " + i.next().getClass());
>                 }
>         }
>
> }
>
> This code outputs:
> Widget class = class com.google.gwt.user.ui.FlowPanel
>
> So how can I hide the nested Panels from the caller and still have my
> Handlers work?
> What am I doing wrong?
>
> Regards,
> Olivier

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment