two forms on one page causes submit problem

UI Components for JSF
Post Reply
nickparker
Posts: 5
Joined: 04 Feb 2010, 15:32

19 Feb 2010, 12:02

Hi

I have a number of forms on the page, each with its own submit button. They are each in a separate tab.

When I click on the submit button on the second form I believe that the top form is submitted but the eventListener for the second button is fired in the bean. This is because the object bound to the form has field values of those set in the top form when I submit.

Code: Select all

<h:form id="cartridgeAssetForm1" prependId="false">
                                    <h:panelGrid columns="2" >
                                        <h:outputLabel value="Code" for="itemCode" />
                                        <h:inputText id="aa" value="#{defaultItemController.selected.code}" title="Code" />
                                        <h:outputLabel value="Name" for="itemName" />
                                        <h:inputText id="bb" value="#{defaultItemController.selected.name}" title="Name" />
                                        <h:outputLabel value="Description" for="itemDescription" />
                                        <h:inputText id="cc" value="#{defaultItemController.selected.description}" title="Description" />
                                        <h:outputLabel value="Category" for="itemCategory" />
                                        <h:inputText id="dd" value="#{defaultItemController.selected.category}" title="Category" />
                                    </h:panelGrid>
                                    <p:commandButton actionListener="#{defaultItemController.store}" value="Update" update="assetList" immediate="true" type="submit" />
</h:form>
                                    <h:form id="cartridgeAssetForm2" prependId="false">
                                    <h:panelGrid columns="2" >
                                        <h:outputLabel value="Code" for="itemCode" />
                                        <h:inputText id="a" value="#{defaultItemController.selected.code}" title="Code" />
                                        <h:outputLabel value="Name" for="itemName" />
                                        <h:inputText id="b" value="#{defaultItemController.selected.name}" title="Name" />
                                        <h:outputLabel value="Description" for="itemDescription" />
                                        <h:inputText id="c" value="#{defaultItemController.selected.description}" title="Description" />
                                        <h:outputLabel value="Category" for="itemCategory" />
                                        <h:inputText id="d" value="#{defaultItemController.selected.category}" title="Category" />
                                    </h:panelGrid>
                                    <p:commandButton actionListener="#{defaultItemController.store}" value="Update" update="assetList" immediate="true" type="submit"  process="cartridgeAssetForm"/>
                                </h:form>

When I look in the HTML I can see that each submit button references the correct form id, however it seems the referenced form is not being submitted.

Has anyone else seen this?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

19 Feb 2010, 15:20

I couldn't understand it clearly, you don't have nested forms right?

Also if you have multiple forms, it is a good idea to keep prependId to true(default).

nickparker
Posts: 5
Joined: 04 Feb 2010, 15:32

19 Feb 2010, 18:42

The forms are not nested.
I just have more than one form on the page, the examle shown is a partial page but in the full page when the Submit button is fired the correct bean method is fired but the bound data does not update the bean member that represents the data in the form, the values are null.

helloprimefaces
Posts: 56
Joined: 28 Sep 2009, 17:44

21 Feb 2010, 01:22

May be its something related to this one
http://primefaces.prime.com.tr/forum/vi ... f=3&t=1367

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

23 Feb 2010, 16:27

Can't replicate this, I see you are using partial processing process="cartridgeAssetForm" but can't see that component. Can you post the whole tabview.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 40 guests