Eelco Hillenius wrote:
On 9/12/07, Vit Rozkovec <[EMAIL PROTECTED]> wrote:
I checked the code out with svn, and run my project with last revision,
however the behavior is still the same.
In the Wizard.java method onBeforeRender() there is a condition
if (buttonBar instanceof IDefaultButtonProvider){}
which in my case never evaluates to true and so the form never gets set
the default button.
Am I correct that you provide your own button bar then? Please take a
look at how WizardButtonBar is implemented.
In fact no, I use standard WizardButtonBar. I checked the implementation
and I understand what it should do, but it does not. At the moment I
solved the problem a bit dirty way - inerhited WizardButtonBar and in
the template changed Finish button to be the first one, so on the last
step Enter is catched correctly by Finish button.
Do you want a code of my class? I do not do there something special, I
copied the class from wicket examples.
Sure.
Eelco
Here it is (full source with imports at http://rafb.net/p/sjz60X77.html )
public class NewRecordWizardPanel extends Wizard {
/**
* file from UploadPanel
*/
private Soubor soubor;
/**
* Step for uploading file
*/
private final class UploadFileStep extends WizardStep {
UploadPanel uploadPanel;
/**
* Construct.
*/
public UploadFileStep() {
setTitleModel(new ResourceModel("upload.title"));
setSummaryModel(new ResourceModel("upload.summary"));
// where to upload files
// TODO move to .properties
Folder uploadFolder = new Folder("data/", "ds-upload");
add(this.uploadPanel = new UploadPanel("uploadPanel",
uploadFolder));
}
@Override
protected void onInit(IWizardModel wizardModel) {
// form settings
Form form = NewRecordWizardPanel.this.getForm();
form.setMultiPart(true);
form.setMaxSize(this.uploadPanel.getMaxUploadSize());
super.onInit(wizardModel);
}
@Override
public void applyState() {
// after submitting step make appropriate actions in panel
this.uploadPanel.submitActions();
// get uploaded file
soubor = this.uploadPanel.getSoubor();
super.applyState();
}
}
/**
* Dublin Core input form
*/
private final class EditDCStep extends WizardStep {
private NewDCPanel panel;
public EditDCStep() {
setTitleModel(new ResourceModel("dublinCore.title"));
add(panel = new NewDCPanel("editDC"));
}
@Override
public void applyState() {
panel.submitActions(soubor);
super.applyState();
}
}
private Class responsePage = WizardPage.class;
/**
* Construct.
*
* @param id
* The component id
* @param responsePage
* page where cancel and finish go
*/
public NewRecordWizardPanel(String id, Class responsePage) {
this(id);
this.responsePage = responsePage;
}
/**
* Construct.
*
* @param id
* The component id
*/
public NewRecordWizardPanel(String id) {
super(id, false);
add(Shorthand.getCssForClass(NewRecordWizardPanel.class));
setModel(new CompoundPropertyModel(this));
WizardModel model = new WizardModel();
model.add(new UploadFileStep());
model.add(new EditDCStep());
// initialize the wizard with the wizard model we just built
init(model);
}
/**
* @see org.apache.wicket.extensions.wizard.Wizard#onCancel()
*/
public void onCancel() {
File file = new File(soubor.getFilePath());
if (file.exists()) {
file.delete();
}
// in case of Cancel button, delete already persisted data in
database
Session session = DataStaticService.getHibernateSession();
session.createQuery("delete Soubor as s where
s.id=:id").setParameter(
"id", soubor.getId()).executeUpdate();
setResponsePage(this.responsePage);
}
/**
* @see org.apache.wicket.extensions.wizard.Wizard#onFinish()
*/
public void onFinish() {
setResponsePage(this.responsePage);
}
}
Vitek
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]