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
enTran01enTran01 

show and hide textfield within a list

Im trying to show and hide a texfield within specific rows when i click on a commandLink

 

            <apex:pageBlockTable id="productTable" value="{!Names}" var="product" >
            
                    
                                        
                
              <apex:column >
             
                                        
                 <apex:facet name="header">Products</apex:facet>
                 
                
                    <apex:outputText value="{!product.Title__c}" style="text-align:center;font-weight:bold;"></apex:outputText><br/>
                    <apex:outputText value="{!product.Body__c}" style="text-align:center;"></apex:outputText><br/>
                    
                    <apex:form style="margin-left:55px;" id="theCommentForm" rendered="{!showComments}">
                     <apex:image id="yourProfilePic" value="{!SmallPhoto}" height="25px" width="25px" styleClass="commentPic" ></apex:image>
                        <apex:param value="{!product.productId__c}" assignTo="{!Currentproduct}"/> 
                        <apex:repeat value="{!productComments}" var="comments">
                            <apex:outputText value="{!product.Id}"></apex:outputText>
                        </apex:repeat>
                        <apex:inputTextarea value="{!commentBody}" rows="1">
                        </apex:inputTextarea><br/>
                        
                        <apex:outputPanel styleClass="invisiblePanel" id="jsvalues">
                             <apex:outputText value="Value one: {!product.productId__c}" /><br/>
                             <apex:outputText value="Value two: {!commentBody}" /><br />
                             
                      </apex:outputPanel>
                        
                        <apex:commandButton style="margin-left:95px;" action="{!mobileComment}"  value="Comment" rerender="jsvalues,feedTable">
                                <apex:param name="productId" value="{!product.productId__c}" assignTo="{!commentId}"></apex:param>
                        </apex:commandButton>
                    
                    </apex:form>
                    <apex:form >
                        <apex:commandLink style="padding-right:10px;" value="Comment" action="{!showChatterComments}" ></apex:commandLink>
                        
                        <apex:outputText value="{0,date,MM'/'dd'/'yyyy}" >
                         <apex:param value="{!product.createdDate__c}"/>
                        </apex:outputText>
                        
                    </apex:form>
                    
              </apex:column>
              
            
            
            </apex:pageBlockTable>

 I want to be able to click on a specific row and only be able to enter a comment for that specific row. Is there a way i can do that? As of right now im when i click on a specific row all rows show the comments.

Best Answer chosen by Admin (Salesforce Developers) 
imutsavimutsav

Oh I see, I faced the same issue once. I suppose this would help you. 

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_best_practices_accessing_id.htm

 

Let me know if have any question. Don't forget to give Kudos on this post if it helps you.

 

Thanks

Utsav

All Answers

imutsavimutsav

You might need to create Boolean variables on your controller. Eg.
public Boolean jsVal{get;set;}

by default set the value to FALSE.
jsVal = FALSE;

Then on your vf page add
<apex:outputPanel styleClass="invisiblePanel" id="jsvalues" rendered='{!production.jsVal}'>
For the first time when the page will load it would not show this section
however when you want to show this page then add change the value of jsVal=TRUE.

eg. in the below code you are calling method mobileComment(); So now in your controller method mobileComment(), set jsVal=TRUE. Now when the commond link is clicked then the mobileComment() method will be called and it would change the value of jsVal to TRUE and when your VF page will try to rerender the jsvalues section then it would check the value of jsVal(TRUE OR FALSE) to show or not to show.
<apex:commandButton style="margin-left:95px;" action="{!mobileComment}" value="Comment" rerender="jsvalues,feedTable">

Let me know if you have any question. Don't forget to give me kudos if this reply helps you.

Thanks
Utsav



enTran01enTran01

That is what my command link is supposed to do

 

<apex:form rendered="{!showComments}">

<apex:inputTextArea ></apex:inputTextArea>

<apex:/form>

 

<apex:commandLink value="Comment" action="{!showChatterComments}"></apex:commandLink>

 

my showChatterComments changes the value of boolean showComment = TRUE which displays the form and inputTextArea.

 

The problem here is when i click on the commandLink, this displays the inputTextArea fields in all the rows but I only want that single row to display the inputTextArea

imutsavimutsav

I am not sure if I am following you. Let me be more specific. In your code you only have one InputTextArea which is outside the repeat so technically there should be only one inputtextarea.
<apex:repeat value="{!productComments}" var="comments">
<apex:outputText value="{!product.Id}"></apex:outputText>
</apex:repeat>
<apex:inputTextarea value="{!commentBody}" rows="1">
</apex:inputTextarea><br/>
One suggestion is to remove the second <form>  from your code and get the command link into the first


enTran01 wrote:

That is what my command link is supposed to do

 

<apex:form rendered="{!showComments}">

<apex:inputTextArea ></apex:inputTextArea>

<apex:/form>

 

<apex:commandLink value="Comment" action="{!showChatterComments}"></apex:commandLink>

 

my showChatterComments changes the value of boolean showComment = TRUE which displays the form and inputTextArea.

 

The problem here is when i click on the commandLink, this displays the inputTextArea fields in all the rows but I only want that single row to display the inputTextArea



enTran01 wrote:

That is what my command link is supposed to do

 

<apex:form rendered="{!showComments}">

<apex:inputTextArea ></apex:inputTextArea>

<apex:/form>

 

<apex:commandLink value="Comment" action="{!showChatterComments}"></apex:commandLink>

 

my showChatterComments changes the value of boolean showComment = TRUE which displays the form and inputTextArea.

 

The problem here is when i click on the commandLink, this displays the inputTextArea fields in all the rows but I only want that single row to display the inputTextArea




form.

enTran01enTran01

sorry for the confusion. the inputTextArea is inside my table

 

<table>

 

<inputTextArea/>

 

<commandLink/>

</table>

 

When i click the commanlink i want to be able to display that inputTextArea only on the row i click on

imutsavimutsav

Oh I see, I faced the same issue once. I suppose this would help you. 

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_best_practices_accessing_id.htm

 

Let me know if have any question. Don't forget to give Kudos on this post if it helps you.

 

Thanks

Utsav

This was selected as the best answer
enTran01enTran01

Thanks. That made things alot easier.