Hi.
Certainly I can.
Here is the main Panel for the case where the CompoundPropertyModel loses
the object.
The WebPage classes basically only contain one of those main panels
depending of the PageParameters which are passed into the panel as converted
to a Scala immutable Map instance.
ParameterPanel is just a plain subclass of Panel which can hold a set of
parameters.
Ah, yeah, and all the code is Scala...
-
class WeekPlanEditPanel(id: String, params: Map[String, Any]) extends
ParameterPanel(id, params) {
private val log: Logger = LoggerFactory.getLogger(this.getClass)
private val wpService =
ServiceLocator.getServiceInstance[WeekPlanService]
private val weekPlanId = getIdParam
private val wp = wpService.findById(weekPlanId).get
private val formModel = new CompoundPropertyModel[WeekPlan](wp)
private val feedback = new FeedbackPanel(feedback).setVisible(false)
private val form = new Form[WeekPlan](editForm, formModel) {
override def onError: Unit = feedback.setVisible(true)
}
form.add(new WeekPlanDataInputPanel(dataPanel, formModel, true))
form.add(new Button(saveButton) {
override def onSubmit: Unit = {
try {
wpService.update(wp)
info(Speichern erfolgreich!)
formModel.setObject(wp)// !!! explicit set of object
necessary
} catch {
case e: Exception = log.error(Error on saving weekplan
entry!, e)
error(Fehler beim Speichern des Eintrages: +
e.getMessage)
}
feedback.setVisible(true)
}
})
form.add(new Button(deleteButton) {
override def onSubmit: Unit = {
try {
wpService.delete(wp)
setResponsePage(classOf[WeekPlanPage], new
PageParameters(action=list))
} catch {
case e: Exception = log.error(Error on deleting weekplan
entry!, e)
error(Fehler beim Löschen des Eintrages: + e.getMessage)
feedback.setVisible(true)
}
}
})
add(feedback)
add(form)
}
-
And the WeekPlanDataInputPanel for sake of completeness.
-
@EditorOnly
class WeekPlanDataInputPanel(id: String, model: IModel[WeekPlan], isEdit:
Boolean) extends Panel(id) {
private val weekPlan = model.getObject
add(new AdminAdditionsInputPanel(adminAdditions, model))
add(new Label(id))
add(new Label(creator))
add(DateLabel.forDatePattern(dateCreated, dd.MM. hh:mm))
add(new WeekTargetDatePanel(targetDate, model, isEdit))
}
-
When submitting the labels in the last Panel class are displayed empty on
the page reload because model object is null. weekPlan itself however is
still a valid instance.
When setting the model object in the onSubmit handler (as in the former
Panel class) it works.
Thanks,
Manfred
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/CompoundPropertymodel-loses-object-after-form-submit-tp2248100p2248412.html
Sent from the Wicket - User mailing list archive at Nabble.com.
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org