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
Nupur ModiNupur Modi 

Issue with rerendering of a visual force component

Hi

I have a visual force component which is inside of an output panel which is placed in a div.

<div id="divContainer">
     <outputpanel id="opComponent">
          <component ..../>
    </outputpanel>
</div>

There are multiple records on the page and on click of the "Edit" of an individual record, the component is opened (divContainer style set to display:block).

In the first scenario, the user clicks on "Edit" of one record and the component is displayed.

There is a standard required field validation in the component and a "Save" and "Close" button. If someone clicks the "Save" button without entering the required value, the validation executes. Then if someone clicks "Close" then the divContainer style is set to display:none. All is fine uptil this point.

Now someone clicks on "Edit" of some other record, the component is displayed but the error from the previous record remains as it is. In short the component is not getting rerendered.
bob_buzzardbob_buzzard
If clicking the edit button causes a postback, the rerender won't succeed as you haven't dealt with the validation error.  If you want to allow the edit button to be clicked regardless of the component state, you can encapsulate it in an actionregion, or set the immediate attribute to true.  I would go for the former, as it means you can still post back other fields if you so desire.
Nupur ModiNupur Modi
Immediate = true for "Edit" wont work as we have a kind of an Auto Save feature whereby clicking of "Edit" of a record, saves the currently open record (if any) and then opens the new record.
Nupur ModiNupur Modi
Also, basically, when someone clicks "Close" of the component, I want to treat it as Cancel and let the error go away. Is it possible?
bob_buzzardbob_buzzard
Yes - same answer - either immediate=true or put it inside an action region.