Re: AjaxTabbedPanel and validation for all tabs

2014-05-17 Thread mscoon
The reason I want to avoid client tabs is speed. The form has several
components that are slow to render (drop downs filled with REST service
calls).

I ended up implementing this as follows:
- An AjaxTabbedPanel with links that will submit the form currently shown
(I look for the first child of class Form of the AjaxTabbedPanel but one
could as well submit a form containing the AjaxTabbedPanel)
- My own validation utility that validates objects using wicket's
validation framework. This is more or less an object that allows the
developer to attach validators to class properties. Then an object is
validated by generating a Validatable object for each property and running
the attached validators. Finally, errors are propagated to form components
by matching the component id to the property name.
- Validation runs on the entire object, not just one tab.

So:
- Every time the user tries to switch tabs, the form is submitted, and the
entire object is validated. The errors relevant to the current tab are
isolated and shown in a feedback panel inside the tab, and the
tab-switching is cancelled. If there are no errors relevant to the current
tab, the tab-switching goes ahead.
- If the user clicks save, again the current form is submitted and the
entire object is validated. If there are any errors, the user gets a popup
message that indicates which tabs have errors.

There are a few more details involved which I won't go into unless somebody
wants to get the full story.

Overall it's not a super clean solution, but it is not too bad either.
Wicket again came through and made it possible to implement this scenario
without much pain.

And I'm quite happy with my object validator. Because now I get a
validator that can run both on a form (by validating it's model object) and
on another channel of data entry (say a REST service) that reuses wicket's
validators and error messages (so it's consistent with other forms that
directly use wicket's validation).

Marios





On Wed, May 7, 2014 at 9:43 AM, Tom Götz t...@decoded.de wrote:

 The easiest solution I can think of. Why do you want to avoid that?

 Cheers,
-Tom

 On 06.05.2014, at 16:13, mscoon msc...@gmail.com wrote:

  Is there a way to solve this? Client side tabs are a solution I guess but
  one I'd like to avoid if possible.







Re: AjaxTabbedPanel and validation for all tabs

2014-05-16 Thread Paul Bors
My recommendation would be to use bean validation and Ajax to update the UI.

On Tuesday, May 6, 2014, mscoon msc...@gmail.com wrote:

 Hi all,

 I have a complex form for editing existing objects. I am planning to use
 AjaxTabbedPanel with adapted ajax links for the tabs to submit the current
 tab when the user switches tabs.

 There will be a save button under the tabbed panel that will save the
 entire object.

 For new objects, I could force the user to visit all tabs before allowing
 them to save, to guarantee that the validators have ran for all form
 components and all tabs.

 The twist here is that the object, when loaded, may be invalid. But I don't
 want to force the user to visit all tabs when editing an existing object
 because it will very unfriendly (imagine the user wanting to update just
 one field in the first tab and being forced to visit all five tabs before
 saving).

 So I am looking for a way to make sure that all validators run when the
 user clicks save. As far as I understand there is no way to force all
 wicket validators to execute because the request will only contain post
 data for the active tab.

 Is there a way to solve this? Client side tabs are a solution I guess but
 one I'd like to avoid if possible.

 I did consider moving my validation logic to a server side validation
 method. The problem here is that you cannot leverage wicket's existing
 validators and error messages and also it becomes considerably harder to
 provide visual feedback for errors (e.g. highlight the components with
 errors). On the plus side, you do have a validation method that can be
 reused if you have alternate methods for updating the same data (e.g. via a
 REST service).

 Are there any pointers on using server side validation with wicket forms?

 Thanks in advance,
 Marios



Re: AjaxTabbedPanel and validation for all tabs

2014-05-15 Thread Tom Götz
The easiest solution I can think of. Why do you want to avoid that?

Cheers,
   -Tom

On 06.05.2014, at 16:13, mscoon msc...@gmail.com wrote:

 Is there a way to solve this? Client side tabs are a solution I guess but
 one I'd like to avoid if possible.






AjaxTabbedPanel and validation for all tabs

2014-05-06 Thread mscoon
Hi all,

I have a complex form for editing existing objects. I am planning to use
AjaxTabbedPanel with adapted ajax links for the tabs to submit the current
tab when the user switches tabs.

There will be a save button under the tabbed panel that will save the
entire object.

For new objects, I could force the user to visit all tabs before allowing
them to save, to guarantee that the validators have ran for all form
components and all tabs.

The twist here is that the object, when loaded, may be invalid. But I don't
want to force the user to visit all tabs when editing an existing object
because it will very unfriendly (imagine the user wanting to update just
one field in the first tab and being forced to visit all five tabs before
saving).

So I am looking for a way to make sure that all validators run when the
user clicks save. As far as I understand there is no way to force all
wicket validators to execute because the request will only contain post
data for the active tab.

Is there a way to solve this? Client side tabs are a solution I guess but
one I'd like to avoid if possible.

I did consider moving my validation logic to a server side validation
method. The problem here is that you cannot leverage wicket's existing
validators and error messages and also it becomes considerably harder to
provide visual feedback for errors (e.g. highlight the components with
errors). On the plus side, you do have a validation method that can be
reused if you have alternate methods for updating the same data (e.g. via a
REST service).

Are there any pointers on using server side validation with wicket forms?

Thanks in advance,
Marios