0

I need to display a pageblock on click of a command button. I tried re rendering the block however its not displaying the block on clicking command button. Please help.

        <apex:page>                                                              
<apex:form >  
<tr>
 <td style="padding-left: 30px"><b>Portfolio Details</b></td>
 <td></td>                                                  
 <tr>                                                               
 <td colspan="2" width="70%">
 <br/> 
 <table width="35%">
 <tr>
 <td>
 <apex:commandButton action="{!display}" value="Account Summary" reRender="AccountSummarypageBlock" status="status"/>
 </td>                                        
  </tr>
   </td>
                            </tr>
                        </table>
                    <br/>

                    <apex:outputPanel id="AccountSummarypageBlock" >
                    <apex:actionstatus id="status" startText="loading...">
                        <apex:facet name="stop">
                    <apex:pageBlock >
                        <apex:pageBlockSection title="Portfolio Holding Details">
                        <apex:pageBlockSectionItem >
                        <apex:pageBlockTable value="{!listTransaction}" var="trans">
                        <!--<apex:column value="{!trans.Client_ID__c}"/>-->
                        <apex:column value="{!trans.Category__c}"/>
                        <apex:column value="{!trans.Quantity__c}"/>
                        <apex:column value="{!trans.Amount__c}"/>
                        <apex:column value="{!trans.Gain_Loss__c}"/>
                        <apex:column value="{!trans.Yield__c}"/>
                        <!--<apex:column value="{!trans.Product__r.Price__c}"/>-->
                        </apex:pageBlockTable>
                        </apex:pageBlockSectionItem>
                        </apex:pageBlockSection>
                        </apex:pageBlock>
                        </apex:facet>
                        </apex:actionstatus>
                    </apex:outputPanel>                         

                    </td>
                 </tr>
                 </tr>
              </apex:form> 
             </apex:page>            


 My Controller

    public class Transactionrecord{ 
public Transactionrecord(customtable controller) {

   }


 transient  public list<Transaction__c >listTransaction{get;set;}
  public Transactionrecord()
   {
      getTransaction();
   }
public void getTransaction()
   {
    listTransaction=new list<Transaction__c >([select name, Account__c, Amount__c, Category__c, Client_ID__c, CMP__c, Gain_Loss__c, Order_Type__c, Product__c, Product_Code__c, Quantity__c, Transaction_Date__c, Yield__c from Transaction__c]);
   }

     public PageReference display() {
        return null;
     }
 }

1 Answer 1

0

You have some errors in your page construction. You have a table row, but you can't have a table row outside of a table. Try doing this:

<apex:form >
    <table>
        <tr>
            <td >
              <apex:commandButton action="{!display}" value="Account Summary" reRender="AccountSummarypageBlock" status="status"/>
            </td>
            <td>
            <apex:outputPanel id="AccountSummarypageBlock" >
               Account summary stuff...
            </apex:outputPanel>
            </td>
        </tr>
    <table>
</apex:form>

EDIT

Aside from the construction issues, you have a PageReference method on your controller which simply returns. This would be fine normally, but since you have used the transient keyword on your list, when the page reloads, the list data is lost.

Remove that and assuming your page construction is ok, you'll be fine.

Here's an example of the controller (using the account object as I don't have your custom object) without the transient method and with formatting cleaned up:

public class TransactionrecordController {

    public Account[] listTransaction {get; set;}

    public TransactionrecordController() {
        getTransaction();
    }
    public void getTransaction() {
        listTransaction = [SELECT name, Id FROM Account];
    }

    public PageReference display() {
        return null;
    }
}
4
  • Thanks for your response. There is already a <table> in my VF but its not helping me in displaying the pageblock. I have pasted the complete VF code in my question (ignore missing closed td's or tr's if any) Commented Aug 5, 2014 at 7:42
  • There is a <table>, but it itself is inside another <tr> - which is not inside a table. A <tr> cannot exist outside of a <table> Commented Aug 5, 2014 at 10:07
  • Thanks alot....I removed "transient" keyword and it worked like a charm.... Commented Aug 6, 2014 at 5:44
  • No worries - glad it worked for you. Commented Aug 6, 2014 at 7:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .