Java – wicket dropdownchoice cannot use propertymodels normally
I've been trying to debug why my dropdownchoice is just a simple form. Only dropdown and a submit button don't work properly for hours now
It has a very strange behavior The first value selected in the drop-down option is successfully sent to the location of the server, after which the model will not update any other selections That is, if I have a list person and I select a second person, it will be submitted successfully However, when you select someone else and try to submit again, it always shows the first selected option
Here's a code snippet:
ChoiceRenderer<Empowerment> empowermentChoiceRenderer = new ChoiceRenderer<>("name","id"); final DropDownChoice<Empowerment> empowermentDropDownChoice = new DropDownChoice<>("empowerment",new PropertyModel<Empowerment>(this,"empowerment"),empowermentList,empowermentChoiceRenderer); empowermentDropDownChoice.setrequired(true); add(empowermentDropDownChoice);
The only way I can get a decent behavior is that I set the employment variable to null In this case, the authorization is reinitialized to null at commit time, and then the new commit works normally
Authorization is just a JPA entity
I'm glad to know if this is a known problem I'm on wicket 6.9 1 and wicket 6.12
resolvent
Solution
Finally, the solution to the problem is found The above code is correct, but the problem is the entity class itself – empowerment needs to implement equals and hashcode correctly
Dropdownchoice has worked well since then