[SalesForce] Split textfield value to use as values for apex:repeat

I am trying to figure out how to use the value of a custom field (textfield or textarea) as the values for an apex:repeat in a visualforce page.

For example, I have a custom field, issues__c, that has the following value:

Issue1, Issue2, Issue3

Alternately the values could be stored with newlines as:


I want pass each of these entries as the value for an apex:repeat, which in turn would create html links to each of the above values stored in the text field.

I assume that I will need to write a controller to accomplish this, but my understanding of writing controller extensions is very limited at the moment.

The bits I am missing are:
How do I pass the value of issues__c to the controller?
How do I return each line or entry in issues__c back to the apex:repeat in the VF page?

Or is there an easier way?

Best Answer

Here is an example of how I would do it. You will have to adapt it for your use.

VF Page:

<apex:page standardController="[OBJECT API NAME]" extensions="[OBJECTNAME]_ExtensionController">

  <apex:repeat value="{!splitString}" var="s">
      I am repeating. {!s} is the current value. <br />



public with sharing class [OBJECTNAME]_ExtensionController {

    public List<string> splitString {get;set;}

    public AccountExtensionController(ApexPages.StandardController controller)
        controller.addFields(new List<string>{'Issues__c'});
        [OBJECT API NAME] record = ([OBJECT API NAME])controller.getRecord();

        splitString = new List<string>();

            splitString = record.Issues__c.split(',');


Good luck!

Luis Luciani

Related Topic