0

I want to pass the value of the pressed link to the controller - Is that possible with

<apex:actionsupport >? Or should I use the apex:param for this?

 <apex:column style="float:right;">
  <apex:commandLink value="{!acc.name}" reRender="accountId,selectedProductListId" action="{!proceedToUpload}" oncomplete="closeTable();"> 
        <apex:param value="{!acc.Id}" name="act" />
        <apex:param value="{!acc.Name}" name="accountName" />

      </apex:commandLink>

   </apex:column>

 </apex:pageBlockTable>

I want to know if I can do it on the same way like in the apex:selectList:

<apex:selectList styleClass="form-control" size="1" value="{!productSelected}" id="selectedProductListId">
                                        <apex:selectOptions value="{!productoList}" id="selectOptionsProductId"/>
                                        <apex:actionSupport action="{!checkTheValues}" event="onchange" reRender="selectedProductItemListId" />
                                    </apex:selectList>

and then I will have the value: 'productSelected' on the controller after the apex:supportAction ran without using the apex:param...

(and of course I will have 'productSelected' variable with get;set; inside the controller)

1 Answer 1

1

You can't pass the value to the controller; it's the attribute that shows the label. You can use the apex:param either directly or within the apex:actionSupport element. The only change you need to make to your code is to create public variables, and use the assignTo attribute to assign the values:

Apex

public transient string accountId { get; set; }
public transient string accountName { get; set; }

Visualforce

<apex:param value="{!acc.Id}" name="var1" assignTo="{!accountId}" />
<apex:param value="{!acc.Name}" name="var2" assignTo="{!accountName}" />
2
  • Hi @sfdcfox, Thanks for answering. I just updated the question - if you can look on it. I did it as you said, I just wanted to know if I can give up on the apex:param...
    – Salvation
    Commented Mar 3, 2019 at 11:34
  • 1
    @Salvation You will need an apex:param, there's no other way to get parameters back to the controller.
    – sfdcfox
    Commented Mar 3, 2019 at 14:39

You must log in to answer this question.

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