1

I have created Discount Integer variable in apex class and use it as a inputText in visualforce page and at the same time i need to display that entered inputText

here is my visualforce code :

<apex:pageBlockTable>
<apex:pageBlockSection id="relatedInfo">
<apex:pageBlockTable value="{!PW.PBEList}" var="PBE" rendered="{!PW.PBEList.size > 0}">
    <apex:column headerValue="Part Number">
        <apex:outputField value="{!PBE.Part_Number__c}"/>
    </apex:column>
    <apex:column headerValue="Description">
        <apex:outputField value="{!PBE.Description__c}"/>
    </apex:column>
    <apex:column headerValue="List Price">
        <apex:outputField value="{!PBE.UnitPrice}"/>
    </apex:column>
    <apex:column headerValue="Discount">
        <apex:inputText value="{!Discount}">
            <apex:actionSupport event="onchange" rerender="saleprice" action="{!Calculation}" immediate="false"/>
        </apex:inputText>
    </apex:column>
    <apex:column headerValue="Sale Price" id="saleprice">
        <apex:inputText value="{!SalePrice}"/>
    </apex:column>
    <apex:column headerValue="Quantity">
        <apex:inputText value="{!Quantity}">
            <apex:actionSupport event="onchange" rerender="exPrice" action="{!Calculation}"/>
        </apex:inputText>
    </apex:column>
    <apex:column headerValue="Extended Price" id="exPrice">
        <apex:inputText value="{!ExtendedPrice}"/>
    </apex:column>
    <apex:column headerValue="Cost">
        <apex:outputField value="{!PBE.Cost__c}"/>
    </apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection columns="4" id="Grouptotal">
    <apex:outputLabel />
    <apex:outputLabel style="display:block;width:590px;"/>
    <apex:outputLabel style="font-weight:bold;" value="Group total Discount :  " />
    <apex:inputText value="{!Discount}"/>
    <apex:outputLabel />
    <apex:outputLabel />
    <apex:outputLabel style="font-weight:bold;" value="Group total price :  " />
    <apex:inputText value="{!Total}"/>
    <apex:outputLabel />
    <apex:outputLabel />
    <apex:outputLabel style="font-weight:bold;" value="Group total cost :  " />
    <apex:inputText value="{!SubTotal}"/>
    <apex:outputLabel />
    <apex:outputLabel />
    <apex:outputLabel style="font-weight:bold;" value="Group Margin :  " />
    <apex:inputText value="{!GroupTotal}" />
</apex:pageBlockSection>
</apex:pageBlockTable>
2

I think the good solution is to add a second action support on your inputText to update the second input text for each key pressed. Like this:

<apex:inputText id="firstInputDiscount" value="{!Discount}">
      <apex:actionSupport event="onchange" rerender="saleprice" action="{!Calculation}" immediate="false"/>
      <apex:actionSupport event="onkeyup" rerender="secondInputDiscount" />
</apex:inputText>

And change the second input text like this:

<apex:inputText id="secondInputDiscount" value="{!Discount}">
     <apex:actionSupport event="onkeyup" rerender="firstInputDiscount" />
</apex:inputText>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.