• Post Reply Bookmark Topic Watch Topic
  • New Topic

2 forms in a page?  RSS feed

 
Jolie Lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i have 2 form tag in a page?

i tried to do that but somehow it will submit the whole page even though some tags are not in the form i submitted..
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I Don't believe JSF supports 2 form tags on the same page. Why do you need 2 forms?
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There were issues in earlier JSF version, but now you can use two forms in a page.
I have a page with search criteria at the top and search results (in datatable) at the bottom, both sections are in different forms and it works fine.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Varun Khanna:
There were issues in earlier JSF version, but now you can use two forms in a page.
I have a page with search criteria at the top and search results (in datatable) at the bottom, both sections are in different forms and it works fine.


That's good to know. I guess I never realized they fixed the problem. That, and I have never had the need for more than 1 form on a page.
 
Mauro Castaldo
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Varun Khanna:
There were issues in earlier JSF version, but now you can use two forms in a page.
I have a page with search criteria at the top and search results (in datatable) at the bottom, both sections are in different forms and it works fine.

yes, it works but there are two side effects:
- if your option is to save state on client you have a duplicated hidden field with state info for the entire components tree of the page (not very good if you have many components on your page)
- if you submit one of the two forms, JSF will not preserve any user edits in the input fields of the other form.
This is why Oracle propose ADF Faces subform tag to manage different validation groups using only one form (technically speaking they submit the whole form but process conversion, validation and updates only for UIInput components nested into "used" subform tag).

Mauro
 
Jolie Lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm, i tried to have two forms, but when i submit the first form, it shows me validation error cos my 2nd forms there's validation checking....

how should i go about it?
 
Mauro Castaldo
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jolie Lee:
hmm, i tried to have two forms, but when i submit the first form, it shows me validation error cos my 2nd forms there's validation checking....

how should i go about it?


strange behavior... can you show your code?
 
Jolie Lee
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes yes.. it works... must be something i've done wrong previously..

thks guys!!
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mauro Castaldo:

yes, it works but there are two side effects:
- if your option is to save state on client you have a duplicated hidden field with state info for the entire components tree of the page (not very good if you have many components on your page)
- if you submit one of the two forms, JSF will not preserve any user edits in the input fields of the other form.
This is why Oracle propose ADF Faces subform tag to manage different validation groups using only one form (technically speaking they submit the whole form but process conversion, validation and updates only for UIInput components nested into "used" subform tag).

Mauro


That's interesting. Thanks for sharing. Any idea why it generates duplicate hidden field?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!