7

We have a Visualforce page that uses standard pageBlockSections and inputFields. This page has a lot of dynamic rerendering of pageBlockSections based on fields. Up until now, all of the fields have been optional. Now we have a request to essentially make every field required.

Running some tests, it seems to work out that requiring the field on the VF page when it isn't rendered ignores the validation (which is good), however our bigger problem is that when we answer a question that should trigger a rerendering of the form, it requires ALL of our required fields to be filled out before the page will submit to the rerender.

Are there any ways around this, i.e. a setting to disable required until the form is legitimately being submitted. I've tossed around the idea of validating via Javascript (not something I want to do, there's easily hundreds of fields of all different types). Additionally, it is possible we could try to refactor our rerendering to be a bit more targeted in terms of what gets rerendered, but I'm not sure that would completely solve our situation. We currently rerender the entire pageBlock because there are so many pageBlockSections/fields that we didn't want to overlook one with targetted rerendering.

1 Answer 1

9

When you fire an action via a button or command link it submits the entire form, meaning all the required fields in the form are checked, so you're right in saying that targetted re-rendering would not solve your problem. The key is to split up your fields into logical groups, whereby when firing a specific action only the fields you want are included.

You can use <apex:actionRegion> tags to split up the form into various groups of fields with their associated actions—when you fire an action in a region only the fields in that same region are sent.

Althernatively, you are now allowed to have multiple <apex:form>s on the page, and this has the same effect with the added bonus of transferring way less information as it supports multiple view states.

Finally, another option is to use the immeditate="true" attribute and value on your action buttons/links, but this can cause other difficulties so I'd try the above first.

1
  • 1
    While not the "magic pill" solution I was hoping for, I think these look to be the only options. Sounds like some page refactoring is in my future. Commented Nov 21, 2012 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .