You need to sign in to do that
Don't have an account?
How to autopopulate the data in VF page
I have made a VF page having some textboxes and buttons. On clicking Get Details button it should come back to the same page with textboxes auto-populated with data.
I have done the following things still it is not auto-populating the page. Please help me in this regard
in VF page
<apex:outputPanel style="width:100px;">
<apex:inputText value="{!data1}" id="id3" style="width:100px;" />
</apex:outputPanel>
in Apex class
PageReference pageRef = Apexpages.currentPage();
String hi = '0.00';
pageRef.getParameters().put('data1', hi);
return pageRef;
the datatype of data1 is decimal
Please tell me how can I approach
This code is working for me
<apex:OutputPanel style="width:100px;"> <apex:inputText value="{!dateOfEntry}" id="id1" style="width:100px;" /> <apex:commandButton value="getDetails" action="{!getDetails}"/> </apex:OutputPanel>
public String dateOfEntry {get; set;} public PageReference getDetails(){ this.dateOfEntry= String.valueof(date.today()); return null; }
All Answers
Set the value of "data1" value in your controller to the value you want to display on the page. setting the parameter does'nt help. The code in your controller might look like this:
public PageReference getDetails(){//do any SOQL/additional processingthis.data1='Autopopulated value';return null;}
This is what I have done again:
in Apex class
public PageReference getDetails(){
this.dateOfEntry= date.today();
return null;
}
and in visualforce I did the following thing
<Table>
<tr><td>
<apex:outputPanel style="width:100px;">
<apex:inputText value="{!dateOfEntry}" id="id1" style="width:100px;" />
</apex:outputPanel>
</td></tr>
</Table>
This is the simplest thing for autopopulation but yet it is not populating.
Please check!!!
This code is working for me
<apex:OutputPanel style="width:100px;"> <apex:inputText value="{!dateOfEntry}" id="id1" style="width:100px;" /> <apex:commandButton value="getDetails" action="{!getDetails}"/> </apex:OutputPanel>
public String dateOfEntry {get; set;} public PageReference getDetails(){ this.dateOfEntry= String.valueof(date.today()); return null; }
This is a very good example. I have similiar kind of doubt.May be i can get help.
I have created a VF page. It has 3 fields. Prodcut Name , Product Family, Product description.
PRODUCT NAME is a lookup field to an object PRODUCT INFORMATION.
whenever Product Name is chosen it should auto populate Product Family and Product Description.
How is this acheived.
try to save product name from a sObject field to a apex class field and then in apex class make a query to get the details for each field.
set the values in the apex class
and keep page reference as null..
there you go...
try the sample code above as well!!!