I have a number in an input text that I want to pass on to the controller:

    <div class="divTable">
        <div class="divRow">
            <div class="cellOne">
                <label>Number of participants</label>
            <div class="cellTwo">
                <apex:inputText value="{!integerNumberParticipants}"/>
                <apex:commandButton value="Add Row" action="{!addRows}">
                    <apex:param name="addCount" value="{!integerNumberParticipants}" assignTo="{!addCount}"/>

and the function where it gets processed:

public void addRows(){
    for (Integer idx=0; idx<addCount; idx++){
            wrappers.add(new ParticipantsWrapper(nextIdent++, selectedRecordId));

The code functions when I pass on value="{!1}", and I have integerNumberParticipants declared as a { get; set; } and initiated in the controller. So what is the problem here?

Thank you for your help!

1 Answer 1


You don't need that <apex:param> tag at all. The <apex:inputText> tag automatically binds it to a variable in the controller.

<apex:inputText value="{!addCount}"/>
<apex:commandButton value="Add Row" action="{!addRows}"/>

As soon as the button is hit, the entire form is submitted to the server, including the field. The value of the field is bound to the addCount variable in the controller for you to process.

Also, use this guy to allow for automatically handling the data conversion from string to integer.

<apex:input type="number" value="{!addCount}"/>

Otherwise, you'll have to assign the value to a string in the controller and use server side code (integer.valueOf(StringToConvertToInteger)).

  • Thank you very much, that works really nicely! Just to add, I had to put docType="html-5.0" into apex:page to make it work. Apr 26, 2017 at 16:34
  • That makes sense if you're using apex:input as that is an HTML 5 tag. Glad it works for you :)
    – gNerb
    Apr 26, 2017 at 19:53

You must log in to answer this question.

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