开发者

How to persist order in JSF datatable or datamodel

I'm using JSF and I have a complex datatable where the user can sort by column headings, re-order individual entries, etc. The table itself contains rows that are made up of BOTH read-only and freely editable checkboxes and textfields. Each instance of the datatable averages about 50 rows but can scale up to 250 or so.

Given that retrieved data (from the database) can be adjusted (by the user) I have gone down the path of creating a wrapper collection around an ArrayList that contains sorting, the ability to move data, etc. The real butt kicker however is that I need to "persist" both the contents and the order of the row entries to the database on submit.

My current collection is physically moving the objects around as I didn't want to maintain a separate list of indexes for fear that they would become out of sync. This is also why I choose to combine both the retrieved and captured data into a single object.

Is this the right approach here? I did investigate the JSF DataModel but was not sure if it开发者_如何转开发 would allow me to persist the data in the current sort order as easily as physically moving the elements around.


Physically moving the objects around was the right approach here as the number of elements would rarely exceeds the 50 row average so performance was not an issue.

Since the objects were physically moved, the natural indexes of the list could be relied upon without having to maintain a separate data structure for the indexes which would need to be constantly synced.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