Re: CompoundPropertymodel loses object after form submit

2010-06-09 Thread Manfred Bergmann

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



CompoundPropertymodel loses object after form submit

2010-06-08 Thread Bergmann Manfred
Hi.

I experience a strange behaviour where I'm not exactly sure what I'm doing 
wrong.
On my pages which are wrapped around some database model classes I have forms 
with CompoundPropertyModels.
On one of five pages the form seems to lose the model object after a submit is 
done so that the page reload after the submit displays empty labels and fields.
This is not the case on the other four pages/forms which basically have the 
same structure.
I got around this problem with explicitly setting the model object again in the 
onSubmit handler which seems to work.

Anyone got an explanation?
Ahh, I'm using Wicket 1.4.9.


Cheers,
Manfred


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: CompoundPropertymodel loses object after form submit

2010-06-08 Thread yaniv kessler
Can you show some code?

On Wed, Jun 9, 2010 at 1:01 AM, Bergmann Manfred 
m...@software-by-mabe.comwrote:

 Hi.

 I experience a strange behaviour where I'm not exactly sure what I'm doing
 wrong.
 On my pages which are wrapped around some database model classes I have
 forms with CompoundPropertyModels.
 On one of five pages the form seems to lose the model object after a submit
 is done so that the page reload after the submit displays empty labels and
 fields.
 This is not the case on the other four pages/forms which basically have the
 same structure.
 I got around this problem with explicitly setting the model object again in
 the onSubmit handler which seems to work.

 Anyone got an explanation?
 Ahh, I'm using Wicket 1.4.9.


 Cheers,
 Manfred


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Tel: +972-77-4100977
Fax: +972-77-4100976
Mobile: +972-54-7755427

http://www.codeark.com
http://blogs.microsoft.co.il/blogs/yanush/
http://headtoscreencollision.blogspot.com