You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Michael Heinen <mh...@recommind.com> on 2006/05/03 16:30:10 UTC

2 forms on one page?

Hi all,

 

I have another question:

 

Is it possible to define 2 forms on one page and that only the submitted
form is validated? 

e.g. buttonA submits formA and buttonB submits formB?

 

I have a datatable on my page with a detail pane.

The detail pane contains some fields in order to update the detail data
of the selected object (formA).

If the user selects multiple objects in the datatable, then I have to
show another form (formB) in order to update different fields at once
for the selected objects.

These fields have to be bound to different attributes of my backing bean
of course.

So if the user submits formB then the model of formA should not be
updated.

 

I want to switch the visibility of the 2 forms via javascript without a
generating new server request.

Does JSF support the above scenario (e.g. with subviews)?

Or is this a requirement that should be better processed with ajax
(which would be more complex for me)?

 

Any help is highly appreciated again

Michael


Re: 2 forms on one page?

Posted by Andrew Robinson <an...@gmail.com>.
I'm not sure about pure JSF, as I haven't really used it, but this is
very easy with facelets, just put in two forms.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core">
  <h:form id="formA">
    <h:dataTable .. />
  </h:form>
  <h:form id="formB" rendered="#{bean.somethingSelected}">
    <h:inputText .../>
    ...
  </h:form>
</html>

The whole view/subview may make this more complex in raw JSF. All your
state will be in the form (for client side state). The forms are just
normal HTML forms, so only the values in the submitted form will be
sent back, validated and updated.

Hope that helps,
-Andrew

On 5/3/06, Michael Heinen <mh...@recommind.com> wrote:
>
>
>
> Hi all,
>
>
>
> I have another question:
>
>
>
> Is it possible to define 2 forms on one page and that only the submitted
> form is validated?
>
> e.g. buttonA submits formA and buttonB submits formB?
>
>
>
> I have a datatable on my page with a detail pane.
>
> The detail pane contains some fields in order to update the detail data of
> the selected object (formA).
>
> If the user selects multiple objects in the datatable, then I have to show
> another form (formB) in order to update different fields at once for the
> selected objects.
>
> These fields have to be bound to different attributes of my backing bean of
> course.
>
> So if the user submits formB then the model of formA should not be updated.
>
>
>
> I want to switch the visibility of the 2 forms via javascript without a
> generating new server request.
>
> Does JSF support the above scenario (e.g. with subviews)?
>
> Or is this a requirement that should be better processed with ajax (which
> would be more complex for me)?
>
>
>
> Any help is highly appreciated again
>
> Michael

Re: 2 forms on one page?

Posted by Catalin Kormos <ca...@yahoo.com>.
Hi,

Looks to me like you could use the subForm component from sandbox:
http://myfaces.apache.org/sandbox/subForm.html

HTH,
Catalin

Michael Heinen <mh...@recommind.com> wrote:          st1\:*{behavior:url(#default#ieooui) }           Hi all,
   
  I have another question:
   
  Is it possible to define 2 forms on one page and that only the submitted form is validated? 
  e.g. buttonA submits formA and buttonB submits formB?
   
  I have a datatable on my page with a detail pane.
  The detail pane contains some fields in order to update the detail data of the selected object (formA).
  If the user selects multiple objects in the datatable, then I have to show another form (formB) in order to update different fields at once for the selected objects.
  These fields have to be bound to different attributes of my backing bean of course.
  So if the user submits formB then the model of formA should not be updated.
   
  I want to switch the visibility of the 2 forms via javascript without a generating new server request.
  Does JSF support the above scenario (e.g. with subviews)?
  Or is this a requirement that should be better processed with ajax (which would be more complex for me)?
   
  Any help is highly appreciated again
  Michael
  
  

		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.