I have two VFpages
In 1st VF Page:
I have a 3 input field and I am entering data
I have a button(Standard/custom).
When I click on this button, It should redirect to another page(2nd VF Page) with the same fields with output fields along with the data I have entered
<apex:page standardController="Contact" > <apex:form > <script> function OpenVfpageConfrim(){ var confirmFlag =confirm('Do you want to open a new visualforce page?'); if(confirmFlag == true) window.open('/apex/anothervfpage'); }</script> <apex:pageBlock title="Edit Contact"> <apex:pageBlockSection columns="1"> <apex:inputField value="{!contact.FirstName}"/> <apex:inputField value="{!contact.LastName}"/> <apex:inputField value="{!contact.Birthdate}"/> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Open vf Page" onclick="OpenVfpageConfrim()"/> </apex:pageBlockButtons> </apex:pageBlock>
In 2nd VF page
- It should display the same 1st VF Page with output fields
There should be a button to SAVE This data into the database
<apex:page Controller="ContactControllerr" > <apex:form > <apex:pageBlock title="Edit Contact"> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!samepage}" var="c"> <apex:column headerValue="First Name"> <apex:outputField value="{!c.Firstname}"/> </apex:column> <apex:column headerValue="Last Name"> <apex:outputField value="{!c.Lastname}"/> </apex:column> <apex:column headerValue="Birthdate"> <apex:outputField value="{!c.Birthdate}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock>
public with sharing class ContactControllerr { public Contact c { get; set; } public List<Contact> samepage { get; set; } public ContactControllerr(){ c=new Contact(); } public PageReference save() { insert c; samepage= [select id,FirstName,LastName,Email,Birthdate from Contact where id=:c.id]; return null; } }
Data is not coming and saving into the database?
Can anyone help me to solve this issue?