5

I have a Visualforce page that collects user input for 125 integer variables that are then used by the controller to create records. I'd rather use an array instead of defining all those variables, but I can't seem to set a variable using

<apex:inputText value="{!inputValue[0][0]}" id="firstInputText"/>

I looked into apex:selectoptions but that doesn't look like I can use it since I need integer values from 0 to 20,000 rather than picklist-like values.

Any suggestions?

1 Answer 1

5

I'm not sure how you want it to display, but how about using an <apex:repeat> with a map?

Your class could look like this.

public Map<String,Integer> vals {
    get {
        if (vals == null) {
            vals = new Map<String, Integer> {
                'Value 1' => 0, 
                'Value 2' => 0, 
                'Value 3' => 0};
        }
        return vals;
    }
    set;
}

Then the page would be

<apex:repeat value="{!vals}" var="valKey">
        <apex:outputText value="{!valKey}" /> -- 
        <apex:inputText value="{!vals[valKey]}" /><br/>
</apex:repeat>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.