function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AkiraDioAkiraDio 

controller and apex:pageBlockTable

I apologize for my English. Let me explain the problem. I want to create a controller that does not use a database and work with it using the apex: pageBlockTable. For example: There are variables:

decimal a = 10;

decimal b = 20;

decimal c = 30;

I want to make a table using the apex: pageBlockTable.:

-------------------------

|variable one | 10 |

------------------------

| variable two | 20 |

------------------------

| variable three | 30 |

------------------------

How make?

tukmoltukmol

you define properties (getters) for your decimal a, b, c like this:

 

public class DecimalController {

   public DecimalController() {

      this.decimal_a = 10;

      this.decimal_b = 20;

      this.decimal_c = 30;

   }

 

   public Decimal decimal_a {

        get ; set';

   }

 

  public Decimal decimal_b {

     get; set;

  }

 

  public Decimal decima_c {

    get; set;

  }

}

 

then you access if in apex page like this:

-------------------------

|variable one | {! decimal_a} |

------------------------

| variable two | {! decimal_b} |

------------------------

| variable three | {! decimal_c} |

------------------------

AkiraDioAkiraDio

 

<apex:page controller="DecimalController" showHeader="false" sidebar="false">
<apex:pageBlock>
    <apex:pageBlockSection>
        <apex:form>    
            <apex:pageBlockTable value="*{!DecimalController}" var="pitem">
            </apex:pageBlockTable>
        </apex:form>
    </apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

 

*What to write here?

 

 

tukmoltukmol

if that's the case then you could do something like this:

 

sample page:

<apex:page controller="DecimalController">
    <apex:pageMessages escape="false"></apex:pageMessages> 
    <apex:form >
        <apex:pageBlock title="Decimals">
            <apex:pageBlockTable value="{! index}" var="i">
                <apex:column headerValue="Decimals" value="Decimal_{! i}"/>
                <apex:column headerValue="Values" value="{! values[i]}"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

corresponding controller:

public with sharing class DecimalController {
	public DecimalController () {
		this.values = new Decimal[]{20,30,40,50,60,100};
		this.index = new Integer[] {};		
		
                //populate the iterator
Integer i = 0; for (Decimal dec:this.values) { this.index.add(i); i++; } } public Decimal[] values { public get; private set; } public Integer[] index { public get; private set; } }

 

AkiraDioAkiraDio

tukmol, thank you very much!