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
Abel PalmaAbel Palma 

I need help here, I need to pass parameters to a class

I´m using  SelectOption (a kind of picklist) in an Apex page, I need to pass the parameter to other class with a button (a submit)


This is my visual Force Page:
<apex:page lightningStylesheets="true" ><!--extensions="WebServiceController"-->
    <apex:form>
        <apex:pageBlock title='Employee id'>
            <apex:pageBlockSection>            
                <apex:selectList id="AccountsClients" Title="Accounts ids" size="1">
                     <apex:selectoption itemLabel="Account 1" itemValue="D0000001"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 2" itemValue="D0000002"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 3" itemValue="D0000003"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 4" itemValue="D0000004"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 5" itemValue="D0000005"></apex:selectoption>                               
                </apex:selectList>            
            </apex:pageBlockSection>
            <apex:pageBlockButtons>
            <apex:commandButton value="Register" id="SubmitButton" action="{!IdCuentas}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>



This is the class that needs to receive the parameter 

public class WebserviceClass{
    public HttpResponse WebserviceClss (String numeroCliente){    
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        getClientes__c customSetting= getClientes__c.getValues('saveAccount');
        request.setEndpoint(customSetting.URL__c + numeroCliente);
        request.setMethod('GET');
        system.debug(customSetting.URL__c);
        HttpResponse response = http.send(request);
        system.debug(response);
        return response;
    }
}
 
Best Answer chosen by Abel Palma
Pradeep SinghPradeep Singh
Hi, Please refer below code.
<apex:page lightningStylesheets="true" controller="WebserviceClass">
    <apex:form>
        <apex:pageBlock title='Employee id'>
            <apex:pageBlockSection>            
                <apex:selectList value="{!selectedValue}" id="AccountsClients" Title="Accounts ids" size="1">
                     <apex:selectoption itemLabel="Account 1" itemValue="D0000001"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 2" itemValue="D0000002"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 3" itemValue="D0000003"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 4" itemValue="D0000004"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 5" itemValue="D0000005"></apex:selectoption>                               
                </apex:selectList>            
            </apex:pageBlockSection>
            <apex:pageBlockButtons>
            <apex:commandButton value="Register" id="SubmitButton" action="{!retrieveValue}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

--------------------------------------------------------------
public class WebserviceClass{
    
    public string selectedValue{get;set;}
    public void retrieveValue(){
        system.debug('-----' + selectedValue);
    }
    
    public HttpResponse WebserviceClss (String numeroCliente){    
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        /*getClientes__c customSetting= getClientes__c.getValues('saveAccount');
        request.setEndpoint(customSetting.URL__c + numeroCliente);
        request.setMethod('GET');
        system.debug(customSetting.URL__c);*/
        HttpResponse response = http.send(request);
        system.debug(response);
        return response;
    }
}

All Answers

Pradeep SinghPradeep Singh
Hi, Please refer below code.
<apex:page lightningStylesheets="true" controller="WebserviceClass">
    <apex:form>
        <apex:pageBlock title='Employee id'>
            <apex:pageBlockSection>            
                <apex:selectList value="{!selectedValue}" id="AccountsClients" Title="Accounts ids" size="1">
                     <apex:selectoption itemLabel="Account 1" itemValue="D0000001"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 2" itemValue="D0000002"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 3" itemValue="D0000003"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 4" itemValue="D0000004"></apex:selectoption>
                     <apex:selectoption itemLabel="Account 5" itemValue="D0000005"></apex:selectoption>                               
                </apex:selectList>            
            </apex:pageBlockSection>
            <apex:pageBlockButtons>
            <apex:commandButton value="Register" id="SubmitButton" action="{!retrieveValue}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

--------------------------------------------------------------
public class WebserviceClass{
    
    public string selectedValue{get;set;}
    public void retrieveValue(){
        system.debug('-----' + selectedValue);
    }
    
    public HttpResponse WebserviceClss (String numeroCliente){    
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        /*getClientes__c customSetting= getClientes__c.getValues('saveAccount');
        request.setEndpoint(customSetting.URL__c + numeroCliente);
        request.setMethod('GET');
        system.debug(customSetting.URL__c);*/
        HttpResponse response = http.send(request);
        system.debug(response);
        return response;
    }
}
This was selected as the best answer
DoondiDoondi
HI pradeep singh
I wanted to add more colums to one particluar view, any help on how I can achieve