I have an inputText field in which I want to display a String list.The list diplay horizontally like 'test1', 'test2', 'test3' .I want it vertically like


The purpose of displaying the list vertically is I want to catch the selected value from that input text field. For Now i just stuck while displaying list vertically

public class accountController {
 public List<String> alphabet {get;set;}
    public accountController (){
      alphabet = new list<String>();

Vf page

<apex:page Controller="accountController">
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputText  value="{!alphabet}"/>

1 Answer 1


Text fields do not allow multiple rows of text.

If you're trying to get multiple input fields, use a repeat tag somehow:

<apex:pageBlockSection title="My Content Section" columns="2">
  <apex:repeat items="{!alphabet}" var="item">
      <apex:outputLabel value="Enter Value" for="input"/>
      <apex:inputText id="input" value="{!item}"/>

Or if you want multiple lines of text in a single input:

<apex:inputTextArea value="{!alphabet}" />

However, the latter needs normal line breaks, not a list:

public String alphabet { get; set; }
public accountController() {
  alphabet = 'test1\ntest2\ntest3';
  // Or String.join(new String[] { 'test1','test2','test3' }, '\n');
  • it worked when I used apex:inputTextArea but how to select multiple values?
    – Fawad azam
    Commented Jul 9, 2022 at 17:10
  • @Fawadazam Are you looking for a multi-select picklist, then?
    – sfdcfox
    Commented Jul 9, 2022 at 17:19
  • can we only select multiple values multi-select picklist?? or in apex:inputTextArea ?
    – Fawad azam
    Commented Jul 9, 2022 at 18:10
  • @Fawadazam Hmm, let's back up a second. What exactly are you trying to achieve? Read about the X-Y Problem for an explanation of what I'm trying to get.
    – sfdcfox
    Commented Jul 9, 2022 at 19:12

You must log in to answer this question.

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