[SOLVED] DataTable constantly loses state

UI Components for JSF
Post Reply
bkrebs
Posts: 4
Joined: 19 Nov 2010, 20:38

16 Dec 2010, 00:03

I am using Tomcat 7.0.3 with Mojarra 2.0.3 FCS and PrimeFaces 2.2 RC2. I was having an issue where any request would immediately reset the state of my p:datatable. This behavior originally manifested itself when I realized my backing bean's selection setter method for the p:datatable was always being called with a null value so I could never get the current selection. I found out eventually, supported by the manual, that there are certain configurations of p:layout's and p:layoutUnit's that are unsupported with h:form elements.

The solution is to place your h:form inside of a p:layoutUnit. For example, the following code did *not* work:

Code: Select all

<h:form>
    <p:layout>
        <p:layoutUnit position="bottom">
            ...
        </p:layoutUnit>
        <p:layoutUnit position="center">
            <p:layout>
                <p:layoutUnit position="left">
                    <p:datatable>
                        ...
                    </p:datatable>
                </p:layoutUnit>
             </p:layout>
        </p:layoutUnit>
    </p:layout>
</h:form>
However, the following code *does* work:

Code: Select all

<p:layout>
    <p:layoutUnit position="bottom">
        ...
    </p:layoutUnit>
    <p:layoutUnit position="center">
        <h:form>
            <p:layout>
                <p:layoutUnit position="left">
                    <p:datatable>
                        ...
                    </p:datatable>
                </p:layoutUnit>
            </p:layout>
        </h:form>
    </p:layoutUnit>
</p:layout>
I was banging my head on the wall for hours upon hours on this and surprisingly, there is no mention of this use case on the forums. I hope I have saved someone some time.

rmuller
Posts: 6
Joined: 23 Sep 2010, 16:46

16 Dec 2010, 16:53

Thank you VERY much for sharing this. I had the same problem and already spent almost 2 hours on this issue.

Regards,

Ronald

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests