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
Gaurav RajGaurav Raj 

Help with the following issue

The following is the Confirmation page in my app. 

<apex:page standardController="Product__c" extensions="myBookedController" tabStyle="Product__c" sidebar="false" showHeader="false">
<body background="{!$Resource.bg}">
<center><u><font face = "comic sans ms" color="blue" size="6"><b>Welcome to Online Shopping</b></font></u></center><br></br><br></br>


<apex:form >
<apex:pageBlock >
<p align="center">
<br></br><br></br>

</p>
<p align="center">

<apex:image url="{!$Resource.s3}" width="100" height="100" rendered="{!Product__c.Model__c =='Galaxy S3'}" />
<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/m2.jpg')}" width="50" height="50" rendered="{!Product__c.Model__c =='Xperia-U'}" />
<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/m3.jpg')}" width="50" height="50" rendered="{!Product__c.Model__c =='Defy'}" />

<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/t1.jpg')}" width="150" height="150" rendered="{!Product__c.Model__c =='LED'}" />
<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/t2.jpg')}" width="150" height="150" rendered="{!Product__c.Model__c =='LCD'}" />
<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/t3.jpg')}" width="150" height="150" rendered="{!Product__c.Model__c =='HD'}" />

<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/r1.jpg')}" width="150" height="150" rendered="{!Product__c.Model__c =='Cool'}" />
<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/r2.jpg')}" width="150" height="150" rendered="{!Product__c.Model__c =='Eon'}" />
<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/r3.jpg')}" width="150" height="150" rendered="{!Product__c.Model__c =='Master'}" />


<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/c2.jpg')}" width="150" height="150" rendered="{!Product__c.Model__c =='Powershot'}" />
<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/c1.jpg')}" width="150" height="150" rendered="{!Product__c.Model__c =='SLR'}" />
<apex:image url="{!URLFOR($Resource.myshopping, 'my_img/c3.jpg')}" width="50" height="50" rendered="{!Product__c.Model__c =='Lumix'}" />


</p>
<p align="center">
<b>You are going to view the details of Product No:</b> <apex:outputField value="{!product.Name}"/>
</p>

<br></br>
<p align="center">

<br/><b>Company:</b> <apex:outputField value="{!product.Company__c}"/>
<br/><b>Model:</b> <apex:outputField value="{!product.Model__c}"/>
<br/><b>Color:</b> <apex:outputField value="{!product.Color__c}"/>
<br/><b>Price:</b> <apex:outputField value="{!product.Price__c}"/><br></br><br></br>

<apex:commandButton action="{!saveandredirect}" value="Confirm" style="color:white;background:red;" />


</p>

</apex:pageBlock>
</apex:form>
</body>
</apex:page>

 

<-----------------------------------Controller---------------------------------------->

public with sharing class myBookedController {
Product__c prod;


public myBookedController(ApexPages.StandardController controller) {
String id = ((Product__c)controller.getRecord()).id;
this.prod = [Select p.Name, p.Company__c, p.Model__c,p.Color__c,p.Price__c from Product__c p where p.id=:id];
}

Booking__c booking = new Booking__c();

public Product__c getProduct() {
return prod;
}

 

Public Pagereference saveandredirect(){

booking.Company__c = prod.Company__c;
booking.Model__c = prod.Model__c;
booking.Color__c = prod.Color__c;
booking.Price__c = prod.Price__c;

upsert booking;


Pagereference p = new Pagereference('/apex/loginpage');
p.setredirect(true);

return p;

}
}

I wish to fetch these details onto another page named Final which is the last page in my app. But whenever i'm trying to fetch id of the product for which booking is done, it throws some error. In between the confirmation page and the final page i've a loginpage.

TrinayTrinay

Hi Gaurav,

 

      You need to get your previous page saved value in to the new page. I hope the following sample will helpful to you.

 

Final page:

----------------

<apex:page standardController="Product__c" extensions="myBookedController">

  <apex:form>

     <apex:pageBlock>

        <apex:outputField value="{!product.Company__c}"/>
         <apex:outputField value="{!product.Model__c}"/>
         <apex:outputField value="{!product.Color__c}"/>
         <apex:outputField value="{!product.Price__c}"/>

     <apex:pageBlock>

  </apex:form>

</apex:page>

 

extension class:  save&redirect method:

------------------------------------------------------

Public Pagereference saveandredirect()

      Pagereference p = new Pagereference('/apex/loginpage');
      p.setredirect(true);

      return p;

     .prod = [Select p.Name, p.Company__c, p.Model__c,p.Color__c,p.Price__c from Product__c p where p.id=: id];

   

      // In the where conditon check the id with your previous page inserted id.

 }

 

and also refer the wizard in salesforce :

http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_wizard.htm 

 

If this post is helpful to your solution, kindly mark this as the solution