I want to create records from individual inputs in a table. Individual inputs are made of Users or Contacts participating to a given meeting. A Meeting__c object is the parent of User and Contacts stored in a Participant__c object. Users and Contacts are distinguished by Record Types: Internal -> Users ; External -> Contacts. Users are stored in a Lookup field User__c ; Contacts are stored in a Lookup field Contact__c. Ths user has the possibility to select the type of participant in a list box (linked to the RecordTypeID field).
Goal: render User__c or Contact__c depending on the value of the RecordTypeID selected by the user.
For that, I use an <apex:actionSupport>
tag to trigger a controller method that handles the Record Type change and sets the Render variable.
Problem: I could write a page that works like expected. But as soon as I have a field required on the page, the actionSupport call fails. The Debug log shows "You must enter a value".
Diagnostic: in any case, the call goes into the checking of required fields being filled or not before doing anything else.
What I've done:
- Enter a value in the required field: no error is raised in this case. But I can't require users to input all the required field PRIOR to entering any value in the participants list (5 fields in the final form)
- Use immediate="true" in actionSupport
- Use actionFunction instead of actionSupport
- Surrounding the
<apex:pageBlockTable>
tag with<apex:actionRegion>
tags
2 caused a different problem. 3 and 4 couldn't resolve the issue.
My question is: is there a way to call directly the controller method without triggering the required checking ?
Thank you for you help
Visualforce page:
<apex:form >
<apex:pageBlock >
<apex:inputField value="{!Visit.Visit_date__c}" required="false" />
<apex:pageBlockTable value="{!Participants}" var="u" title="Participants list" id="ParticipantsList">
<apex:column headerValue="Participant Type" >
<apex:inputField value="{!u.participant.RecordTypeId}" >
<apex:actionSupport event="onchange" action="{!onRecordTypeChange}" reRender="ParticipantsList" >
<apex:param name="LineIndex" value="{!u.index}" assignTo="{!CurrentRow}" />
</apex:actionSupport>
</apex:inputField>
</apex:column>
<apex:column headerValue="Participant" >
<apex:inputField value="{!u.participant.User__c}" rendered="{!u.isInternal}" />
<apex:inputField value="{!u.participant.Contact__c}" rendered="{!NOT(u.isInternal)}" />
</apex:column>
<apex:column headerValue="Index" >
<apex:outputText value="{!u.index}" />
</apex:column>
<apex:column headerValue="isInternal" >
<apex:outputText value="{!u.isInternal}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>