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
Shwetal DesaiShwetal Desai 

Problem in passing data to apex class used as extension

Hi,
 
The problem I m facing must be solved by so many developers.
 
I m trying to set public variable value in apex class from VF page.
VF Page uses StandardCotroller and that apex class as an extension
 
but that public variable not being set...  :womansad:
 
I need proper guidence....  :womanindifferent:
 
here is the source code:  VF Page
 
<apex:inputText id="clientid" value="{!clientId}"/>

Apex Class
 
public class PointOfSale
{
    public ID clientId;

    public ID getclientId()
    {
        return clientId;
    }
    public void setclientId (ID txt)
    {
        clientId = txt;
    }

    private final POS__c pos;
   
    public PointOfSale (ApexPages.StandardController controller)
    {
        this.pos = (POS__c)controller.getRecord();
    }
}
 
Is it becoz m using this class as extension?
 
Any Idea/Sugession/ help ???
 
 
Thanks
 

 
Ron HessRon Hess
your page must have a page tag, and form tags i don't see those in your page .

does it work if you declare the variable as a string instead of an ID

you have no debug statements to verify the value?

how do you know it's not working?
visulaforcevisulaforce
change the datatype of clientId from ID to String.
User@SVFUser@SVF

HI Shwetal,

 

The get, set methods should automatically fetch the client id entered in your vf page.

 

Try the below code and check if it works:

 

public class PointOfSale{
    public String clientId {get; set;}
    private final POS__c pos;

    public PointOfSale (ApexPages.StandardController controller){
        this.pos = (POS__c)controller.getRecord();
    }
}