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
Vigneshwaran LoganathanVigneshwaran Loganathan 

Need help

public class good
{
Public string logid;
public good(ApexPages.StandardController controller)
{
    system.debug('********'+logid) // After submitting I need the same value Yes here, But it Shows NULL
}
Public page reference submit() //
{
Logid = 'Yes'; 
}
}


My problem is when i press submit button, Logid variable is assigned to Yes. But when it goes to Constructor it is Changed to Null, which affect my further codes.
How to get the same value in constructor? am i wrong anywhere? 
Anoop yadavAnoop yadav
Hi,
Constructor runs only on the page load.
praveen murugesanpraveen murugesan
Hi Vignesh,

As per your code it will print null only. coz, while page loading contructor will get invoked and the value will be null. because u r assiging in one method. so after calling that method if use that variable in other method method means value will be ther in that string variable.

public class good
{
Public string logid;
public good(ApexPages.StandardController controller)
{
    system.debug('********'+logid) // After submitting I need the same value Yes here, But it Shows NULL
}
Public page reference submit() //
{
Logid = 'Yes'; 
 system.debug('********'+logid) // Now the value will not be NULL
}
Public page reference submit1() //
{
 system.debug('********'+logid) // Now the value will not be NULL
}
}

Thanks.
 
StephenKennyStephenKenny
If you are reloading the entrie page again, the constructor wil lbe invoked as per the comments above. I suspect for what you are trying to achive, perhaps you do not need to reload the entire page, maybe just rerender a specific portion of it? If you can explain what you are trying to do and why you are reloading the page then perhaps we can help you with an alternitive solution.