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
Mack DsozaMack Dsoza 

solve my confusion

Please explain me that whenever I write Bean class to initialize values of field so at that time what happens...

Suppose I created one custom object & have written get & set property for that object in Bean class i.e. separately apex class named ObjectBean.

Now the confusion is that, Whether this get & set property takes values directly from Page or it takes values from controller.

& what happens in set & get property, as generally says, set sets the value & get returns value.

But as i know that set execute first & then get return that value but entire problem is from where Bean accept these values ?

 

can bean set their value from Database ?

If YES then please tell me how it do ?

 

Please reply me soon for this...

Bcoz my confusion creates many different views....

 

 

 

Jake GmerekJake Gmerek

The object can get its value whichever way you want.  You can have something passed from the page, or from the context record, or something completely seperate from the database.  Here is an example:

 

Public Class Bean(

 

 

Public someObj beanOBj {get; set;} //create default getter and setter

 

Public Bean () {  //constructor

 

     //get value from database

     beanOBj = [select someInt from someObj where someParameter = 1 LIMIT 1];

 

     //get value from the record in context

    beanObj = [select someFields from someObj where id =: apexPages.currentPage().getParameters().get('id') LIMIT 1];

}

}

 

To get a value from your page, just put something like this on the page:

 

<apex:inputText value = "{!beanObj}">

 

This should call your set method and set the Obj to the proper value, but please note that in the class beanObj was declared as an Sobject and would not work as declared, you would have to declare a string or integer to get a value from an inputText field.