我正在编写一个visualforce页面,用户必须在其中选择机会列表当用户单击上一个按钮时我实现了分页然后它将再次呈现列表面板并且我在调用中更改了列表的值我的visualforce页面段是
<apex:pageBlockTable value="{!numbers}" var="n" align="center">
<apex:column >
<apex:inputCheckbox value="{!n.checked}"/>
</apex:column>
<apex:column value="{!n.cat.Id}" />
<apex:column value="{!n.cat.Name}" />
<apex:facet name="footer">Showing Page # {!pageNumber} of {!totalPages}</apex:facet>
</apex:pageBlockTable>
我有一个 OpportunityWrapper 类来维护 checkItem:
public class OpportunityWrapper {
public Boolean checked { get; set; }
public Opportunity cat { get; set; }
public OpportunityWrapper(){
cat = new Opportunity();
checked = false;
}
public OpportunityWrapper(Opportunity c){
cat = c;
checked = false;
}
public OpportunityWrapper(Opportunity c, Boolean checked){
cat = c;
this.checked = checked ;
}
}
在自定义控制器中获取 OpportunityWrapper 列表的代码段是
public List<OpportunityWrapper> getNumbers() {
opp = new List<OpportunityWrapper>();
if ( selectedPage != '0' )
counter = list_size*integer.valueOf(selectedPage)-list_size;
//we have to catch query exceptions in case the list is greater than 2000 rows
try {
for ( Opportunity o : [SELECT Id,Name from Opportunity order by name
limit :list_size offset :counter] ) {
if ( !oppId.contains(o.Id) )
opp.add(new OpportunityWrapper(o));
else
opp.add(new OpportunityWrapper(o,true));
}
} catch ( QueryException e ) {
ApexPages.addMessages(e);
return null;
}
return opp;
}
并且当按下前一个按钮时,调用以下方法
public PageReference Previous() {
//user clicked previous button
for ( OpportunityWrapper o : opp ) {
if ( o.checked && oppId.contains(o.cat.Id) )
oppId.add(o.cat.Id);
}
selectedPage = '0';
counter -= list_size;
return null ;
}
以下是自定义类的公共成员
private integer counter = 0; //keeps track of the offset
private integer list_size = 5;
public integer total_size;
List<OpportunityWrapper> opp ;
public List<OpportunityWrapper> oppwrapper = new List<OpportunityWrapper>(); //list of Opportunity wrapper shown in the page
public Set<String> oppId = new Set<String>(); //set for maintaining which Id's are checked
我的目标是当我检查任何机会包装器并转到下一个或上一个列表时,当返回该项目时应该检查但我得到的设置值始终为空但我将选择值列表存储在 Previous() 方法的集合中为什么它的显示设置总是空的??