<apex:selectRadio>
繰り返し内にあるを使用して visualforce ページをセットアップすると、選択した値をコントローラーに戻すことができないようです。繰り返しの外に移動すると、正常に動作します。何か案は?
コントローラ:
public with sharing class COPE_TestsExt {
public id tid {get;set;}
public boolean showTestSelect {get;set;}
public list<COPE_Tests__c> tests {get;set;}
public list<COPE_questions__c> questions {get;set;}
public list<List<SelectOption>> options {get;set;}
public COPE_results__c results {get;set;}
public list<string> rid {get;set;}
public COPE_TestsExt(ApexPages.StandardController controller) {
results = new COPE_results__c();
showTestSelect = true;
tests = [select id, name from COPE_Tests__c];
tid = null;
}
public PageReference setTid(){
integer ridCount = 0;
showTestSelect = false;
tid = ApexPages.CurrentPage().getParameters().get('tid');
results.cope_test__c = tid;
questions = [select id, name, question_body__c, (select id, name, option_body__c from COPE_options__r order by name ASC) from COPE_questions__c ];
options = new List<List<SelectOption>>();
for(COPE_Questions__C q : questions){
ridCount++;
List<SelectOption> l = new List<SelectOption>();
for(COPE_options__c op : q.COPE_options__r){
l.add(new SelectOption(string.valueof(op.id), op.option_body__c));
}
options.add(l);
}
rid = new string[ridCount];
integer tempCount = 0;
while(tempCount < ridCount){
rid[tempCount] = '';
tempCount++;
}
return null;
}
public pagereference submit(){
return null;
}
}
ページ:
<apex:page showHeader="false" standardController="COPE_Tests__c" extensions="COPE_TestsExt" >
<apex:form id="theForm" >
<apex:pageblock >
<apex:outputPanel id="testSelect">
<apex:pageBlockTable value="{!tests}" var="t" rendered="{!showTestSelect}" >
<apex:column headerValue="Please select a test:" ><apex:commandLink reRender="testSelect,testPage" action="{!setTID}" >{!t.name}<apex:param name="tid" value="{!t.id}"/></apex:commandLink></apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
<apex:outputPanel id="testPage">
<apex:outputText rendered="{!not(showTestSelect)}">
<apex:pageBlockSection collapsible="false" title="User Information" columns="1">
<apex:inputField label="What is your full name?" value="{!results.name}" required="false"/>
<apex:inputField label="What is your email address?" value="{!results.Email__c}" required="false"/>
<apex:inputField label="What is your OE Tracker #?" value="{!results.OE_Tracker__c}" required="false"/>
</apex:pageBlockSection>
<apex:pageBlockSection collapsible="false" title="Test Questions" columns="1">
<apex:variable var="count" value="{!0}" />
<apex:repeat value="{!questions}" var="q">
{!count+1}. {!q.Question_Body__c}
<apex:repeat first="{!count}" rows="1" value="{!options}" var="op">
<apex:selectRadio value="{!rid[count]}" >
<apex:selectOptions value="{!op}" />
</apex:selectRadio>
</apex:repeat>
<apex:variable var="count" value="{!count+1}"/>
</apex:repeat>
<apex:commandButton reRender="check" action="{!submit}" value="Submit"/>
</apex:pageBlockSection>
</apex:outputtext>
</apex:outputPanel>
<apex:outputPanel id="check">
{!rid[0]}
</apex:outputPanel>
</apex:pageblock>
</apex:form>
</apex:page>