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
TenaTena 

Pass Value from to pageBlockTable Row to Controller

I load data into a PageBlockTable in edit mode.  I want to allow the users to edit the Quantity and Unit Price.  When either of these values are changed I need my Total Price to change.  Currently I am trying to get the Value from the Quantity field and display it the "Rerender Example" section just to see if the value is being passed and it always comes up blank.  I am using actionSupport.  I know I am missing something that connects these together but I can't figure out what from all the examples I have found on line.

 

1)  How do I pass the value of a row to the controller to modify another value on the same row?

 

VF page code:

<apex:page Controller="dataListCon1" id="thePage">

<apex:form ID="Selling">
<apex:pageBlock title="Mass Edit" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
              <apex:pageBlockTable value="{!ypItems}" var="yp" ID="theTable" rowClasses="odd,even" styleClass="tableClass">
            <apex:facet name="caption"></apex:facet>
                <apex:column >
                      <apex:facet name="header">Name</apex:facet>
                      <apex:outputText value="{!yp.name}"/>
                </apex:column>
                <apex:column >
                      <apex:facet name="header">Product Name</apex:facet>
                      <apex:outputText value="{!yp.yptrimble__Product__r.Name}"/>
                </apex:column>
                <apex:column >
                        <apex:facet name="header">Quantity</apex:facet>
                        <apex:inputField ID="Quantity" value="{!yp.yptrimble__Quantity__c}" required="true" >
                          <apex:param name="para" value="{!yp.yptrimble__Quantity__c}" assignTo="{!para}"/>
                          <apex:actionSupport event="onchange" rerender="qvalue" status="refreshstatus"/>
                        </apex:inputField>
                </apex:column>
                <apex:column >
                        <apex:facet name="header">Unit Price</apex:facet>
                        <apex:inputField ID="UnitPrice" value="{!yp.yptrimble__Unit_Price__c}" required="true" />
                </apex:column>
                <apex:column >
                        <apex:facet name="header">Total Price</apex:facet>
                        <apex:outputText ID="TotalPrice" value="{!yp.yptrimble__Total_Price__c}"/>
                </apex:column>
                <apex:column >
                        <apex:facet name="header">Service Date</apex:facet>
                        <apex:outputText value="{!yp.yptrimble__Service_Date__c}"/>
                </apex:column>
         </apex:pageBlockTable>
       </apex:pageBlock>
          <apex:pageBlock >
       <apex:sectionHeader title="Rerender Example"/>      
           <apex:actionStatus id="refreshstatus" startstyle="color:green;" startText="Refreshing...."></apex:actionStatus>  
           <apex:outputpanel id="qvalue">
               <apex:outputtext value="{!para}"/>
           </apex:outputpanel>  
   </apex:pageBlock>
   </apex:form>
</apex:page>

 

Controller Code:

public class dataListCon1 {

    public String para{
        get;
        
        set{
           para= value;
        
        }
    }

    public dataListCon1() {

    }
        List<yptrimble__Quote_Line_Item__c> ypItems;
        
        public List<yptrimble__Quote_Line_Item__c> getYpitems()
        {
            if(ypItems== null) ypItems= [select name,id,YPTRIMBLE__QUANTITY__C,YPTRIMBLE__SERVICE_DATE__C,
                    YPTRIMBLE__TOTAL_PRICE__C,YPTRIMBLE__UNIT_PRICE__C, YPTRIMBLE__PRODUCT__C, yptrimble__Product__r.Name
                    from yptrimble__Quote_Line_Item__c
                    where YPTRIMBLE__QUOTE__C =:ApexPages.currentPage().getParameters().get('Id')];
            return ypItems;
        }
        
        public PageReference save()
        {
          Update ypItems;
          PageReference pageRef = new PageReference('https://cs17.salesforce.com/' + ApexPages.currentPage().getParameters().get('Id'));
          return pageRef;
        }
      
        public PageReference cancel()
     {
            PageReference pageRef = new PageReference('https://cs17.salesforce.com/' + ApexPages.currentPage().getParameters().get('Id'));
            return pageRef;
    }
}