Re: AjaxFormComponentUpdatingBehavior after validation problem

2012-04-27 Thread Gytis
Hello, here I renew this thread, because this problem is still cannot be
resolved.
So problem is that when you have AjaxFormComponentUpdatingBehaviour it works
fine, until that moment, when you try to submit your form. So when you get
error, that some kind of value is not as it is not supposed to be, all of
this AjaxBehaviour starts working kinda strange, it doesn`t update Models...
What can solve this problem?


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AjaxFormComponentUpdatingBehavior-after-validation-problem-tp4477705p4592316.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: AjaxFormComponentUpdatingBehavior after validation problem

2012-03-19 Thread Michal Wegrzyn
Hi Gytis,

If you add AjaxFormSubmitBehaviour to your checkbox it should work exactly as 
Submit button.

Best regards,
Michal Wegrzyn

 -Original Message-
 From: Gytis [mailto:lietuvis...@mail.ru]
 Sent: Sunday, March 18, 2012 8:02
 To: users@wicket.apache.org
 Subject: RE: AjaxFormComponentUpdatingBehavior after validation problem
 
 Hello, Michal,
 Well, I`ve tried to make an AjaxFormSubmitBehaviour, but this doesn`t
 help, in fact it is updating component, when you click Submit button,
 and I need it updated, when clicking checkBox.
 I`ve tried to add both Ajax behaviours, still doesn`t work. Wanted to
 add some details on my code, for form submitting I use AjaxButton...
 
 --
 View this message in context: http://apache-
 wicket.1842946.n4.nabble.com/AjaxFormComponentUpdatingBehavior-after-
 validation-problem-tp4477705p4481742.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


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



RE: AjaxFormComponentUpdatingBehavior after validation problem

2012-03-18 Thread Evan Sable
Hello,

I think the problem is just that you're calling setValues on your
genericModelObject, which is set as the compoundpropertymodel for your
form, but you're not adding the form back to the ajax response - with the
AjaxRequestTarget, you're only adding the component dropDownId to get
re-rendered into the page, not the form with the updated model.  So, the
change made directly on the dropdown which is added to the ajaxRequestTarget
(calling setEnabled) is taking effect, but it's not finding the updated
model.  It should work if you add:
target.addComponent(get(formId));

Hope that helps,
-Evan

-Original Message-
From: Gytis [mailto:lietuvis...@mail.ru] 
Sent: Friday, March 16, 2012 5:32 AM
To: users@wicket.apache.org
Subject: AjaxFormComponentUpdatingBehavior after validation problem

Hello, I have such a problem with AjaxFormComponentUpdatingBehavior. 
I have some DropDownChoice and a CheckBox on a Form. I need to make a change
to DropDown, when I click on CheckBox. But as I try to submit a Form, got
some error, and then click CheckBox DropDown doesn`t change. The code looks
like this: 

   DropDownChoiceSomeEnum dropDownz = new
DropDownChoiceSomeEnum(dropDownId,
Arrays.asList(SomeEnum.values()), new
EnumChoiceRendererSomeEnum(this));
   getGenericModelObject().setValues(SomeEnum.FIRSTVALUE);
   CheckBox boxz = new CheckBox(BoxId);
   boxz.add(new AjaxFormComponentUpdatingBehavior(onchange)
{
@Override
protected void onUpdate(AjaxRequestTarget target) {
if (boxz.getModelObject())
{

getGenericModelObject().setValues(SomeEnum.SECONDVALUE);
get(dropDownId).setEnabled(false);

target.addComponent(get(dropDownId));
}
else
{
get(dropDownId).setEnabled(true);

target.addComponent(get(dropDownId));
}
}
@Override
protected void onError(AjaxRequestTarget target,
RuntimeException e) {
if (boxz.getModelObject())
{

getGenericModelObject().setValues(SomeEnum.SECONDVALUE);
get(dropDownId).setEnabled(false);

target.addComponent(get(dropDownId));
}
else
{
get(dropDownId).setEnabled(true);

target.addComponent(get(dropDownId));
}
super.onError(target, e);
}
});
 Form form = new Form(formId, getGenericModel());
 form.add(dropDownz);
 form.add(boxz);

