File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Mutiple form problem in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Mutiple form problem in JSF" Watch "Mutiple form problem in JSF" New topic

Mutiple form problem in JSF

A.C Ac

Joined: Aug 09, 2012
Posts: 2
I have an xhtml page with two forms.In form1 I have one input text and in form two I have a submit button.In the actionlistener of the action button in form2 I want to get the value of the fom1's input textbox throgh the backing bean value.When I am trying it is giving null value.What is the workaround of this problem?
Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218
The obvious thing to do is to use one form. Why have you got two? This is the source of all your problems. The submit button
is submitting the values of components within the form it is in, which sounds like just the button. These values (ok, this value)
is sent to the server, but not the input field value.

There's rarely any reason to use multiple forms in an ajax world except in a few exceptional situations such as when doing
file upload and using dialogs. You just limit what gets sent to the server with f:ajax execute=, and you save yourself getting
confused about which naming container your components are in.

My understanding is that what you are trying to do is completely impossible with HTML & JSF.

A.C Ac

Joined: Aug 09, 2012
Posts: 2
I know it is not a good practice to have multiple forms in one single page.But I want it to achieve the following template

left content right content

Now in the actual page where I am using this template, I want to put my buttons in the left area and other inputs in the right area.On the click of the button on the left form should submit the values entered in the right form.
Please let me nkow how to achieve this.
I agree. Here's the link:
subject: Mutiple form problem in JSF
jQuery in Action, 3rd edition