0

I am building a VF page that uses a repeat to build a number of rows based on how many values are in a picklist. What I would like to do is when a checkbox is checked, rerender the Notes textArea for that row as required. I have tried suggestions found on Google and was not able to make it work

<apex:repeat value="{!rows}" var="field" >
    <apex:outputLabel value="{!field.Business}" />
    <apex:inputCheckbox value="{!field.selected}">
        <apex:actionSupport event="onChange" rerender="notesPanel"/>
    </apex:inputCheckbox>
    <apex:inputField value="{!field.OwnerId}" label="Send To" required="false"/>
    <apex:outputPanel id="notesPanel">
        <apex:inputTextArea value="{!field.Notes}" required="{!field.selected}"/>
    </apex:outputPanel>
</apex:repeat>

I have tried: required="{!field.selected}, event="onChange", event="onchange", event="OnChange"

2

I just dealt with a similar issue. It may be one of several things. Most likely, it's an error with the data that cannot be surfaced because you aren't refreshing an <apex:pageMessages>. To solve this problem, I'd suggest doing the following:

  1. Add a pageMessages element that gets refreshed, as well (this would help diagnose your problem).
  2. Wrap your checkbox in an <apex:actionRegion>.
  3. Add action={!refresh} to the <apex:actionSupport> tag, and a method that looks like:
    public PageReference refresh() {
      PageReference ref = ApexPages.currentPage();
      ref.setRedirect(true);
      return null;
    }
  1. Possibly add immediate="true", also.
  • You know what? I was missing the <apex:pageMessages> I was expecting the red bar to appear showing the field is required and the errors to be on the field level rather than the page. Now I just need to figure out how to get the errors down to the field level instead. Thanks! – Mike Jul 22 '15 at 20:48
  • 1
    @Mike - Check out Part 1 and Part 2, maybe it will help you: bobbuzzard.blogspot.com/2011/04/… - Part 2: bobbuzzard.blogspot.com/2011/04/… – Eric Jul 22 '15 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.