Re: Finishing wizard by pressing Enter

2007-09-12 Thread Vit Rozkovec
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.


Do you want a code of my class? I do not do there something special, I 
copied the class from wicket examples.


Vitek

I didn't quite make 'today', but it is fixed now. See
https://issues.apache.org/jira/browse/WICKET-955

Defaults in WizardButtonBar should work for most people, but if you
want something different, you can let your button bar implement
IDefaultButtonProvider (which is a new interface).

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Finishing wizard by pressing Enter

2007-09-12 Thread Vit Rozkovec

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]



Re: Finishing wizard by pressing Enter

2007-09-12 Thread Eelco Hillenius
On 9/12/07, Vit Rozkovec [EMAIL PROTECTED] wrote:
 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.

I'm sorry I didn't mention this, but this
https://issues.apache.org/jira/browse/WICKET-954 was a related bug I
fixed two days ago. So for the update to work you also need the latest
snapshot of wicket, not just wicket-extensions.

If it still doesn't work, that's a bug. Could you try please?

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Finishing wizard by pressing Enter

2007-09-12 Thread Vit Rozkovec

Eelco Hillenius wrote:

On 9/12/07, Vit Rozkovec [EMAIL PROTECTED] wrote:
  

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.



I'm sorry I didn't mention this, but this
https://issues.apache.org/jira/browse/WICKET-954 was a related bug I
fixed two days ago. So for the update to work you also need the latest
snapshot of wicket, not just wicket-extensions.

If it still doesn't work, that's a bug. Could you try please?

Eelco
  


Yes, I checked out all trunk and did mvn install in parent directory. To 
be sure, I checked content of the Form.class in included jar and there 
is the patched code.

The behavior is the same.

But I do not think it is the problem, if I understand it well.

As I said earlier, in Wizard.java's method

protected void onBeforeRender()
   {
   super.onBeforeRender();
   Component buttonBar = get(BUTTONS_ID);
   if (buttonBar instanceof IDefaultButtonProvider)
   {
   IFormSubmittingComponent defaultButton = 
((IDefaultButtonProvider)buttonBar)

   .getDefaultButton(wizardModel);
   form.setDefaultButton(defaultButton);
   }
   }

in Component buttonBar = get(BUTTONS_ID); the buttonBar variable is 
assigned null, so we do not even reach form.setDefaultButton(defaultButton);


Vitek


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Finishing wizard by pressing Enter

2007-09-12 Thread Eelco Hillenius

 As I said earlier, in Wizard.java's method

 protected void onBeforeRender()
 {
 super.onBeforeRender();
 Component buttonBar = get(BUTTONS_ID);
 if (buttonBar instanceof IDefaultButtonProvider)
 {
 IFormSubmittingComponent defaultButton =
 ((IDefaultButtonProvider)buttonBar)
 .getDefaultButton(wizardModel);
 form.setDefaultButton(defaultButton);
 }
 }

Ugh. That get call should have been done on form of course. Sorry for
the oversight. It is fixed now.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Finishing wizard by pressing Enter

2007-09-12 Thread Vit Rozkovec

Eelco Hillenius wrote:

As I said earlier, in Wizard.java's method

protected void onBeforeRender()
{
super.onBeforeRender();
Component buttonBar = get(BUTTONS_ID);
if (buttonBar instanceof IDefaultButtonProvider)
{
IFormSubmittingComponent defaultButton =
((IDefaultButtonProvider)buttonBar)
.getDefaultButton(wizardModel);
form.setDefaultButton(defaultButton);
}
}



Ugh. That get call should have been done on form of course. Sorry for
the oversight. It is fixed now.

Eelco
  
It works perfect now. The only last thing I would do when accessing form 
is to either use in both cases  getForm() or form, but maybe I am too 
pedant :)


Vitek

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Finishing wizard by pressing Enter

2007-09-12 Thread Eelco Hillenius
 It works perfect now. The only last thing I would do when accessing form
 is to either use in both cases  getForm() or form

Right, fixed that.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Finishing wizard by pressing Enter

2007-09-05 Thread David Leangen

You can override the Finish button and create your own ButtonBar (or
whatever it's called... don't have the API in front of me).

Cheers,
Dave



 -Original Message-
 From: Vit Rozkovec [mailto:[EMAIL PROTECTED]
 Sent: 5 September 2007 23:11
 To: users@wicket.apache.org
 Subject: Finishing wizard by pressing Enter


 Hi,
 what is the best way to make a Finish button the default processing
 button of the Wizard component?
 When I am in the last step of the wizard and in the form field I press
 Enter, it takes me to the previous step. I would like to finish the
 wizard. Is it possible?

 Thank you for any suggestion.

 Vitek

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Finishing wizard by pressing Enter

2007-09-05 Thread Al Maw

Vit Rozkovec wrote:
what is the best way to make a Finish button the default processing 
button of the Wizard component?
When I am in the last step of the wizard and in the form field I press 
Enter, it takes me to the previous step. I would like to finish the 
wizard. Is it possible?


This is a limitation of the browsers and HTML. They all focus the first 
button in the form as the default one. In theory they should not submit 
the form at all when you hit enter, but Internet Explorer started doing 
it, so everyone else uses the same behaviour. Sucks. :/


Regards,

Al
--
Alastair Maw
Wicket-biased blog at http://herebebeasties.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Finishing wizard by pressing Enter

2007-09-05 Thread Eelco Hillenius
On 9/5/07, Al Maw [EMAIL PROTECTED] wrote:
 Vit Rozkovec wrote:
  what is the best way to make a Finish button the default processing
  button of the Wizard component?
  When I am in the last step of the wizard and in the form field I press
  Enter, it takes me to the previous step. I would like to finish the
  wizard. Is it possible?

 This is a limitation of the browsers and HTML. They all focus the first
 button in the form as the default one. In theory they should not submit
 the form at all when you hit enter, but Internet Explorer started doing
 it, so everyone else uses the same behaviour. Sucks. :/

Well, we have a trick that mostly works and expose via the
defaultButton property of Form. I'll try to look at it later today.

Eelco

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]