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 ID's

PageReference gotoConfirmation()
{
PageReference result=Page.Cofirmation;
result.getParameters().put(id, Product__c.id);
result.setRedirect(true);

return result;
}

 this code asks to define id, wen i do so throws an error in put(id, Product__c.id).

 

wen i use the following

<apex:commandButton  value="Print" onClick="window.location='Confirmation?id={!Product__c.id}'; return false;" />

the output is a new window in the same, how to keep it in a single screen?

kamlesh_chauhankamlesh_chauhan

Gaurav,

 

It looks like that Product__c is a lookup or masterdetail field.

 

Field name itself represent the ID so no need to add additional ".id" in your code.

 

try this.

 

PageReference gotoConfirmation()
{
PageReference result=Page.Cofirmation;
result.getParameters().put(id, Product__c);
result.setRedirect(true);

return result;
}

 

 

Regards,

Kamlesh Chauhan, (Founder & CTO, LogicRain Technologies)

kamlesh@logicrain.com || http://www.logicrain.com || LinkedIn

 

Answers/Suggestions are my own.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

bob_buzzardbob_buzzard

Its a bit difficult to tell without knowing what Product__c is declared as - can you post that code?

its_rajits_raj

<apex:page standardController="Product__c" extensions="myProductController" 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 value="{!$Resource.s3}" /><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 value="BUY NOW" onClick="window.location='Confirmation?id={!Product__c.id}'; return false;" />

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

public with sharing class myProductController {

    public myProductController(ApexPages.standardController controller) {
    
    String id = ((Product__c)controller.getRecord()).id;
       this.product  = [Select p.Name, p.Company__c, p.Model__c,p.Color__c,p.Price__c from Product__c p where p.id=:id];

    }
        public PageReference view() {
        return null;

    }

 Product__c product;
 Booking__c booking = new Booking__c();

    
    public Product__c getProduct() {
        return product;
    } I want the same information on two pages named Confirmation and Final. The Confirmation page comes just after this page but the final page comes after the loginpage 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>

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'm working on my finalpage, fetching these values in the final page is getting a bit complex.

bob_buzzardbob_buzzard

So the error is that your variable is named 'product' rather than 'Product__c', which is its type.

 

Therefore you should use:

 

PageReference gotoConfirmation()
{
  PageReference result=Page.Cofirmation;
  result.getParameters().put(id, product.id);
  result.setRedirect(true);
  return result;
}