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
Force.comForce.com 

How to set a param value of command button equal to the User Text input ?

Hi,

 

In visualforce, I am iterating through a wrapper class and for each iteration, a textbox is displayed. My code snippet is:

 

<apex:repeat value="{!comList}" var="com">
<b>{!com.comment.name} : </b><br/>
<apex:inputTextarea id="textbox" value="{!com.reply}" /><br/>

<apex:commandButton value="Reply" action="{!replytoComment}" reRender="repeatFrm">
    <apex:param name="commentId" value="{!com.comment.id}" assignTo="{!commentId}" />
    <apex:param name="replyText" assignTo="{!replyText}" value="{!com.reply}"/>
</apex:commandButton>

</apex:repeat>

 

I want to send the user input which is entered in the inputText Box to the controller with the help of  "param" called replyText. But when I am clicking on "Reply" command button, replyText param is showing null value.

 

replyText is of getter setter type.

 

If somebody had faced such a situation, please help.

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Force.comForce.com

Hi Charan,

 

Thanks for quick response. I resolved the problem by using <apex:variable> and passing the index number in the controller.

I modified my visualforce code to

<apex:variable value="{!1}" var="rowNum"/>
         

           <!-- Iterating through the list called comList for displaying all existing comments -->
       <apex:repeat value="{!comList}" var="com">
                <apex:inputTextarea id="textbox1" value="{!com.reply}" /><br/>
           
                <apex:commandButton value="Reply" action="{!replytoComment}"  reRender="repeatFrm">
                    <apex:param name="commentId" value="{!rowNum}" assignTo="{!commentId}" />
                </apex:commandButton>
          

                <!-- Incrementing rowNum by 1 on each iteration -->
                <apex:variable var="rowNum" value="{!rowNum + 1}"/>
           

          </apex:repeat>

 

Thanks

All Answers

cvuyyurucvuyyuru

You could better call a Action fucntion onClick of command button and send these values.

 

Give a try!!

Force.comForce.com

Hi Charan,

 

Thanks for quick response. I resolved the problem by using <apex:variable> and passing the index number in the controller.

I modified my visualforce code to

<apex:variable value="{!1}" var="rowNum"/>
         

           <!-- Iterating through the list called comList for displaying all existing comments -->
       <apex:repeat value="{!comList}" var="com">
                <apex:inputTextarea id="textbox1" value="{!com.reply}" /><br/>
           
                <apex:commandButton value="Reply" action="{!replytoComment}"  reRender="repeatFrm">
                    <apex:param name="commentId" value="{!rowNum}" assignTo="{!commentId}" />
                </apex:commandButton>
          

                <!-- Incrementing rowNum by 1 on each iteration -->
                <apex:variable var="rowNum" value="{!rowNum + 1}"/>
           

          </apex:repeat>

 

Thanks

This was selected as the best answer