解決策が見つからないような問題のヘッドスクラッチャーが1つあります。
魔女でVFページをやっています。他のフィールドにユーザーが挿入した数字に応じてフィールドを表示したいです。たとえば、ユーザーがフィールド「A」に2を挿入すると、同じページに2つのフィールドが表示されます。
// Page
<apex:page standardController="Assure__c" extensions="insEnfant"
standardStylesheets="true">
<apex:sectionHeader title="Ajouter un assuré"
subtitle="{!$User.FirstName}" help="/help/doc/user_ed.jsp?loc=help"></apex:sectionHeader>
<apex:form>
<apex:pageBlock title="Nouveau assuré" id="thePageBlock" mode="edit">
<apex:pageBlockButtons>
<apex:commandButton action="{!save}" value="Enregistrer"></apex:commandButton>
<apex:commandButton action="{!cancel}" value=" Annuler "></apex:commandButton>
</apex:pageBlockButtons>
<apex:pageBlockSection title="General Information" columns="2">
<apex:pageBlockSection id="liste1" columns="1">
<apex:inputField value="{!Assure__c.Civilite__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Nom__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Prenom__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Nom_de_jeune_fille__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Date_de_naissance__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Lieu_de_naissance__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Pays_de_naissance__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Nationalit__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Situation_Familiale__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Numero_de_securit_sociale__c}"></apex:inputField>
</apex:pageBlockSection>
<apex:pageBlockSection id="liste2" columns="1">
<apex:inputField value="{!Assure__c.Telephone_bureau__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Telephone_personnel__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Portable__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Adresse_e_mail__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Adresse__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Code_postal__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Ville__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Pays__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Pays__c}"></apex:inputField>
<apex:pageBlockSectionItem>
<apex:outputLabel value="Nombre d'enfants" />
<apex:outputPanel>
<apex:inputField value="{!Assure__c.Nombre_enfants__c}">
<apex:actionSupport event="onchange" rerender="thePageBlock"
status="statut1" />
</apex:inputField>
<apex:actionStatus startText="Application..." id="statut1" />
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="{!$ObjectType.Assure__c.fields.Etudes_superieures__c.label}" />
<apex:outputPanel>
<apex:inputField value="{!Assure__c.Etudes_superieures__c}">
<apex:actionSupport event="onchange" rerender="thePageBlock"
status="statut2" />
</apex:inputField>
<apex:actionStatus startText="Application..." id="statut2" />
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel value="Service militaire" />
<apex:outputPanel>
<apex:inputField value="{!Assure__c.Service_militaire__c}">
<apex:actionSupport event="onchange" rerender="thePageBlock"
status="statut3" />
</apex:inputField>
<apex:actionStatus startText="Application..." id="statut3" />
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlockSection>
<apex:pageBlockSection
title="Entrez le niveau d'études supérieures atteint" columns="1"
rendered="{!(Assure__c.Etudes_superieures__c)}">
<apex:inputField value="{!Assure__c.Type_etudes__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Diplome_obtenu__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Nombre_annees__c}"></apex:inputField>
</apex:pageBlockSection>
<apex:pageBlockSection
title="Entrez les informations concernant le service militaire"
columns="1" rendered="{!(Assure__c.Service_militaire__c)}">
<apex:inputField value="{!Assure__c.Type_de_service__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Date_de_debut__c}"></apex:inputField>
<apex:inputField value="{!Assure__c.Date_de_fin__c}"></apex:inputField>
</apex:pageBlockSection>
<apex:pageBlockSection title="Liste des enfants" columns="1"
rendered="{!IF(Assure__c.Nombre_enfants__c > 0, true, false)}">
<apex:pageBlockTable value="{!accts}" var="a" id="table">
<apex:facet name="footer">
<apex:commandLink value="Ajouter" action="{!addRow}"
rerender="table,error" />
</apex:facet>
<apex:column headerValue="Nom">
<apex:inputField value="{!a.Name}" />
</apex:column>
<apex:column headerValue="Prénom">
<apex:inputField value="{!a.Prenom__c}" />
</apex:column>
<apex:column headerValue="Né le">
<apex:inputField value="{!a.Date_de_naissance__c}" />
</apex:column>
<apex:column headerValue="Lieu de naissance">
<apex:inputField value="{!a.Lieu_de_naissance__c}" />
</apex:column>
<apex:column headerValue="Situation">
<apex:inputField value="{!a.Situation__c }" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
// Controller
public class insEnfant{
public List<Enfants__c> accts {get; set;}
public insererEnfant(){
accts = new List<Enfants__c>();
accts.add(new Enfants__c());
}
public void addrow(){
accts.add(new Enfants__c());
}
public PageReference save(){
insert accts;
PageReference home = new PageReference('/home/home.jsp');
home.setRedirect(true);
return home;
}
}
誰か助けてくれませんか?
ありがとう !!