0

I am not able to keep my wicket form fields blank after browser refresh once they are submitted on the page; my fields are present in a group box.

I have a wicket form with a group box which is having a date picker and text field. If I am entering data and submitting it gives success response. On browser refresh, I want those fields to become empty but they don't.

I tried setting every field to blank after success response as fieldName.setModelValue(new String[]{" "});.

I need this to be done at browser refresh handling without setting it everywhere.

AstroCB
  • 12,337
  • 20
  • 57
  • 73
  • To receive help you should provide more code (the submit routine, what kind of models you use, etc ...) – thg Apr 10 '15 at 11:05

1 Answers1

0

You have (at least) these three options:

1) on success redirect to a fresh instance of the current page, i.e. setResponsePage(getPage().getClass())

2) stay on the current page, but set an "empty" model to the Form. By "empty" I mean whatever "empty" means in your context. Use #setModel() on the form or on the form component. Do not use #setModelValue().

3) Use a stateless page (with StatelessForm) if this is possible

martin-g
  • 17,243
  • 2
  • 23
  • 35
  • i mean to ask. on 'browser refresh', form fields should retain their default nature as they were at landing time. (for me they are blank at landing time) – prashanth Apr 10 '15 at 14:28
  • a 4th option would be to turn the page versioning off for that page (setVersioned(false)). You are refreshing the latest version of that page (including the submitted values) that's why the page is not blank – Thorsten Wendelmuth Apr 11 '15 at 14:26