Skip to main content
Hello everyone...

I'm working now in a complex part of my developing app, which is a full custom code, so that I will try to do is:

- Compare 2 variable; 1 from a pick list field (Width), and the other one from a field (Max_Width)

- Get 3 types of result:

  * Width > Max_Width; pop up a message to avoid create the record "Please pick width less than Max_Width"

  * Width = Max_Width; show a section with two fields Long_Imperial(number) and Length_Units(picklist field)

  * Width < Max_Width; show a section with standard pick list length

I've developed this code below, but I have no idea how transfer data in between them... Can somebody show me some light or help me with this code?, I don't know, whether it is possible that I'm trying to do, or not...

Thanks in advance, any advice it will be welcome

----VISUALFORCE---

<apex:pageBlockSection title="Imperial System" columns="1" 

                                rendered="{!Customer_s_Price_List__c.System_Of_Measurement__c == 'Imperial System'

                                && ( Customer_s_Price_List__c.Product_Type__c == 'Fabric' || Customer_s_Price_List__c.Product_Type__c == 'Tape') }">

     <apex:pageBlockSectionItem >

        <apex:outputLabel >Width(inches)</apex:outputLabel>

        <apex:inputField value="{!Customer_s_Price_List__c.Wide_Imperial__c}"> 

           <apex:actionSupport event="onchange" reRender="check_width"/>

        </apex:inputField>                          

     </apex:pageBlockSectionItem> 

     

     <apex:outputPanel id="check_width">

        <apex:pageBlock rendered="{!Tape_Fabric}">

  

        </apex:pageBlock>

     </apex:outputPanel>

</apex:pageBlockSection>

--------APEX------------

<public boolean Compare_width{get;set;}

public decimal var_Max_Width {get; set;}

public PageReference Tape_Fabric(){

    var_Max_Width = cpl.Max_Width__c;

    

    //Convert String in Decimal

    String temp = var_width;

    Decimal var_width_dec = Decimal.valueOf(temp);

   

    if(var_width_dec > var_Max_Width ){

        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Please select width '));

    }

    if(var_width_dec == var_Max_Width ){

        

    }

    if(var_width_dec < var_Max_Width ){

        List<SelectOption> options = new List<SelectOption>();

        var_width = cpl.Wide_Imperial__c;

        var_Max_Width = cpl.Max_Width__c;

        if(var_width <> null  || Test.isRunningtest() )

        {

            if((var_Product_Type =='Tape' || var_Product_Type =='Fabric') && (var_width =='1/4' || 

                                             var_width =='3/8' ) || Test.isRunningtest()){

                options.add(new SelectOption('18','18'));

                options.add(new SelectOption('3','3'));

                }

            if((var_Product_Type =='Tape' || var_Product_Type =='Fabric') && !(var_width =='1/4' || 

                                             var_width =='3/8' ) || Test.isRunningtest()){

                options.add(new SelectOption('36','36'));

                options.add(new SelectOption('3','3'));

                }

        }

        return option;

    }

}>

 
1 件の回答
  1. 2015年8月12日 20:27
    You need to grab the record from the page in the controller in the constructor method.

    public with sharing class testme {

    private final account vfRecord ;

    public testme(ApexPages.StandardController stdController) {

    this.vfRecord = (account)stdController.getRecord();

    }

    If you still have issue, post the whole code.

    thx
0/9000