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
Sivasankari MuthuSivasankari Muthu 

Reg:Doubt in page reference

Hi All,
In my scenario ,
Select page(input)-select industry and product
User-added image

Select page-click image
User-added image

Detail page- it shows relevant information about the image
User-added image

but in my case the detail page could not shows any informations.it couldn't receive any input from previous page(Select page).
My Code is:
Vfp-1(select page)
 
<apex:commandLink target="_blank" action="{!hello1}">
<apex:image value="{!account.photo__c}" height="150" width="200" id="test"   /> 
    
    </apex:commandLink>


My Controller page:
public PageReference  hello1(){
       PageReference pagr= new PageReference('/apex/custrefdetail');   
String searchStr1=ApexPages.currentPage().getParameters().get('searchStr'); //input - industry
     String productName1=ApexPages.currentPage().getParameters().get('productName');//input - product

accprd = [SELECT Detail__c,Product__c from  accproducts__c where Product__c =:productName1  and account__c in (select ID from Account where industry=:searchStr1)];
      System.debug(productName1);//product
      System.debug(searchStr1);//industry
              pagr.setRedirect(false); 
             return pagr;
	}
product and industry values shows as null. I dont know how to pass the detail value in visualforce page2.

if anybody knows please tell me.

Thanks,
M. Sivasankari.



 
James LoghryJames Loghry
It's hard to know exactly what's going on with the little information provided.  It would help if you could post the entire VF page and entire controller.  However, what I suspect is going on is the following:

You're not setting the values prior to displaying them in Visualforce.  It looks like you're setting productName1, searchString1 or any other fields prior to displaying them.

It could also be that your secondary or "custrefdetail" page is not reading the correct parameters in.

I would add some system.debug lines to your controller to see if your variables are getting set properly and go from there.
Sivasankari MuthuSivasankari Muthu
Hi James Loghry,
Thanks for your reply.

My full code

My controller
Public with sharing class sfdctest{
 Public List<Account> acc{get;set;} 
 Public List<accproducts__c> accprd{get;set;}
 public String imageURL{get;set;}
 Public String searchStr{get;set;} 
 public string productName{get;set;}


public List<selectoption> getIndustrynames()
{           
    list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues(); 
     options.add(new SelectOption('select','Select Industry'));     
    for (Schema.PicklistEntry a : values) 
    {                  
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    } 
  
    return options; 
}


public List<SelectOption> getItems() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('selectprd','Select Product')); 
    for(product2 c : [select ID, name  from product2  where ID IN( select Product__c from accproducts__c )]){
        options.add(new SelectOption(c.ID, c.name));
    }  
    return options;
}
    
 public  sfdctest()
  {
    acc = New List<Account>();
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
        
 public  sfdctest(ApexPages.StandardController controller)
 {}
	 
  Public void soslDemo_method(){
      System.debug(searchStr);
   if(searchStr.length() > 1 && searchStr != 'select'){
       acc = [SELECT Name,image__c,photo__c,Description,website from Account  where industry=:searchStr and Id in (select account__c from accproducts__c where Product__c = :productName )  ];
        System.debug('product');
       if(acc.size() == 0) {
           apexPages.addmessage(new apexpages.message(apexpages.severity.WARNING, 'Sorry, data not found'));
            return;
          }
       }

   else{
       acc = [SELECT Name,image__c,photo__c,Description,website from Account  where Id in (select account__c from accproducts__c )  ];
      
   }
  }
  
 public PageReference  hello1(){
       PageReference pagr= new PageReference('/apex/custrefdetail');   
		String searchStr1=ApexPages.currentPage().getParameters().get('searchStr');
     String productName1=ApexPages.currentPage().getParameters().get('productName');

accprd = [SELECT Detail__c from  accproducts__c where Product__c =:productName1  and account__c in (select ID from Account where industry=:searchStr1)];
      System.debug(productName1);
      System.debug(searchStr1);
        pagr.setRedirect(false); 
     
        return pagr;
	}
}




vfp-1
<apex:page sidebar="false" showheader="false" controller="sfdctest" tabStyle="account">
<apex:form id="ref">
<apex:pageMessages id="pId"/>
    <apex:image url="{!imageURL}">   
    </apex:image>
      <apex:pageBlock title="Select a Industry & Product" >
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <apex:selectList value="{!searchStr}" size="1"> 
                    <apex:selectOptions value="{!Industrynames}" />
          </apex:selectList>    
    		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <apex:selectList size="1" value="{!productName}">
            <apex:selectOptions value="{!items}"/>
	</apex:selectList> 
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<apex:outputPanel id="myRerender">

         <apex:commandButton value="Submit" action="{!soslDemo_method}"  ReRender="ref,pgId,pId"  />
            </apex:outputPanel>

      </apex:pageBlock>
    
    <apex:pageBlock title="Customer details" id="pgId" rendered="true">
        
       <apex:repeat value="{!acc}" var="account">
     
             
<style>
    body {margin:50px;}
   
div.img {

    -webkit-align-items: baseline;
    align-items:baseline;
     margin: 10px;
    border: 1px solid #ccc;
    float: left;
    width: 220px;
   
    margin-bottom:25px;
    box:0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
}	
  div.img:hover {
    
    border: 1px solid #777;
   
}

div.img img {
    max-width:100%;
    width: 100%;
    height: 150px;
    
}

    
div.desc {
    font-family:"arial";
    background-color : lightgrey;
    padding: 10px 20px;
   
    height: 50px;
    text-align: justify;
}   
 
    
   </style>      
 <body>
     

<div class="img" >
<!--<a target="_blank" href="{! $Page.custrefdetail}">
      <img src="{!account.photo__c}"  width="200" height="150"/> </a>-->    
  <apex:commandLink target="_blank" action="{!hello1}">
            <apex:image value="{!account.photo__c}" height="150" width="200" id="test"   /> 
    
    </apex:commandLink>
    <div class="desc"><h1>
    
        {!account.Name}
        </h1>
        <p>
        {!account.Description}
        </p>
        </div>
   
</div>
    
     </body>
        </apex:repeat>
    </apex:pageBlock>
</apex:form>
</apex:page>
vfp-2
<apex:page sidebar="false" showHeader="false" standardController="accproducts__c" extensions="sfdctest" >
<apex:form >
  <apex:pageBlock >
			{!accproducts__c.Detail__c}
        </apex:pageBlock>
     </apex:form>
</apex:page>