+ Start a Discussion

SelectList in DataList


Hi All, 


How can I pass a value to an apex:param of an apex:commandLink from an apex:SelectList ?

I think I have to set an Id attribute to my SelectList but the problem is that my SelectList is in a DataList and I don't know how I can set a different SelectList Id for each row of my DataList.


My code

<apex:dataList value="{!events}" var="event"> <apex:form> <apex:outputText value="{!event.Commercial__c}"/> <apex:outputText value="{!event.Produits__c}"/> <apex:outputText value="{!event.Subject}"/> <apex:outputText value="{!event.What.Name}"/> <apex:selectList value="{!choice}" multiselect="false" size="1"> <apex:selectOptions value="{!choiceaction}"/> </apex:selectList> <apex:commandLink value="Do Action for this event" action="{!goToAction}"> <apex:param value="{!event.Id}" name="eventid" /> <apex:param value="" name="selectedChoice" /> </apex:commandLink> </apex:form> </apex:dataList>



I want my param selectedChoice have to take the value of the SelectList when I click on my commandLink.


My Controller


... public PageReference goToAction() { evt = PageReference Traitementcas1 ApexPages.currentPage().getParameters().get('eventid'); choice = PageReference Traitementcas1 ApexPages.currentPage().getParameters().get('selectedChoice'); ... }



Any Help please ?




Best Answer chosen by Admin (Salesforce Developers) 

You see a fair amount of this type of use case within salesforce where there is a list of records and there are several actions you can apply to those records, eg: Edit, Del. But rather than providing a drop-down with the list of actions and then a "Do it" link, we generally create seperate links for each action. For example, click on Setup, Develop, Apex Classes. You'll see the actions Edit, Del, WSDL and Security as seperate command links. In this case, you only need to pass one param which is the ID of the record you wish to apply the action to. Would this work for you? It might be a bit more familiar a UI pattern for your users.