OK, I'm not sure, but is it a bug?

Looking at MarkupContainer#visitChildren I found something strange.

The lines:
// If child is a container
if ((child instanceof MarkupContainer) &&
                (value != IVisitor.CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER))
            {
...
}

Now maybe I'm wrong, but should isInstance or isAssignableFrom be used?

In any case, I have a page that holds containers and the visitor did not
traverse inside them:
        visitChildren(FormComponent.class, new Component.IVisitor() {
            public Object component(Component component) {
                if (FormComponent.class.isInstance(component)) {
                    FormComponent formComponent = (FormComponent) component;
                    if (formComponent.isRequired()) {
                        required.setVisible(true);
                        return formComponent;
                    }
                }
                return Component.IVisitor.CONTINUE_TRAVERSAL;
            }
        });

Is it me or Wicket?

Eyal Golan
[email protected]

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really necessary


On Thu, Jun 4, 2009 at 4:28 PM, Eyal Golan <[email protected]> wrote:

> I guess yes ...
>
> org.apache.wicket.MarkupContainer#visitChildren(final Class clazz, final
> IVisitor visitor)
>
>
> Eyal Golan
> [email protected]
>
> Visit: http://jvdrums.sourceforge.net/
> LinkedIn: http://www.linkedin.com/in/egolan74
>
> P  Save a tree. Please don't print this e-mail unless it's really necessary
>
>
> On Thu, Jun 4, 2009 at 4:26 PM, Eyal Golan <[email protected]> wrote:
>
>> thanks,
>> iIf I want it to run on all children (recursively), should I use somewhere
>> IVisitor.CONTINUE_TRAVERSAL; ?
>>
>>
>> Eyal Golan
>> [email protected]
>>
>> Visit: http://jvdrums.sourceforge.net/
>> LinkedIn: http://www.linkedin.com/in/egolan74
>>
>> P  Save a tree. Please don't print this e-mail unless it's really
>> necessary
>>
>>
>> On Thu, Jun 4, 2009 at 4:08 PM, sander v F <[email protected]>wrote:
>>
>>> you could use a visitor:
>>>
>>>            form.visitChildren(new Component.IVisitor()
>>>            {
>>>                public Object component(Component component)
>>>                {
>>>                    if (component instanceof FormComponent)
>>>                    {
>>>                        FormComponent formComponent = (FormComponent)
>>> component;
>>>                        if (!formComponent.isRequired())
>>>                        {
>>>                            // do something
>>>                        }
>>>                    }
>>>                    return component;
>>>                }
>>>            });
>>>
>>>
>>> 2009/6/4 Eyal Golan <[email protected]>
>>>
>>> > Hi,
>>> > What is the best way to check if there are any required fields in a
>>> page?
>>> > I want a page that checks for these fields and do something
>>> accordingly.
>>> >
>>> > Thanks,
>>> >
>>> > Eyal Golan
>>> > [email protected]
>>> >
>>> > Visit: http://jvdrums.sourceforge.net/
>>> > LinkedIn: http://www.linkedin.com/in/egolan74
>>> >
>>> > P  Save a tree. Please don't print this e-mail unless it's really
>>> necessary
>>> >
>>>
>>
>>
>

Reply via email to