You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eyal Golan <eg...@gmail.com> on 2009/06/04 14:52:39 UTC

checking for required fields

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
egolan74@gmail.com

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

Re: checking for required fields

Posted by Igor Vaynberg <ig...@gmail.com>.
maybe because your visitor stops after it finds the first formcomponent.

-igor

On Thu, Jun 4, 2009 at 7:21 AM, Eyal Golan <eg...@gmail.com> wrote:
> 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
> egolan74@gmail.com
>
> 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 <eg...@gmail.com> wrote:
>
>> I guess yes ...
>>
>> org.apache.wicket.MarkupContainer#visitChildren(final Class clazz, final
>> IVisitor visitor)
>>
>>
>> Eyal Golan
>> egolan74@gmail.com
>>
>> 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 <eg...@gmail.com> wrote:
>>
>>> thanks,
>>> iIf I want it to run on all children (recursively), should I use somewhere
>>> IVisitor.CONTINUE_TRAVERSAL; ?
>>>
>>>
>>> Eyal Golan
>>> egolan74@gmail.com
>>>
>>> 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 <sa...@gmail.com>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 <eg...@gmail.com>
>>>>
>>>> > 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
>>>> > egolan74@gmail.com
>>>> >
>>>> > 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
>>>> >
>>>>
>>>
>>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: checking for required fields

Posted by Eyal Golan <eg...@gmail.com>.
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
egolan74@gmail.com

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 <eg...@gmail.com> wrote:

> I guess yes ...
>
> org.apache.wicket.MarkupContainer#visitChildren(final Class clazz, final
> IVisitor visitor)
>
>
> Eyal Golan
> egolan74@gmail.com
>
> 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 <eg...@gmail.com> wrote:
>
>> thanks,
>> iIf I want it to run on all children (recursively), should I use somewhere
>> IVisitor.CONTINUE_TRAVERSAL; ?
>>
>>
>> Eyal Golan
>> egolan74@gmail.com
>>
>> 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 <sa...@gmail.com>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 <eg...@gmail.com>
>>>
>>> > 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
>>> > egolan74@gmail.com
>>> >
>>> > 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
>>> >
>>>
>>
>>
>

Re: checking for required fields

Posted by Eyal Golan <eg...@gmail.com>.
I guess yes ...

org.apache.wicket.MarkupContainer#visitChildren(final Class clazz, final
IVisitor visitor)


Eyal Golan
egolan74@gmail.com

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 <eg...@gmail.com> wrote:

> thanks,
> iIf I want it to run on all children (recursively), should I use somewhere
> IVisitor.CONTINUE_TRAVERSAL; ?
>
>
> Eyal Golan
> egolan74@gmail.com
>
> 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 <sa...@gmail.com>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 <eg...@gmail.com>
>>
>> > 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
>> > egolan74@gmail.com
>> >
>> > 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
>> >
>>
>
>

Re: checking for required fields

Posted by Eyal Golan <eg...@gmail.com>.
thanks,
iIf I want it to run on all children (recursively), should I use somewhere
IVisitor.CONTINUE_TRAVERSAL; ?


Eyal Golan
egolan74@gmail.com

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 <sa...@gmail.com>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 <eg...@gmail.com>
>
> > 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
> > egolan74@gmail.com
> >
> > 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
> >
>

Re: checking for required fields

Posted by sander v F <sa...@gmail.com>.
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 <eg...@gmail.com>

> 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
> egolan74@gmail.com
>
> 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
>