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
sk kumarsk kumar 

there are 3 nodes n1,n2,n3 are there..if i select n1 it shows aproduct node tab cpu..and again if i select cpu it will show cpu details in a popup..so any one plz help me out..urgent

<apex:page standardController="Account" extensions="productconfig5">
    <apex:form >
       <apex:pageblock >
          <apex:panelGrid columns="5">
             Select Node &nbsp;<apex:selectList size="1" value="{!SelectedNode}">
               <apex:selectOptions value="{!SelectedNodes}"/>
                  <apex:actionSupport event="onchange" reRender="a"/>
                     </apex:selectList>   
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select Product &nbsp;<apex:selectList size="1" value="{!product}" id="a">
                            <apex:selectOptions value="{!products}"/>
                         <apex:actionSupport event="onclick" reRender="Details"/>
                       </apex:selectList>
                     </apex:panelGrid>
                   <apex:outputPanel id="Details">
                <apex:outputText value="The Product you Selected is {!product} " rendered="{!product != null}" />
             </apex:outputPanel>
          </apex:pageblock>
      </apex:form>
</apex:page>

class--

public with sharing class productconfig5
{
      Public String SelectedNode{get;set;}
      Public String Product{get;set;}
      Public String SelectedProduct{get;set;}
      public productconfig5(ApexPages.StandardController controller)
         {
       
        }
  
    public List<SelectOption> getSelectedNodes()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None',' None'));       
        options.add(new SelectOption('N1','N1'));
        options.add(new SelectOption('N2','N2'));
        options.add(new SelectOption('N3','N3'));       
        return options;
    }
    public List<SelectOption> getProducts()
    {
        List<SelectOption> options =new List<SelectOption>();
        if(SelectedNode == 'N1')
        {      
            options.add(new SelectOption('CPU','CPU'));
            options.add(new SelectOption('MOUSE','MOUSE'));
        }
        else if(SelectedNode == 'N2')
        {      
            options.add(new SelectOption('N/W','N/W'));
          
        }
        else if(SelectedNode == 'N3')
        {      
            options.add(new SelectOption('MONITOR','MONITOR'));
          
        }
        else
        {
            options.add(new SelectOption('None', 'None '));
        }     
        return options;
   }      
}
Virendra ChouhanVirendra Chouhan
Hi sk kumar,

This all products are standard product?


sk kumarsk kumar
hi virendra no thsese r custom product..wht my requirement is if i select cpu it show the cpu deatails like(cpu model p4 2.6) in popup besides the cpu node..simolteniously for n/w(ip adress, mac adress) & montor(24 inch screen) like that only.. so plz bro help me out urgent..send me the code or logic..if u modify my  code i will greatful to u..thnx in advance..
Virendra ChouhanVirendra Chouhan
Hi SK

I do it but with Standard Product Object . So, change it with you requirment (i.e. change the sObject with you custom).

VF page -

<apex:page standardController="Account" extensions="productconfig1">
   <apex:form >
    
     <apex:pageblock >
          <apex:panelGrid columns="5">
             Select Node &nbsp;<apex:selectList size="1" value="{!SelectedNode}">
                    <apex:selectOptions value="{!SelectedNodes}"/>
                    <apex:actionSupport event="onchange" reRender="a"/>
                </apex:selectList>    
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select Product &nbsp;<apex:selectList size="1" value="{!product}" id="a">
                    <apex:selectOptions value="{!products}"/>
                    <apex:actionSupport event="onclick" reRender="Details" action="{!productDetails}"/>
                </apex:selectList>
        </apex:panelGrid>
        <apex:outputPanel id="Details">
          <apex:detail subject="{!pList.id}"/>
        </apex:outputPanel>
     </apex:pageblock>
    
    </apex:form>

</apex:page>

Extension :

public with sharing class productconfig1
{
      Public String SelectedNode{get;set;}
      Public String Product{get;set;}
      Public String SelectedProduct{get;set;}
      public product2 pList {get; set;}
      
        public productconfig1(ApexPages.StandardController controller){
        
        }
   
    
    public List<SelectOption> getSelectedNodes()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None','--- None ---'));        
        options.add(new SelectOption('N1','N1'));
        options.add(new SelectOption('N2','N2'));
        options.add(new SelectOption('N3','N3'));        
        return options;
    } 
    
    public List<SelectOption> getProducts()
    {
        List<SelectOption> options = new List<SelectOption>();
        if(SelectedNode == 'N1')
        {       
            options.add(new SelectOption('CPU','CPU'));
            options.add(new SelectOption('MOUSE','MOUSE'));
        }
        else if(SelectedNode == 'N2')
        {       
            options.add(new SelectOption('N/W','N/W'));
           
        }
        else if(SelectedNode == 'N3')
        {       
            options.add(new SelectOption('MONITOR','MONITOR'));
           
        }
        else
        {
            options.add(new SelectOption('None','--- None ---'));
        }      
        return options;
    }       

   public PageReference productDetails(){
          
          pList = [select id FROM product2 where name =:product LIMIT 1];
       
         return null;
       
   }
}

Notify me if it'll Helped you

Regards
Virendra

