dsyrstad / wicket-web-beans

Automatically exported from code.google.com/p/wicket-web-beans
Apache License 2.0
1 stars 1 forks source link

StackOverflowException when Bean has Self or Parent Class Reference. #35

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Start with the NestedBeanPage example.
2. Open Address.java
3. Add the following property:
private Customer tenant;
4. Generate Getters/Setters
5. Add annotation @Property(required=false) to new attribute.
6. Run example.

What is the expected output? What do you see instead?
I expect to see the example only with the ability to add a customer to an 
address optionally.

Instead, I get a stack overflow error:

java.lang.StackOverflowError
    at org.apache.wicket.markup.html.form.Form.isVersioned(Form.java:841)
    at org.apache.wicket.Component.isVersioned(Component.java:2182)
    at org.apache.wicket.Component.isVersioned(Component.java:2182)
    at org.apache.wicket.Component.isVersioned(Component.java:2182)
    at org.apache.wicket.Component.isVersioned(Component.java:2182)
    at org.apache.wicket.Component.isVersioned(Component.java:2182)
    at org.apache.wicket.Component.isVersioned(Component.java:2182)
    at org.apache.wicket.Component.isVersioned(Component.java:2182)

What version of the product are you using? On what operating system?
trunk (1.2)  - Windows 7

Please provide any additional information below.

It is obvious why self-reference will cause a stack overflow.  It seems that 
there should be a way to say that these references are optional in order to 
only traverse them if the user specifies.

Original issue reported on code.google.com by aplea...@gmail.com on 7 Dec 2010 at 5:38

GoogleCodeExporter commented 9 years ago
After browsing around the source code, I found out that any referenced object 
would be rendered by BeanGridField. With self-reference beans, it would cause 
stack overflow. So all we need is to assign fieldType in beanprops to something 
else. For example:
props:
  parent{fieldType:InputField}

Ideally you have to implement your own com.googlecode.wicketwebbeans.field to 
meet your requirement.

Original comment by freddija...@gmail.com on 17 Apr 2011 at 5:29

GoogleCodeExporter commented 9 years ago
I think this is not a defect, but it should be mentioned somewhere in 
documentation how to deal with self-reference beans.

Original comment by freddija...@gmail.com on 17 Apr 2011 at 5:33