function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vlotarevvlotarev 

How to ignore collection changes during page navigation?

I am using custom list controller to display my list data. Each record have <apex:inputField> column, values of that are eligible within current page only and should be just ignored (cleared) during page navigation. How is it possible to do that? I am always getting the error message like: "Modified rows exist in the records collection!" (even trying to clear field values in the controller).

 

Is it possible to define a kind of transient field in sObject?

bob_buzzardbob_buzzard

If you don't want the collection to change, use OutputIField instead - that way the users will be presented with the data in a sensible format, but won't be able to alter it.

vlotarevvlotarev

The problem is that I WANT user to enter data but I'll handle it manually when special button is added. This is a kind of adding product to shopping cart: you see list of products with inputs where you can enter number of products to add. You enter number and press button "Add to Shopping Cart".

But if you enter some quantities and then decided to navigate to the next page these quantities shoudl be just ignored.

bob_buzzardbob_buzzard

So if I understand correctly, there is a button that the user can click to discard current changes and move to the next page?

 

That being the case, set the immediate attribute to "true" for the commandbutton component - that skips validation and viewstate update.

vlotarevvlotarev

This is exactly what I need. It works, thank you!

bob_buzzardbob_buzzard

You can mark it as a solution if you like ;)

vlotarevvlotarev

Well, this seems to be a partial solution ... It works fine if the form was never submitted before. But if it was submitted once (say "Add to basket" button was pressed) than the list page contains changed objects (I guess that this list is cached in StandardSetController). Any other navigation fails since changed objects are required to be saved. Is it possible to clear or ignore changes made on the page objects?