You need to sign in to do that
Don't have an account?
Néstor Velázquez Sánchez
How receive a POST in custom controller?
I need your help with a new doubt with a custom controller.
In my VisualForce page I have to SelectList, these SelectList could change their name periodically (they are dynamic) in some times I have only one, but sometime I have 10 or more.
Then my SelectList have a name like:
In my VisualForce page I have to SelectList, these SelectList could change their name periodically (they are dynamic) in some times I have only one, but sometime I have 10 or more.
Then my SelectList have a name like:
<select name="{!var.Name_{!var.Id}" id="{!var.Name_{!var.Id}"> <apex:repeat var="opt" value="options"> <option value="{!opt.Id}>{!opt.Name}</option> </apex:repeat> </select>
This SelectList could be repeat N times, the form looks like the attachment image.
How I can recieve this values in the custom controller to insert in my object Custom__c.
It's important considering that the code
ApexPages.currentPage().getParameters().get('input')
is useless there, I have a lot input fields with distinct names,and not all the time will be the same name.
Thanks.
This is a big question; but I'll start by suggesting that you use the Visualforce components that implement select/option picklists. Hopefully, that will get you most of the way there.
<pre>
<apex:selectList value="{!var.Name_{!var.Id}}" id="{!var.Name_{!var.Id}}" size="1">
<apex:repeat var="opt" value="{!options}">
<apex:selectOption itemValue="{!opt.Id}" itemLabel="{!opt.Name}"/>
</apex:repeat>
</apex:selectList>
<!-- You could also to do this, with changes to your controller. -->
<apex:selectList value="{!var.Name_{!var.Id}}" id="{!var.Name_{!var.Id}}" size="1">
<apex:selectOptions value="{!options}"/>
</apex:selectList>
</pre>
Basically I don't understanding the concept FORM > DESTINY in salesforce.
Invalid selectOptions found. Use SelectOption type in Apex.
<pre>
public List<Option__c> options { get; private set; }
{
options = [SELECT Id, Name from Option__c];
}
</pre>
The second method (lines 8-10) of my post) will require you to use the Apex class, SelectOption, in your controller. It's a little more complicated, but not much:
<pre>
public List<SelectOption> options { get; private set; }
{
options = new List<SelectOption>();
for ( Option__c option : [SELECT Id, Name from Option__c] )
{
options.add( new SelectOption( option.Id, option.Name ) );
}
}
</pre>
Hi, I try to use the code that you provide me, but it's not useful for my proposities, the options for this list must will be dynamic, I am use an IF statement for "draw" the option according the case in code lines previous.
If I used this code:
In this case the options is an optinos sting like this:
And i Can't compare with other elements for draw the only one option that I need, thats useless for me. EXAMPLE I NEED ONLY THIS ELEMENT BUT THE SECOND PART: BAILARIN SALTARIN - Capacidad de expresión, I also need other hidden fields that will be compared for make the update and insert into custom objects, but I can't get the elements using POST GET or whatever.
:'(
I answer to myself . . .
All the variables must be declared in the upper part of the class. . .
Once upon that the variables are declareted it's necesary populate this and create a new instances about this in the constructor of class:
And the list for the options
Finally I need create a WRAPPER CLASS for the select with this element i can use the list elements. like a Map<idELement, ListElemnts>
In the visual force I was created the SelectList with options, then in the controllerThanks a lot for read and try to help.