function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Balakumar Ramachandran 6Balakumar Ramachandran 6 

<apex:param> not working inside pageblock

VF Page
-----------

                 <apex:pageblockTable value="{!users}" var="user" >                                                           
                         <apex:column width="20%">
                           <apex:facet name="header">Owner ID </apex:facet>                         
                            
                            <apex:commandlink value="Del" action="{!delCont}" rerender="" >
                               <apex:param name="contIdChosen"  value="{!user.UserOrGroupId}" assignTo="{!contIdChosen}"/>                         
                             </apex:commandlink>                            
                         </apex:column>                                    
                  </apex:pageblockTable>


class
=------

public PageReference delCont()
    {    
     system.debug('----------------------------------------Test Me------------------------------');
     Id id = System.currentPageReference().getParameters().get('contIdChosen');
     Scheme__Share toDel=new Scheme__Share(Id=contIdChosen );
     system.debug('----------Id is------------'+contIdChosen );     
     PageReference nextpage1 = new PageReference('/apex/share/WV_SharingDetails?parentId='+id);
     nextpage1.setredirect(true);
     return nextpage1;
    
    }


The method delCont  itself is not called inside pageblock.. If i place outside it it works fine but i need it inside pageblock..
Hargobind_SinghHargobind_Singh
Hi,

You won't be able to pass parameters to commandlInk component. You can try to use ActionFunction to pass parameters to your Apex Controller. Here is an example:   http://salesforce.stackexchange.com/questions/24175/passing-method-parameters-with-apexactionfunction
Balakumar Ramachandran 6Balakumar Ramachandran 6
thanks hargobind..

now i modify this to

page
--------
<script>
    function ClickMe(id)
    {
        alert(id);
        callDelId();
    }
</script>

<apex:actionFunction name="callDelId" action="{!delCont}" onComplete="alert('After apex method') ;" />
<apex:commandlink value="Del" onClick="ClickMe(!user.UserOrGroupId);" >
                            <apex:param name="contIdChosen"  value="{!user.UserOrGroupId}"  assignTo="{!contIdChosen}"/> 
                            </apex:commandlink >


class
--------

public PageReference delCont()
    {    
     system.debug('----------------------------------------Test Me------------------------------');
         system.debug('----------Id is------------'+contIdChosen );
     Id id = System.currentPageReference().getParameters().get('contIdChosen');
     system.debug('----------Id is------------'+contIdChosen );
     Scheme__Share toDel=new Scheme__Share(Id=contIdChosen );    
     system.debug('----------Id is------------'+Id); 
     //delete todel;
     //setupContacts();  
     PageReference nextpage1 = new PageReference('/apex/share/WV_SharingDetails?parentId='+id);
     nextpage1.setredirect(true);
     return nextpage1;
        
    }

how do i pass the id from javascript. i got in the alert the respective id..how do i pass it to controller ??
Madhu SFDC PhoenixMadhu SFDC Phoenix
Hi,

I tested the same example. which worked fine for me

vf Page:
<apex:page controller="ApexParamExmaple" >
        <apex:form >
            <apex:pageBlock >
                 <apex:pageblockTable value="{!users}" var="user" >                                                          
                         <apex:column width="20%">
                           <apex:facet name="header">Owner ID </apex:facet>                       
                            <apex:commandlink value="Del" action="{!delCont}" rerender="" >
                               <apex:param name="contIdChosen"  value="{!user.Id}" assignTo="{!contIdChosen}"/>                        
                             </apex:commandlink>                           
                         </apex:column>                                   
                  </apex:pageblockTable>
              </apex:pageBlock>
      </apex:form>
</apex:page>

Controller:
public class ApexParamExmaple {
    public String contIdChosen {get;set;}
    public PageReference delCont()
    {   
     system.debug('----------------------------------------Test Me------------------------------');
     Id id = System.currentPageReference().getParameters().get('contIdChosen');
     //Scheme__Share toDel=new Scheme__Share(Id=contIdChosen );
     system.debug('----------Id is------------'+contIdChosen );    
     PageReference nextpage1 = new PageReference('/apex/share/WV_SharingDetails?parentId='+id);
     nextpage1.setredirect(true);
     return nextpage1;
    }
   
    public List<User> getUsers() {
        return [select Id,Name from User];
    }
}

Can you please be specific what exactly the issue is
Hargobind_SinghHargobind_Singh
Hi Balakumar, 

Here is an example: 
<apex:outputLink value="javascript:if (window.confirm('Are you sure?')) DeleteQuoteLineItem('TEST VALUE');">
    Del
</apex:outputLink>

    <apex:actionFunction action="{!DeleteQuoteLineItem}" name="DeleteQuoteLineItem" reRender="content">
        <apex:param name="myParam" value=""/>
    </apex:actionFunction>

If you look closely, the Param is to be added to "ActionFunction" tag, and you can call the action function name directly as a javascript function (you don't need an additional javascript function, i.e. your clickme function can be removed) 






Anoop yadavAnoop yadav
Balakumar Ramachandran 6Balakumar Ramachandran 6

<script>
    function ClickMe(id)
    {
        alert(id);
        callDelId(id.value);
        alert(id);
    }

<apex:actionFunction name="callDelId" action="{!delCont}" onComplete="alert('After apex method') ;" >
         <apex:param name="contIdParam"  value=""  assignTo="{!contIdChosen}"/>
    </apex:actionFunction>

class
----------
public PageReference delCont()
    {    
     system.debug('----------------------------------------Test Me------------------------------');
      Id id = Apexpages.currentPage().getParameters().get('contIdChosen');
    
     system.debug('----------Id is------------'+contIdChosen );
     Scheme__Share toDel=new Scheme__Share(id=contIdChosen);    
     system.debug('----------Id is------------'+Id);


i want to pass the value "id.value" in the apex parameter so that to the method delCont the id is coming..
Hargobind_SinghHargobind_Singh
Hi Balakumar, 

Are you not getting contIdChosen in this line ? 

system.debug('----------Id is------------'+contIdChosen );