3

I have a method to get the param value :

public PageReference facultyid() {
  public String fid{get;set;}    
  System.debug('facultyId: ' + fid);  
  return null;
}

My page calls and sets this function as below:

<apex:pageBlockTable value="{!faculties}" var="f"  id="fblock" rendered="{!faculities.size!=null}">
  <apex:column >
    <apex:actionregion >   
      <apex:outputpanel id="plusimage">
        <apex:image url="{!$Resource.Plus_Image}" onclick="switchMenu('{!$Component.inlinetablesec}','{!$Component.minusimage}','{!$Component.plusimage}')" title="Expand - Faculties"> 
          <apex:actionsupport event="onclick" action="{!facultyid}">
            <apex:param name="facultyid"  value="{!f.id}" assignTo="{!fid}" />
          </apex:actionsupport>
        </apex:image>
      </apex:outputpanel>  
    </apex:actionRegion> 

So it should pass the "fid" value immediately, but it is not happening... its showing me null value in debug logs why is it so? am i doing something wrong here, please help me to get the value of fid to controller, i can't use action function as its inside the output panel between tables, so please suggest me. Thanks in advance for the help.

1

Param will be passed on post of form to server.

In your action support you don't have any rerender attribute. Add a rerender attribute and give id plusimage.

One more thing to note is apex:param behaves differently when passing id value with string literal in name attribute.

If you change this

<apex:param name="facultyid" value="{!f.id}" assignTo="{!fid}"/>

To

<apex:param name=" {!f.id} " value="{!f.id}" assignTo="{!fid}"/>

it works. Its not documented anywhere but usually works for me.

Hope it helps.

  • When i add Rerender = plusimage or my pagblock id - its not expanding -means no action is performed now at all... – sfdev Jul 21 '15 at 8:18
  • Then you should rerender whole form. – Vigneshwaran G Jul 21 '15 at 8:28
  • still it is coming as null; – sfdev Jul 21 '15 at 8:38
  • Updated my answer to address this issue. Take a look and let me know if it worked. – Vigneshwaran G Jul 21 '15 at 8:54
1

try using Command button.

<apex:commandButton action="{!removeCon}" id="remov" image="{!URLFOR($Resource.minus_icon1)}" style=" height:25px;  width:25px;"reRender="pb2">
<apex:param name="selectedIndex" value="{!Wap.index}" /> 
</apex:commandButton>
  • i don't want commandbutton on it , if i use commanbutton or commandlink , its working fine , but i dont want to use command button , its just expand all image – sfdev Jul 21 '15 at 10:52
  • i tried with commandbutton or commandlink for apex param , and its not working – sfdev Jul 22 '15 at 9:05
1

Shouldn't fid be declared with its get & set before the method? Otherwise, the method should work with the local values.

  • i have declared it before the method only but as i can't post my all lines of code over here , just added get set is declared to show. – sfdev Jul 22 '15 at 8:46
1

I don't know whats happening with apex param for apex support , So i just used below code to complete my requirement using action function

<apex:actionFunction name="for faculty" action="{!facultyid}" rerender="myoutputpanel" > <apex:param name="fid" value="{0}" /></apex:actionFunction>
1

I had the same problem when using param to pass value to apex code. Below code solve my problem. //apex code

public String fid{
    get;
    set{
        fid = value;
       }
}
public PageReference facultyid(){
    system.debug('fid = ' = fid);
}

//vf page

<apex:param name="fid" value="{!f.id}" assingTo="{!fid}"/>

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.