You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Sven Pfeiffer <sv...@madsep.de> on 2010/07/26 14:27:56 UTC
using FieldSet in a TabbedForm
Hi list,
I'd like to add a FieldSet to tab in a TabbedForm, my code looks like this:
TabbedForm form = new TabbedForm("form");
FieldSet protFS = new FieldSet("protocol");
FieldSet dataSet = new FieldSet("data");
... adding fields to dataSet
protFS.add(dataSet); // this crashes
form.addTabSheet(protFS);
The line protFS.add(dataSet) crashes with the following Exception:
java.lang.IllegalArgumentException: Cannot set the FieldSet's form to null
I also tried setting the form manually:
dataSet.setForm(form);
Currently I am using click 2.1.0
Is there any way to add a FieldSet to a tab?
Thanks in advance
SVen
Re: using FieldSet in a TabbedForm
Posted by Sven Pfeiffer <sv...@madsep.de>.
Hmm, it's almost 2.1.0, it's 2.1.0-RC1-incubating, I guess it'll be a
good idea to upgrade at least to 2.1.0.
You're right, if I add the "tab"-FieldSet to the form before adding more
FieldSets it works.
Thanks a lot!
Sven
Bob Schellink wrote:
> On 26/07/2010 23:31, Sven Pfeiffer wrote:
>
>> Maybe the Stacktrace will help:
>>
>> java.lang.IllegalArgumentException: Cannot set the FieldSet's form to null
>> at org.apache.click.control.FieldSet.setForm(FieldSet.java:596)
>> at org.apache.click.control.FieldSet.insert(FieldSet.java:205)
>> at org.apache.click.control.FieldSet.add(FieldSet.java:243)
>> at org.apache.click.control.FieldSet.add(FieldSet.java:263)
>>
>
>
> Are you sure you are using 2.1.0 and not 2.0.1? I just checked the source code for 2.0.1 [1] and it
> contains the exception you are referring to. But this isn't present in 2.1.0 [2]. In 2.1.0 the
> parent Form is looked up dynamically if it is null.
>
> Anyway, I think the problem is that dataSet is added to protFS before protFS parent form is set.
>
> You can fix it by adding the protFS to the form first:
>
> form.addTabSheet(protFS);
> protFS.add(dataSet);
>
> Kind regards
>
> Bob
>
> [1]:
> http://svn.apache.org/viewvc/click/tags/click-2.0.1/framework/src/org/apache/click/control/FieldSet.java?view=markup
> [2]:
> http://svn.apache.org/viewvc/click/tags/click-2.1.0/framework/src/org/apache/click/control/FieldSet.java?view=markup
>
>
>
>> Bob Schellink wrote:
>>
>>> Hi Sven,
>>>
>>> On 26/07/2010 22:27, Sven Pfeiffer wrote:
>>>
>>>
>>>> I'd like to add a FieldSet to tab in a TabbedForm, my code looks like
>>>> this:
>>>>
>>>> TabbedForm form = new TabbedForm("form");
>>>> FieldSet protFS = new FieldSet("protocol");
>>>> FieldSet dataSet = new FieldSet("data");
>>>>
>>>> ... adding fields to dataSet
>>>>
>>>> protFS.add(dataSet); // this crashes
>>>> form.addTabSheet(protFS);
>>>>
>>>> The line protFS.add(dataSet) crashes with the following Exception:
>>>> java.lang.IllegalArgumentException: Cannot set the FieldSet's form to
>>>> null
>>>>
>>>>
>>> In your example above you are adding one FieldSet to another FieldSet,
>>> not the TabbedForm.
>>>
>>> Regardless it sounds as if dataSet has already been added to another
>>> parent? Are you using
>>> Autobinding or a Stateful page perhaps?
>>>
>>>
>>>
>>>
>>>> I also tried setting the form manually:
>>>> dataSet.setForm(form);
>>>>
>>>> Currently I am using click 2.1.0
>>>>
>>>> Is there any way to add a FieldSet to a tab?
>>>>
>>>>
>>> TabbedForm is basically a Form with a number of FieldSets that are
>>> rendered as Tabs. But it looks
>>> like you want to add a FieldSet to another FieldSet? It should work
>>> though.
>>>
>>> Kind regards
>>>
>>> Bob
>>>
>>>
>>>
>>>
>>
>
>
>
>
Re: using FieldSet in a TabbedForm
Posted by Bob Schellink <sa...@gmail.com>.
On 26/07/2010 23:31, Sven Pfeiffer wrote:
>
> Maybe the Stacktrace will help:
>
> java.lang.IllegalArgumentException: Cannot set the FieldSet's form to null
> at org.apache.click.control.FieldSet.setForm(FieldSet.java:596)
> at org.apache.click.control.FieldSet.insert(FieldSet.java:205)
> at org.apache.click.control.FieldSet.add(FieldSet.java:243)
> at org.apache.click.control.FieldSet.add(FieldSet.java:263)
Are you sure you are using 2.1.0 and not 2.0.1? I just checked the source code for 2.0.1 [1] and it
contains the exception you are referring to. But this isn't present in 2.1.0 [2]. In 2.1.0 the
parent Form is looked up dynamically if it is null.
Anyway, I think the problem is that dataSet is added to protFS before protFS parent form is set.
You can fix it by adding the protFS to the form first:
form.addTabSheet(protFS);
protFS.add(dataSet);
Kind regards
Bob
[1]:
http://svn.apache.org/viewvc/click/tags/click-2.0.1/framework/src/org/apache/click/control/FieldSet.java?view=markup
[2]:
http://svn.apache.org/viewvc/click/tags/click-2.1.0/framework/src/org/apache/click/control/FieldSet.java?view=markup
> Bob Schellink wrote:
>> Hi Sven,
>>
>> On 26/07/2010 22:27, Sven Pfeiffer wrote:
>>
>>> I'd like to add a FieldSet to tab in a TabbedForm, my code looks like
>>> this:
>>>
>>> TabbedForm form = new TabbedForm("form");
>>> FieldSet protFS = new FieldSet("protocol");
>>> FieldSet dataSet = new FieldSet("data");
>>>
>>> ... adding fields to dataSet
>>>
>>> protFS.add(dataSet); // this crashes
>>> form.addTabSheet(protFS);
>>>
>>> The line protFS.add(dataSet) crashes with the following Exception:
>>> java.lang.IllegalArgumentException: Cannot set the FieldSet's form to
>>> null
>>>
>>
>>
>> In your example above you are adding one FieldSet to another FieldSet,
>> not the TabbedForm.
>>
>> Regardless it sounds as if dataSet has already been added to another
>> parent? Are you using
>> Autobinding or a Stateful page perhaps?
>>
>>
>>
>>> I also tried setting the form manually:
>>> dataSet.setForm(form);
>>>
>>> Currently I am using click 2.1.0
>>>
>>> Is there any way to add a FieldSet to a tab?
>>>
>>
>>
>> TabbedForm is basically a Form with a number of FieldSets that are
>> rendered as Tabs. But it looks
>> like you want to add a FieldSet to another FieldSet? It should work
>> though.
>>
>> Kind regards
>>
>> Bob
>>
>>
>>
>
>
Re: using FieldSet in a TabbedForm
Posted by Sven Pfeiffer <sv...@madsep.de>.
Hi Bob,
the first FieldSet (protFS) is added to the form as a tab using
addTabSheet, afaik this is the only way to add a tab to the form.
The second FieldSet is only added to protFS (which will be the tab).
I don't think it's an autobinding issue because dataSet is not a field
but only locally defined, the page is not stateful.
> TabbedForm is basically a Form with a number of FieldSets that are rendered as Tabs.
I know, protFS is the FieldSet that is used as Tab, dataSet is the
FieldSet I'd like to have inside the Tab.
Maybe the Stacktrace will help:
java.lang.IllegalArgumentException: Cannot set the FieldSet's form to null
at org.apache.click.control.FieldSet.setForm(FieldSet.java:596)
at org.apache.click.control.FieldSet.insert(FieldSet.java:205)
at org.apache.click.control.FieldSet.add(FieldSet.java:243)
at org.apache.click.control.FieldSet.add(FieldSet.java:263)
Thanks in advance
SVen
Bob Schellink wrote:
> Hi Sven,
>
> On 26/07/2010 22:27, Sven Pfeiffer wrote:
>
>> I'd like to add a FieldSet to tab in a TabbedForm, my code looks like this:
>>
>> TabbedForm form = new TabbedForm("form");
>> FieldSet protFS = new FieldSet("protocol");
>> FieldSet dataSet = new FieldSet("data");
>>
>> ... adding fields to dataSet
>>
>> protFS.add(dataSet); // this crashes
>> form.addTabSheet(protFS);
>>
>> The line protFS.add(dataSet) crashes with the following Exception:
>> java.lang.IllegalArgumentException: Cannot set the FieldSet's form to null
>>
>
>
> In your example above you are adding one FieldSet to another FieldSet, not the TabbedForm.
>
> Regardless it sounds as if dataSet has already been added to another parent? Are you using
> Autobinding or a Stateful page perhaps?
>
>
>
>> I also tried setting the form manually:
>> dataSet.setForm(form);
>>
>> Currently I am using click 2.1.0
>>
>> Is there any way to add a FieldSet to a tab?
>>
>
>
> TabbedForm is basically a Form with a number of FieldSets that are rendered as Tabs. But it looks
> like you want to add a FieldSet to another FieldSet? It should work though.
>
> Kind regards
>
> Bob
>
>
>
Re: using FieldSet in a TabbedForm
Posted by Bob Schellink <sa...@gmail.com>.
Hi Sven,
On 26/07/2010 22:27, Sven Pfeiffer wrote:
>
> I'd like to add a FieldSet to tab in a TabbedForm, my code looks like this:
>
> TabbedForm form = new TabbedForm("form");
> FieldSet protFS = new FieldSet("protocol");
> FieldSet dataSet = new FieldSet("data");
>
> ... adding fields to dataSet
>
> protFS.add(dataSet); // this crashes
> form.addTabSheet(protFS);
>
> The line protFS.add(dataSet) crashes with the following Exception:
> java.lang.IllegalArgumentException: Cannot set the FieldSet's form to null
In your example above you are adding one FieldSet to another FieldSet, not the TabbedForm.
Regardless it sounds as if dataSet has already been added to another parent? Are you using
Autobinding or a Stateful page perhaps?
> I also tried setting the form manually:
> dataSet.setForm(form);
>
> Currently I am using click 2.1.0
>
> Is there any way to add a FieldSet to a tab?
TabbedForm is basically a Form with a number of FieldSets that are rendered as Tabs. But it looks
like you want to add a FieldSet to another FieldSet? It should work though.
Kind regards
Bob