So as I said, after form validation, if errors occur, it won`t change
dropdown to SECONDVALUE, but sets it as setEnabled(false), why this happens?

--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/AjaxFormComponentUpdatingBehavior
-after-validation-problem-tp4477705p4477705.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: AjaxFormComponentUpdatingBehavior after validation problem

2012-03-16 Thread Michal Wegrzyn
Hi,

Did you try using AjaxCheckBox instead of CheckBox with ajax behavior?

Best regards,
Michal Wegrzyn

 -Original Message-
 From: Gytis [mailto:lietuvis...@mail.ru]
 Sent: Friday, March 16, 2012 10:32
 To: users@wicket.apache.org
 Subject: AjaxFormComponentUpdatingBehavior after validation problem
 
 Hello, I have such a problem with AjaxFormComponentUpdatingBehavior.
 I have some DropDownChoice and a CheckBox on a Form. I need to make a
 change to DropDown, when I click on CheckBox. But as I try to submit a
 Form, got some error, and then click CheckBox DropDown doesn`t change.
 The code looks like this:
 
DropDownChoiceSomeEnum dropDownz = new
 DropDownChoiceSomeEnum(dropDownId,
   Arrays.asList(SomeEnum.values()), new
 EnumChoiceRendererSomeEnum(this));
getGenericModelObject().setValues(SomeEnum.FIRSTVALUE);
CheckBox boxz = new CheckBox(BoxId);
boxz.add(new AjaxFormComponentUpdatingBehavior(onchange)
   {
   @Override
   protected void onUpdate(AjaxRequestTarget target) {
   if (boxz.getModelObject())
   {
 
   getGenericModelObject().setValues(SomeEnum.SECONDVALUE);
   get(dropDownId).setEnabled(false);
   target.addComponent(get(dropDownId));
   }
   else
   {
   get(dropDownId).setEnabled(true);
   target.addComponent(get(dropDownId));
   }
   }
   @Override
   protected void onError(AjaxRequestTarget target,
 RuntimeException e) {
   if (boxz.getModelObject())
   {
 
   getGenericModelObject().setValues(SomeEnum.SECONDVALUE);
   get(dropDownId).setEnabled(false);
   target.addComponent(get(dropDownId));
   }
   else
   {
   get(dropDownId).setEnabled(true);
   target.addComponent(get(dropDownId));
   }
   super.onError(target, e);
   }
   });
  Form form = new Form(formId, getGenericModel());
  form.add(dropDownz);
  form.add(boxz);
 
 So as I said, after form validation, if errors occur, it won`t change
 dropdown to SECONDVALUE, but sets it as setEnabled(false), why this
 happens?
 
 --
 View this message in context: http://apache-
 wicket.1842946.n4.nabble.com/AjaxFormComponentUpdatingBehavior-after-
 validation-problem-tp4477705p4477705.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


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



RE: AjaxFormComponentUpdatingBehavior after validation problem

2012-03-16 Thread Gytis
Hi, Michal, I`ve tried AjaxCheckBox component, but problem is the same.
I even made Sytem.out.println() of what object is set in DropDown, it shows
that Object is SECONDVALUE, but still shows me FIRSTVALUE. Both dropDownz
and CheckBox OutputMarkupId set to true.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AjaxFormComponentUpdatingBehavior-after-validation-problem-tp4477705p4478018.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: AjaxFormComponentUpdatingBehavior after validation problem

2012-03-16 Thread Michal Wegrzyn
You can try using AjaxFormSubmitBehavior instead of 
AjaxFormComponentUpdatingBehavior.

Compare 

org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior.onEvent(AjaxRequestTarget
 target)

and

org.apache.wicket.ajax.form.AjaxFormSubmitBehavior.onEvent(AjaxRequestTarget 
target)

Best regards,
Michal Wegrzyn

 -Original Message-
 From: Gytis [mailto:lietuvis...@mail.ru]
 Sent: Friday, March 16, 2012 13:13
 To: users@wicket.apache.org
 Subject: RE: AjaxFormComponentUpdatingBehavior after validation problem
 
 Hi, Michal, I`ve tried AjaxCheckBox component, but problem is the same.
 I even made Sytem.out.println() of what object is set in DropDown, it
 shows that Object is SECONDVALUE, but still shows me FIRSTVALUE. Both
 dropDownz and CheckBox OutputMarkupId set to true.
 
 --
 View this message in context: http://apache-
 wicket.1842946.n4.nabble.com/AjaxFormComponentUpdatingBehavior-after-
 validation-problem-tp4477705p4478018.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


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