You need to sign in to do that
Don't have an account?
mritz
This code displays info correctly on vf pg1 ,
But when i click on the link to go on pg2 i cant see the ID stored in string myStr.
tried using pageReference but that was wroking on "Apex commandButton" but i want "link" and the url was also not changing.
I want that the url changes and the values also reflect on this page.
(I havent used pageReference in my Code)
display values from one vf page to another having common controller
public class getAcnt{ public string AcNm{get;set;} //get value frm vf page public string AcPhn{get;set;} //get value frm vf page public string myStr{get;set;} // string having ID of a particular Account public list<Account> Usr{get;set;} //holds values of an account retreived from database ................ public void search(){ ................ } } vf page 1 <apex:page controller="getAcnt" sidebar="false"> <apex:form > <p>Enter Account Details.</p> <p>Name:<apex:inputText value="{!AcNm}"/></p> <p>Phone:<apex:inputText value="{!AcPhn}"/></p> <p><apex:commandButton value="Search" action="{!search}"/> <b> <a href="AcntPg">Go2Account</a></b> ........................ ........................ <apex:pageBlock > <apex:pageblockTable value="{!Usr}" var="my"> <apex:column value="{!my.id}"/> <apex:column value="{!my.name}"/> <apex:column value="{!myStr}"/> </apex:pageblockTable </apex:pageBlock> </apex:form> vf pg2 <apex:page controller="getAcnt"> <apex:form > <apex:outputText value="ID: {!myStr}"></apex:outputText> </apex:form> </apex:page>
This code displays info correctly on vf pg1 ,
But when i click on the link to go on pg2 i cant see the ID stored in string myStr.
tried using pageReference but that was wroking on "Apex commandButton" but i want "link" and the url was also not changing.
I want that the url changes and the values also reflect on this page.
(I havent used pageReference in my Code)
The reason may be you are doing operations in the constructor.
When new page of same controller is loaded it will run the constructor.
Just remove your logic from constructor if any and use the below code in second page to call the method if you need to call any method on page load.
Let me know if you have any question
Please mark this as solution if this solves your problem, So that if anyone has this issue this can help.
Nor do i need to call any method.
I want the ID stored in myStr to be visible in pg2 when itc accessed from pg1.
You can simply pass this Id in as URL parameter of other page when you are redirecting and then in controller you can get the id from URL parameter and then you can proceed further...
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
I dont want to pass values in URL.
Then you can save that id in custom setting and in another page you can get the id from there..
You can refer to this blog for command link.
http://blog.jeffdouglas.com/2010/03/03/passing-parameters-with-a-commandlink/
Please mark this as solution if this solves your problem, So that if anyone has this issue this can help.