0

I have a form that is very long but is submitted and validated all together. I need to break it up into sections.

I have tried using the Trinidad component panelAccordion to break the form into sections.

However if I then submit and validate the form, clicking one of the panels open or closed causes the validation messages to disappear.

Is there any way to avoid this?

Or is there a better way to achieve the same result of breaking up the form?

I am using Trinidad 1.2.6 and MyFaces 2.0. Due to corporate standards I cannot use anything else.

Laila Agaev
  • 1,782
  • 1
  • 10
  • 19

1 Answers1

0

One way you can achieve the desired effect is by submitting the form when a user clicks on each <tr:accordionPanel>. It supports many other client side events so pick one that best suits your needs.If you submit the entire form, this will force validation to kick in for all components however, whether the user entered a value or not. This might be the quickest and simplest way but some people might be picky and not like this solution.

You can also make use of partial updates and partial triggers and submit only the components that are part of the current accordion panel based on the event you choose.

Andy
  • 5,900
  • 2
  • 20
  • 29
  • I am interested in the idea of submitting on an event... I'm not sure how practical it will be (our validation takes a little while so from the user perspective it might be annoying or slow), but I will try it and see. As for using partial triggers I'm not sure about that as there are quite a few of these other components to trigger and the validation is highly customized and completely server-side. I think it would be both ugly and slow in my case (though it would probably work for others). Thanks for the advice! – Laila Agaev Jul 11 '13 at 15:07
  • @Laila Partial updates might be the way to go if your validation takes awhile. I'm thinking that this will reduce the number of components that trigger your validations, instead of all of them. Then again, I see your point if there's a lot. To be honest I'm not really used to MyFaces but maybe there's an equivalent to `@this` you could use, or wrap each accordionPanel with `f:ajax`. This might free you from hard coding all the ids...maybe. – Andy Jul 11 '13 at 15:21
  • @Laila Now I'm curious. I'll see what I can dig up. Keep you posted on your progress will you please ? – Andy Jul 11 '13 at 15:31
  • I ended up using a non-trinidad solution (pure Javascript and CSS tabs were more appropriate), but I'll mark this as the answer since it seems this is the only way to achieve what I wanted using the given framework. – Laila Agaev Sep 11 '13 at 19:45