+ Start a Discussion
sfdc18sfdc18 

How to store values from visualforce page to an object?

How can i store textfield values from visualforce page to an object?

asish1989asish1989

Hi

   please follow thease step ...

   1-make a field of type Text in a object 

    2-make a visual force page 

    3-bind that value with field in controller

   4-insert object ;

   

<apex:page controller = "testController">
   <apex:form>
     <apex:pageBlock>
       <apex:inputText value= "{!sometext}" />
     </apex:pageBlock>
    </apex:form>
<apex:page>

public class testController {
   public String sometext{get;set;}
   public YourObject__c yourobj{get;set;}
   public testController () {
   } 
   public PageReference toSave() {
      yourobj.yourField__c = sometext;
      insert yourobj;
      return null;
  }
}
     

 Did this post answers your questions,if so please mark it solved..

 

thanks

asish

  

its_rajits_raj

Hi Ashish,

 

I need to display values from differnet visualforcepages onto a single another visualforcepage. Likewise, username from Loginpage, and product specification from some other ProductDetail Page.

asish1989asish1989

Hi

  Then pass the value as parameter from one page to another ,

   you may follow this code ...

public PageReference forPdf() {
          
             // all the parameters is to dispalyed in Invoice..
              String name=contact.Name;
              String firstName=contact.FirstName;
    PageReference newpage= new PageReference('/apex/nextPage?Id='+contactId+'&name='+name+'&firstName='+firstName);
return null

}

In the next page
    public class nextPageController {
     public Id Id{get;set;}
     public String name{get;set;}
     public nextPageController () {
         firstName = ApexPages.currentPage().getParameters().get('firstName');
         Id Id = ApexPages.currentPage().getParameters().get('Id');
      name = = ApexPages.currentPage().getParameters().get('name');
}

}

 Did this post answers your problem If so please mark it solved

 

Thanks

asish

its_rajits_raj

Hi Ashish,

 

I need to fetch values from 2 or more visualforce pages onto a single page. I m not storing all the data of those visualforcepages in any object. I m storing the data in this last page to an object.
Is this possible, to fetch data from different visualforce pages whose values are not stored anywhere i.e. in any object.
As i know it might not be possible to fetch a data without storing it. But if there's someway, do help.
Thank You.

asish1989asish1989

Hi

   Then there is one solution .You have to use wrapper class for your requirement .

 

 

 

Thanks

asish