edillmann / zkspring

Automatically exported from code.google.com/p/zkspring
0 stars 0 forks source link

children of spring-autowired widgets cannot be removed #15

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. In the zk spring essentials example (from 
http://zkbooks.googlecode.com/svn/trunk/zkspringessentials/zkspringcoresec/zkspr
ingessentials.war),
let the greeting be shown as Label inside a Div.

modified org.zkoss.zkspringessentials.controller.GreetingCtrl:

@org.springframework.stereotype.Component("greetingCtrl")
@Scope("prototype")
public class GreetingCtrl extends GenericSpringComposer {

    @Autowired private Textbox name;
    @Autowired private Button greetBtn;
    @Autowired private Div myDiv;

    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);
    }

    @EventHandler("greetBtn.onClick")
    public void showGreeting(Event evt) throws WrongValueException, InterruptedException {
        myDiv.getChildren().clear();
        new Label("Hello " + name.getValue() + "!").setParent(myDiv);
    }
}

modified autowirezkcomp.zul:

<?xml version="1.0" encoding="UTF-8"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<window title="Autowire ZK Components Example" border="normal" height="100px"
    width="400px" apply="${greetingCtrl}">
    <label value="Name:"></label>
    <textbox id="name" />
    <button id="greetBtn" label="Greet!" />
    <div id="myDiv"/>
</window>

2. Open "/autowirezkcomp.zul" and click several times on on the "Greet!" button.

What is the expected output? What do you see instead?
myDiv.getChildren().clear(); does not work so you will see "Hello X!Hello Y!" 
and get a java.util.ConcurrentModificationException at the third time.

What version of the product are you using? On what operating system?
zkspring-3.0, zk-5.0.6, apache-tomcat-7

Please provide any additional information below.
-

Original issue reported on code.google.com by wac...@tuxen.de on 5 Apr 2011 at 3:22