Re: Wizard clear all formfields

2012-05-16 Thread jensiator
Ended up with this:
public class ClearFormComponentWizardStep extends WizardStep {

public ClearFormComponentWizardStep(String pTitleMessageKey) {
this(pTitleMessageKey, new ModelString());
}

public ClearFormComponentWizardStep(String pTitleMessageKey, IModel?
extends Serializable pModel) {
super(pTitleMessageKey, pModel);
}

@Override
public Component getView(String pId, Component pParent, IWizard 
pWizard) {
WebMarkupContainer view = (WebMarkupContainer) 
super.getView(pId, pParent,
pWizard);
if(isTimeToClear()) {
clearAllFormComponent(view);
}
return view;
}

/**
 * Can be overriden for changing the clearAllForm behavior
 * 
 * @param pView
 */
protected void clearAllFormComponent(WebMarkupContainer pView) {
pView.visitChildren(FormComponent.class, new
Component.IVisitorFormComponentlt;?() {
@Override
public Object component(FormComponent? 
pFormComponent) {
pFormComponent.clearInput();
return Component.IVisitor.CONTINUE_TRAVERSAL;
}
});
}

/**
 * Override this if any other parameter would affect
clearAllFormComponentCode
 * 
 * @return
 */
protected boolean isTimeToClear() {
return true;
}

}

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wizard-clear-all-formfields-tp4634057p4641106.html
Sent from the Users forum 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



Wizard clear all formfields

2012-05-15 Thread jensiator
Hi everyone. 
I got a problem. Anyone ever had a first step contain for example a dropdown
that will load default data to the other formcomponents in the wizard?
The dropdown has got a ajaxformcomponentupdatingbehavior. We call our server
in the ajax request and update a lot of properties in the model object. The
model object shared between all of the pages. 
If you show step2 it will show the correct default values. 
If you then go back to step1 again and change the dropdown, step2 will not
show the changes. This I  because I need to clear the input of the
formcomponents in step2. Is there any way to clear all formcomponents for
all steps in a wizard. The problem is that only one step at the time is
active.  
Is Overriding onBefore render on every single step the only way? 

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wizard-clear-all-formfields-tp4634057.html
Sent from the Users forum 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



Re: Wizard clear all formfields

2012-05-15 Thread Alexander Cherednichenko
Hi!
If the question is correctly understood by me, all u need is to traverse
the form for all the components and clear input -- then just use form
component visitor, traverse the entire form and clear components' input.

however itd be good if someone else on the list told if such a solution is
any good.

regards,
Alex.
On May 15, 2012 10:50 AM, jensiator jens.alen...@gmail.com wrote:

 Hi everyone.
 I got a problem. Anyone ever had a first step contain for example a
 dropdown
 that will load default data to the other formcomponents in the wizard?
 The dropdown has got a ajaxformcomponentupdatingbehavior. We call our
 server
 in the ajax request and update a lot of properties in the model object. The
 model object shared between all of the pages.
 If you show step2 it will show the correct default values.
 If you then go back to step1 again and change the dropdown, step2 will not
 show the changes. This I  because I need to clear the input of the
 formcomponents in step2. Is there any way to clear all formcomponents for
 all steps in a wizard. The problem is that only one step at the time is
 active.
 Is Overriding onBefore render on every single step the only way?

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Wizard-clear-all-formfields-tp4634057.html
 Sent from the Users forum 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




Re: Wizard clear all formfields

2012-05-15 Thread Martin Grigorov
Form.clearInput() does exactly that.

On Tue, May 15, 2012 at 10:01 AM, Alexander Cherednichenko
lex...@gmail.com wrote:
 Hi!
 If the question is correctly understood by me, all u need is to traverse
 the form for all the components and clear input -- then just use form
 component visitor, traverse the entire form and clear components' input.

 however itd be good if someone else on the list told if such a solution is
 any good.

 regards,
 Alex.
 On May 15, 2012 10:50 AM, jensiator jens.alen...@gmail.com wrote:

 Hi everyone.
 I got a problem. Anyone ever had a first step contain for example a
 dropdown
 that will load default data to the other formcomponents in the wizard?
 The dropdown has got a ajaxformcomponentupdatingbehavior. We call our
 server
 in the ajax request and update a lot of properties in the model object. The
 model object shared between all of the pages.
 If you show step2 it will show the correct default values.
 If you then go back to step1 again and change the dropdown, step2 will not
 show the changes. This I  because I need to clear the input of the
 formcomponents in step2. Is there any way to clear all formcomponents for
 all steps in a wizard. The problem is that only one step at the time is
 active.
 Is Overriding onBefore render on every single step the only way?

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Wizard-clear-all-formfields-tp4634057.html
 Sent from the Users forum 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





-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



Re: Wizard clear all formfields

2012-05-15 Thread jensiator
Yes you are correct. I forgot to mention that I have already tried it. It
does not work because Step2 formcomponents is not a part of the wizard form
when step1 is. 
I think its done here in Wizard class
public void onActiveStepChanged(IWizardStep newStep)
{
 form.replace(newStep.getView(VIEW_ID, this, this));
 form.replace(newStep.getHeader(HEADER_ID, this, this));
}


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wizard-clear-all-formfields-tp4634057p4634120.html
Sent from the Users forum 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



Re: Wizard clear all formfields

2012-05-15 Thread Alexander Cherednichenko
Then, manual traversal of the components of the newStep.getView(VIEW_ID,
this, this) with the form component visitor and clearing input for every
form component would work. Surely, if it is the same object returned every
time from getView(...)

2012/5/15 jensiator jens.alen...@gmail.com

 Yes you are correct. I forgot to mention that I have already tried it. It
 does not work because Step2 formcomponents is not a part of the wizard form
 when step1 is.
 I think its done here in Wizard class
 public void onActiveStepChanged(IWizardStep newStep)
 {
  form.replace(newStep.getView(VIEW_ID, this, this));
  form.replace(newStep.getHeader(HEADER_ID, this, this));
 }


 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Wizard-clear-all-formfields-tp4634057p4634120.html
 Sent from the Users forum 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




-- 
Alexander Cherednichenko

[ the only way out is the way up ]


Re: Wizard clear all formfields

2012-05-15 Thread jensiator
Good Idea. I will try it. The only drawback is that it will be done
everytime. Even if I go back to step1 and don't do anything. But I might be
able to live with that 
Thanks

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wizard-clear-all-formfields-tp4634057p4634157.html
Sent from the Users forum 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