You need to sign in to do that
Don't have an account?
raju123
Calculate Fields in one page display in Next page
Hi,
Can anybody help me on this Simple Requirement.Please provide me Code
I have 2 Visual force pages.
one page contains A,B Fields
in Second page i want sum of a+b and display it in c field.
Plese Help me in this Requirement.
page1
<apex:page controller="add" >
<apex:form >
A : <apex:inputText id="a" value="{!a}"/>
B : <apex:inputText id="b" value="{!b}"/>
<apex:commandbutton value="Result" action="{!result}" />
</apex:form>
</apex:page>
page 2
<apex:page >
Sum is : {!$CurrentPage.parameters.val}
</apex:page>
class:
public class add{
public integer a {get;set;}
public integer b {get;set;}
public pagereference result(){
pagereference pf = new pagereference('/apex/second2?val='+(a+b));
pf.setredirect(true);
return pf;
}
}
All Answers
If you use the same controller for both pages, you can calculate the result when page A is submitted back and store this on the controller for use in page B.
could you please send me code
i am unable to convert string to integer getting this error "System.NullPointerException: Attempt to de-reference a null object
"
page1
<apex:page controller="add" >
<apex:form >
A : <apex:inputText id="a" value="{!a}"/>
B : <apex:inputText id="b" value="{!b}"/>
<apex:commandbutton value="Result" action="{!result}" />
</apex:form>
</apex:page>
page 2
<apex:page >
Sum is : {!$CurrentPage.parameters.val}
</apex:page>
class:
public class add{
public integer a {get;set;}
public integer b {get;set;}
public pagereference result(){
pagereference pf = new pagereference('/apex/second2?val='+(a+b));
pf.setredirect(true);
return pf;
}
}
Thank you very much Kiran . Thank you
inputfiled is always accept the value there u wont get the value from that object u need to use outputfield
OK.THANK YOU VERY MUCH