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
MohanaGopalMohanaGopal 

Use of Setter method

Hi...
 
       I want to pass inputtext field value to controller.
 
In controller based on this value I have to do some calculation..
 
I know settermethod is used for it..  I couldnt understand the example which u gave in user guide..
 
Any one send some sample code for
   ------how to pass input text value to controller 
   ------In controller how to recieve this value.. Based on this value I have to do some calculation 
   ------the result is displayed in another inputtext in UI.....
How to achive it.
 
 
 
 
hisrinuhisrinu
Hi,

For  <apex:inputText id="two" value="{!stat}"/>   this u need to write following get and set methods.

    public void setstat(String s4){st=s4;}
    public String getstat(){return st;}

Now the value of the text box will be avaliable in st.
dchasmandchasman
You might also want to take a look at switching to using the new native property syntax support in Apex Code - it really cleans things up and makes dealing with getters/setters much much nicer.
MohanaGopalMohanaGopal

Hi..

 Sri

My question is how to pass inputtext value as another inputtext -- input

Ex: A is inputtext this value is get from database onchange of another inputfield.

I have to use set method for A

A value is get and calculated and assigned to another input text B.. How is it possible....

I could nt understand ur code..

Sorry.. I am new to VF, Can u explain ur code and give solution for my questions



Message Edited by MohanaGopal on 08-22-2008 04:54 AM
hisrinuhisrinu
Hi,

    String stA,stB;
    public void setA(String s4){stA=s4;}
    public String getA(){return stA;}

    public void setB(stA){stB=stA;}
    public String getB(){return stB;}
  

I don't know whether it will work or not, but it is my blind guess.
MohanaGopalMohanaGopal
Thanks for ur reply..
 
But in my situation getA method return one object (that is query result)..
 
So I couldnt get that corresponding value in getB..
 
Any other way..
hisrinuhisrinu
Hi Gopal,

Please post your code, so that I can get back to you.
Vivek ViswanathVivek Viswanath
Hi,

If I understand you right you want to take input from one field and calculate in your controller and display the calculated value to set it ot another input box please correct me if I am wrong, this is fairly simple you need an action support on your inputbox where your value changes this calls an action on your controller and re-renders the input box that you want to display the value in once the calculation is complete.


Code:
<apex:inputField id="onlineRevenue" value="xyz">
                       <apex:actionSupport event="onchange" action="{!yourCalculateFunction}" rerender="QTY" />
</apex:inputField>           

 <apex:outputPanel id="QTY" layout="inline">
                        <apex:inputtext id="newRevenueTotal" value="{!variableAfterCalculations}"></apex:outputtext>           
</apex:outputpanel>

 


if you dont re-render your change to the variable will not be shown.

Regards

Vivek Viswanathan |Technical Analyst | vviswanathan@Tier1CRM.com |Tier1CRM Inc.|T: 416.932-4625|C: 416.455-8019 |www.Tier1CRM.com


Message Edited by Vivek Viswanath on 08-22-2008 12:09 PM
MohanaGopalMohanaGopal
Thanks for ur reply Vivek..
 
 
 I am new to VF.. Can u send Apex class coding..
 
Its very useful for me to understand ur VF coding..
 
Thank u..
Vivek ViswanathVivek Viswanath
If you could post your controller or/and class  I can help you with it. I am not sure as to what class you want from me?

You can also find documentation at

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

regards

Vivek


Message Edited by Vivek Viswanath on 08-25-2008 09:51 AM