而不是創造如上爲什麼我們不能創建CheckBox組件類似下面
public Boolean chkBox{
get{
if(myMap.get(myList[i]) == true){
return true;
}
return false;
}
set;
在Visualforce頁面,我們可以如下編寫頂點組成的
<apex:outputLabel value="Check Box Label"/> <apex:inputCheckBox value="{!chkBox}"><apex:actionSupport event="onclick" rerender="TheBlock" status="showCredentialing" />
的錯誤也可能是由於由於VF錯誤沒有行號,所以在視覺力頁面上出現的其他輸出字段ERROR。
我試圖在Visualforce頁面中實現一個獨立的Component.Apex.inputCheckbox。請嘗試下面的代碼
控制器
public class testcontroller {
public Component.Apex.inputCheckbox chkBox { get; set; }
public Component.Apex.inputCheckbox dyCheckbox;
public PageReference chkBox3() {
this.chkBox = new Component.Apex.inputCheckbox();
System.debug('Here is Test');
this.chkBox.value = true;
return null;
}
public String chkBox2 { get; set; }
public testcontroller(){
this.chkBox2 = 'false';
}
public Component.Apex.inputCheckbox getInputCheckbox() {
Component.Apex.inputCheckbox dyCheckbox = new Component.Apex.inputCheckbox();
dyCheckbox.value = 'true';
return dyCheckbox;
}
}
VISUALFORCE PAGE
<apex:page controller="testcontroller">
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Page: test
<apex:form >
<apex:outputLabel value="Check Box Label"/>
<apex:inputCheckBox value="{!chkBox2}"/>
<apex:dynamicComponent componentValue="{!InputCheckbox}" />
<apex:commandButton value="sd" action="{!chkBox3}" title="asdf"/>
</apex:form>
<!-- End Default Content REMOVE THIS -->
</apex:page>
我用一個頂點組成部分,因爲我無法顯示我的複選框我直接需要他們在VF的方式:我需要在表格中顯示可變數量的複選框(標題+ 2行「n」複選框)。我確信錯誤來自「chkBox.selected = true;」 :當這一行被評論時,我沒有更多的錯誤。 – Plato
Hi Plato,我試圖在Visualforce頁面中實現一個獨立的Component.Apex.inputCheckbox。請嘗試下面的代碼 –
非常感謝!我會嘗試一下你的代碼:這似乎是解決方案的途徑。 – Plato