0

I have the following:

<apex:column headerValue="Contact" headerClass="ct" >

    <apex:inputField value="{!c.Contactid}" id="inputField"/>
    <apex:inputHidden id="hdnField" value="{!contactId}" />

    <apex:commandLink value="+" styleClass="btn" style="color:red;font-size:15px;"  onclick="setVar();" action="{!updateCase}" >

        <apex:param name="caseId"
                    value="{!c.Id}"
                    assignTo="{!caseId}" />

        <apex:param name="contactId"
                    value="{!contactId}"
                    assignTo="{!contactId}" />                            

    </apex:commandLink>       

</apex:column>

I'm trying to set the apex:param with the name contactId to the value of my apex:inputHidden field so I can pass that value to my controller when I click the command button. inputHidden is set correctly, but I can't work out how to link the param to the inputHidden value attribute?

Does anybody have any ideas?

4
  • have you defined contactId as getter and setter in your controller ?
    – MIX DML
    Oct 24, 2015 at 14:06
  • Yeah, they're both properties. caseId works fine but contactId isn't being passed through. I have a feeling it's because the value and assignTo attributes are the same, and I'm not sure if it should be like that.
    – user24634
    Oct 24, 2015 at 17:21
  • 1
    Yeah... Why don't you pass c.ContactID to value in Param ?
    – MIX DML
    Oct 24, 2015 at 17:35
  • Sorry I'll probably reword my original. I want to pass the value of my hidden field instead. I don't know if I can do this via javascript/jquery or how I should do it.
    – user24634
    Oct 24, 2015 at 18:57

1 Answer 1

0

If you are setting the value of the input field, when the ajax post happens due to the click on the link, the value of contact ID will be as it is in the hidden field, so you do not need the param since you have the input hidden field as the setter will set it when the ajax post is made.

Below is an example

Class

public class xmyTest{


 public string contactID {get;set;}


 public void showExample(){

   system.debug(logginglevel.error,'The value of Contact ID IS: ' + contactID);
 }



}

Page

<apex:page controller="xmyTest">

<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"/>

<script>

function setVal(){

  $('[id$=hideMe]').val('12345');

}

</script>

<apex:form >


<apex:inputHidden id="hideMe" value="{!contactid}"/>

<apex:commandlink value="+" onclick="setVal();" action="{!showExample}" />

</apex:form>



</apex:page>

Debug

01:31:15.026 (26306325)|USER_DEBUG|[9]|ERROR|The value of Contact ID IS: 12345

0

You must log in to answer this question.