• VK2009
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

My UI will have 2 input box.Unable to save data into DB..Help me out!! 

Here is my vf code:

 

 

<apex:page controller="testapplicationApex">

  <apex:form >

  <apex:pageblock title="Reena Application" mode="edit">

  <apex:pageblockButtons >

  <apex:commandButton value="Save" action="{!save}"/>

  <apex:commandButton value="Cancel" onclick="top.history.go(-1);return false;"/>

  </apex:pageblockButtons>

  <apex:pageBlockSection title="Test Details" Collapsible="false" columns="1">

  <apex:inputField value="{!test.Name__c}"/>

<apex:inputField value="{!test.TNumber__c}"/>

  </apex:pageBlockSection>

  </apex:pageblock>

  </apex:form>

</apex:page> 

 

Controller code:

public class testapplicationApex {

public test__c test{get;set;}

 

public test__c gettest() {

if(test== null) test= new test__c();

return test;

}

public PageReference save(){

try{

if(test== null) test= new test__c();

insert test;

}

catch(System.DMLexception e){

ApexPages.addmessages(e);

return null;

}

PageReference p = Page.app1;

       p.setRedirect(true);

       return p;

}

 

}

 

what needs to change???  

  • December 17, 2009
  • Like
  • 0

My UI will have 2 input box.Unable to save data into DB..Help me out!! 

Here is my vf code:

 

 

<apex:page controller="testapplicationApex">

  <apex:form >

  <apex:pageblock title="Reena Application" mode="edit">

  <apex:pageblockButtons >

  <apex:commandButton value="Save" action="{!save}"/>

  <apex:commandButton value="Cancel" onclick="top.history.go(-1);return false;"/>

  </apex:pageblockButtons>

  <apex:pageBlockSection title="Test Details" Collapsible="false" columns="1">

  <apex:inputField value="{!test.Name__c}"/>

<apex:inputField value="{!test.TNumber__c}"/>

  </apex:pageBlockSection>

  </apex:pageblock>

  </apex:form>

</apex:page> 

 

Controller code:

public class testapplicationApex {

public test__c test{get;set;}

 

public test__c gettest() {

if(test== null) test= new test__c();

return test;

}

public PageReference save(){

try{

if(test== null) test= new test__c();

insert test;

}

catch(System.DMLexception e){

ApexPages.addmessages(e);

return null;

}

PageReference p = Page.app1;

       p.setRedirect(true);

       return p;

}

 

}

 

what needs to change???  

  • December 17, 2009
  • Like
  • 0

Hi,

 

I want to create a simple UI form  having  some <apex:inputtext > not <apex:inputfield> and save button.

 

 i need to save data using that UI to database.

 

 

what will be code for UI as well controller? how to pass inputtext value to my controller and then saved?

 

Thanks in anticipation of your valuable response.

 

 

Regards,

 Jha

  • December 10, 2009
  • Like
  • 0