Rajendra ORajendra O
<apex:page standardController="Account" extensions="productconfig5">
    <apex:form >
       <apex:pageblock >
          <apex:panelGrid columns="5">
             Select Node &nbsp;<apex:selectList size="1" value="{!SelectedNode}">
               <apex:selectOptions value="{!SelectedNodes}"/>
                  <apex:actionSupport event="onchange" reRender="a"/>
                     </apex:selectList>  
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Select Product &nbsp;<apex:selectList size="1" value="{!product}" id="a">
                            <apex:selectOptions value="{!products}" onchange="onProductSelection(this.value)"/>
                       </apex:selectList>
                     </apex:panelGrid>
                   <apex:outputPanel id="Details">
                <apex:outputText value="The Product you Selected is {!product} " rendered="{!product != null}" />
             </apex:outputPanel>
          </apex:pageblock>
      </apex:form>
   <script>
   function onProductSelection(productName){
  window.open("{!$Page.ProductDetail}?pName="+productName, "_blank", "toolbar=no, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");
}
   </script>
  
</apex:page>



class--

public with sharing class productconfig5
{
      Public String SelectedNode{get;set;}
      Public String Product{get;set;}
      Public String SelectedProduct{get;set;}
      public productconfig5(ApexPages.StandardController controller)
         {
      
        }
 
    public List<SelectOption> getSelectedNodes()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('None',' None'));      
        options.add(new SelectOption('N1','N1'));
        options.add(new SelectOption('N2','N2'));
        options.add(new SelectOption('N3','N3'));      
        return options;
    }
    public List<SelectOption> getProducts()
    {
        List<SelectOption> options =new List<SelectOption>();
  options.add(new selectoption('',''));
        if(SelectedNode == 'N1')
        {     
            options.add(new SelectOption('CPU','CPU'));
            options.add(new SelectOption('MOUSE','MOUSE'));
        }
        else if(SelectedNode == 'N2')
        {     
            options.add(new SelectOption('N/W','N/W'));
         
        }
        else if(SelectedNode == 'N3')
        {     
            options.add(new SelectOption('MONITOR','MONITOR'));
         
        }
        else
        {
            options.add(new SelectOption('None', 'None '));
        }    
        return options;
   }     
}


I have updated your existing code to call some JS. You will will need to create two more code files to save above changes


#1 Create VF page and related controller with name "ProductDetail". On controller load fetch request parameter "pName" and populate the product detail to be displayed in popup. Something like:-
ProductDetail.page

<apex:page controller="ProductDetailController" sidebar="false" showHeader="false">
<!--If product detail can be linked to field use outputField -->
<apex:outputText value="{!productDetail}" />
</apex:page>

ProductDetailController.cls

public with sharing ProductDetailController(){
public string productDetail {get; private set;}
public ProductDetailController(){
  String productName = Apexpages.currentPage().getParameters().get('pName');
  if(productName != null){
   //@todo Fetch product detail
   productDetail = 'Some detail';
  }else{
   //@todo add page message i.e. details/product not found
  }
}
}

There are other approches to serve your purpose but I guess it's the simple one. Let me know if it solve your issue.

Please note:
All code changes I did were in offline mode, so you may encounter trival save error.
You should not be using the product name string as option values, you should be using record ids.
Also next time please use code editor to paste code, it's really easy to do so and extremlly helpfull during review.
sk kumarsk kumar
hi  virendra & rajebdra thnx for yr quick response...but m not getting the result.actually..i paste yr code in vf page.. wht i need is if i select cpu it show a popip message like(cpu dualcore),n/w(wireless),monitor(24 inch)..i  write the below  vf  page & controller but dont getting the popup message while clicking cpu node..plz  help me..
sk kumarsk kumar
hi virendra m getting error after i pasted yr code in my vf page....the error is below-----


Visualforce Error
Help for this Page

System.QueryException: List has no rows for assignment to SObject
Error is in expression '{!productDetails}' in page productconfig6: Class.productconfig6.productDetails: line 50, column 1

Class.productconfig6.productDetails: line 50, column 1


kindly let me know..bcoz when i click the cpu option it will show the above error..plz do reply dude..thnx
Virendra ChouhanVirendra Chouhan
Hi Sk,

Make sure you have a product name CPU.
 after that run this code


sk kumarsk kumar
hi virendra ..thnx dude but m not getting how to check that..so plz be elaborate & give me proper detail concept bcoz m new to this visualforce coding...i m  copied all yr code & when selecting cpu or monitor it will not rertriving anything..so m not getting that exactly where i need to write the cpu details , monitor details  so that when click the perticular node cpu or monitor it will give me the infirmation as a popup...so can u do the changes in my code for wchich reason u guessing that it will not retrivng the data..sorry for  disturbing u again & again  so plz  dont mind..bcoz i hav a urgent assignment..:
Virendra ChouhanVirendra Chouhan
Hi sk Kumar,

If you are using my code the njust create a product from the product standard  tab with name CPU.
and also feel some details.then try to this vf page.

If we talk about your code so sorry but still i don't understand that your product CPU and MOUSE are custom objects record or just static details for that.

Regards
Virendra 
version7.7@hotmail.com (mailto:version7.7@hotmail.com)
sk kumarsk kumar
thnx virendra..finally it working loads of thnx for quick response...again if i want to make it like nested how shouid i syncronize my code....suppose if i select cpu it will show another node like intel, & if i select montor it will show another name node ho near to that & again if i select N/W it will show wifi tab near to that...so basically the flow will be like nested tree manner..for this will i implement same logic or how & where should i write this new logic so that it looks like hirachy manner..& whener node i will click it will show that tab information in popup.....thnx a lot u just amazing devloper..do reply to me ..m waiting for yr response..dont mind bro bcoz m asing u dout..u know m a beigner so do help me...: