• Jigar Shah
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 6
    Replies

I am trying to perform some processing when the user clicks on a button after performing multiple selections in list box. Once the button is clicked the selections are divided into a batch of 25 elements each and stored in Map and the action poller is enabled.

The poller picks up the records and processes one batch at a time and returns the results which are being stored in a List<CustomType>. The List<CustomType> is bound to a <apex:dataTable> to display the output.

 

The Problem:

In case of multiple batches each batch is processed and the List<MyCustomType> is populated correctly with elements from all batches. However when the table is finally rendered, values from only the last batch that was processed are displayed within the table.

 

The VF code is as follows:

<apex:page controller="MyCtl" action="{!getValuesToSelect}">
<apex:form>
<apex:outputPanel id="pnlInput">
<apex:pageBlock>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!createBatches}" value="Display"/>
</apex:pageBlockButtons>

<apex:actionPoller id="poller" action="{!processBatch}" enabled=" {!IsPollerEnabled}" rerender="pnlDisplayAllFieldDetails" interval="5" status="tableStatus"/>

</apex:form>

<apex:outputPanel id="pnlDisplayAllFieldDetails">
<apex:dataTable value="{!MyCustomList}" var="ft" rendered="{!IF(IsFieldTableVisible == True, True, False)}">

<apex:column headerValue="FIELD 1">
<apex:outputText value="{!ft.Field1}"/>
</apex:column>

<apex:column headerValue="FIELD 2">
<apex:outputText value="{!ft.Field2}"/>
</apex:column>
</apex:dataTable>
</apex:outputPanel>

</apex:page>

 

The Apex Controller code is as follows:

 

public class MyCtl{

public List<MyCustomType> MyCustomList = new List<MyCustomType>();

public MyCtl()
{}

public class MyCustomType{

public MyCustomType(String pField1, String pField2)
{
Field1 = pField1;
Field2 = pField2;
}

public String Field1{get; set;}
public String Field2{get; set;}
}

public List<MyCustomType> getMyCustomList()
{ return MyCustomList; }

public void processBatches()
{
/* perform some processing */
MyCustomList.add(new MyCustomType(strField1, strField2));
}

public void createBatches()
{
/*
Iterate over the selection
Create batch of 25 elements each of List<String>
Store the list in Map<Integer, List<String>> BatchMap = new Map<Integer, List<String>>
*/
}

}//End

 

  Can someone please suggest what can be possibly wrong in my code !!

 

 

I am trying to perform some processing when the user clicks on a button after performing multiple selections in list box. Once the button is clicked the selections are divided into a batch of 25 elements each and stored in Map and the action poller is enabled.

The poller picks up the records and processes one batch at a time and returns the results which are being stored in a List<CustomType>. The List<CustomType> is bound to a <apex:dataTable> to display the output.

 

The Problem:

In case of multiple batches each batch is processed and the List<MyCustomType> is populated correctly with elements from all batches. However when the table is finally rendered, values from only the last batch that was processed are displayed within the table.

 

The VF code is as follows:

<apex:page controller="MyCtl" action="{!getValuesToSelect}">
<apex:form>
<apex:outputPanel id="pnlInput">
<apex:pageBlock>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!createBatches}" value="Display"/>
</apex:pageBlockButtons>

<apex:actionPoller id="poller" action="{!processBatch}" enabled=" {!IsPollerEnabled}" rerender="pnlDisplayAllFieldDetails" interval="5" status="tableStatus"/>

</apex:form>

<apex:outputPanel id="pnlDisplayAllFieldDetails">
<apex:dataTable value="{!MyCustomList}" var="ft" rendered="{!IF(IsFieldTableVisible == True, True, False)}">

<apex:column headerValue="FIELD 1">
<apex:outputText value="{!ft.Field1}"/>
</apex:column>

<apex:column headerValue="FIELD 2">
<apex:outputText value="{!ft.Field2}"/>
</apex:column>
</apex:dataTable>
</apex:outputPanel>

</apex:page>

 

The Apex Controller code is as follows:

 

public class MyCtl{

public List<MyCustomType> MyCustomList = new List<MyCustomType>();

public MyCtl()
{}

public class MyCustomType{

public MyCustomType(String pField1, String pField2)
{
Field1 = pField1;
Field2 = pField2;
}

public String Field1{get; set;}
public String Field2{get; set;}
}

public List<MyCustomType> getMyCustomList()
{ return MyCustomList; }

public void processBatches()
{
/* perform some processing */
MyCustomList.add(new MyCustomType(strField1, strField2));
}

public void createBatches()
{
/*
Iterate over the selection
Create batch of 25 elements each of List<String>
Store the list in Map<Integer, List<String>> BatchMap = new Map<Integer, List<String>>
*/
}

}//End

 

  Can someone please suggest what can be possibly wrong in my code !!

 

 

how to populate input fields when the lookup is selected?