0

I have the following visualforce page:

<apex:page title="Select return address" Controller="FedExController">
    <apex:form >
        <apex:pageBlock title="FedEx Label generation for {!RMA}">
            <span>Viable addresses: </span>
            <apex:selectList size="1" id="returnAddressesSelectList" value="{!returnAddressesValue}">
            <apex:actionSupport event="onchange" action="{!recalculateDefaults}" rerender="form"/>
            <apex:selectOptions value="{!returnAddresses}" />
            </apex:selectList><br></br>
            <apex:inputText value="{!Address}" id="AddressTextBox"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>

And the following controller:

global class FedExController {

private final Account account;
global static Id myIdclone;
public List<SelectOption> compressedAddressesPREFIX = new List<SelectOption>();
global string returnAddressesValue{get;set;}

public static string getDefaultSubject(){
    return null;
}

public static string getRMA(){
    Id myId = ApexPages.currentPage().getParameters().get('id');
    System.debug('ID: ' + myId);
    FedExLabelMethods job = new FedExLabelMethods();
    String rmaNumber = FedExLabelMethods.getRMA(myId);
    return rmaNumber;
}

public List<SelectOption> returnAddresses{
    get{
        Id myId = ApexPages.currentPage().getParameters().get('id');
        FedExLabelMethods job = new FedExLabelMethods();
        List<String> compressedAddresses = FedExLabelMethods.getlistofAddresses(myId);
        for (integer i = 0; i < compressedAddresses.size(); i++){
            string temporarystring = compressedAddresses[i];
            string[] temporaryarray = temporarystring.split(',');
            compressedAddressesPREFIX.add(new SelectOption(temporaryarray[0],temporaryarray[0]));
        }
        return compressedAddressesPREFIX;
    }
    set;
}

public static void recalculateDefaults(){

}

public string Address{
    get{
        system.debug('ReturnAddresses ' + returnAddressesValue);
        system.debug('compressedAddressesPREFIX ' + compressedAddressesPREFIX);
        return returnAddressesValue;
    }
    set;
}
}

What I am trying to do is probably extremely simple for others more experienced with visualforce than me. I want to get

 System.debug('ReturnAddresses ' + returnAddressesvalue);

at the bottom of the visualforce controller to display the current value of the selected list id returnAddressesSelectList.

Currently the debug displays Null...

4
  • You are never assigning any value "returnAddressesValue" variable, that's why it is displaying null. Commented Jan 12, 2016 at 1:30
  • How do I get the current value (which option is selected) of the selectlist then?
    – JMK
    Commented Jan 12, 2016 at 1:32
  • Do you plan on submitting your form with an apex:commandButton? Commented Jan 12, 2016 at 1:37
  • Not necessarily, my aim is to have the form update when the selectlist changes, however if it is necessary for me to submit the form then I would use a commandbutton to move onto another page that calls for the previous page's variables. However I want to just update the form when the selectlist changes.
    – JMK
    Commented Jan 12, 2016 at 1:39

1 Answer 1

0

Your rerender="form" rerenders a VF component with id="form" yet you have no such component element

You need

<apex:form id="form">
1
  • NP, I make this mistake all the time myself
    – cropredy
    Commented Jan 12, 2016 at 1:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .