0

I have a radio button it's function is, when click it should reRender pageblock table. But when I press it button not get clicked. so that my table not get reRender. For achieving that i tried but not working. Please help me.

<apex:pageBlockTable id="cWapID" value="{!con_ord}" var="cWap" rendered="{!con_ord.size > 0}"> 
<apex:column headerValue="Select" styleClass="actionColumn">
    <apex:actionSupport event="onclick" action="{!onChangeContract}" reRender="cWapID, attachmentSection" status="waitMsg">
        <input type="radio" name="chosen" id="{!cWap.Id}" VALUE="{!cWap.Id}" onclick="setcontractId(this,'{!$Component.RadioButtonValue}');"/> 
    </apex:actionSupport>
 </apex:column> 
</apex:pageBlockTable>
 <apex:inputHidden value="{!selectedcontractId}" id="RadioButtonValue"/>   

  <script type="text/javascript">
      function setcontractId(input, textid) {
          document.getElementById(textid).value = input.value;
      }   
   </script> 

My Controller method:

public String selectedcontractId {get; set;} 
//On click of radio button change 
public PageReference onChangeContract(){  
    return null;
}

On Click radio button here i am getting selectedcontractId value as an Id.

1
  • Try wrapping your pageBlockTable in an outputPanel tag and then rerender the ID of the outputPanel.
    – Berg
    Commented Jul 22, 2015 at 11:05

1 Answer 1

1

All other things working correctly, your use of action support is incorrect. It needs to be the child of the mage it is supporting not the parent since you already have an onClick on the input you can remove the action support altogether

<apex:inputRadio name="chosen" id="{!cWap.Id}" VALUE="{!cWap.Id}"  
                 onclick="setcontractId(this,'{!$Component.RadioButtonValue}');"/> 

Also, javascript is CASE SENSITIVE so your function never gets called so change the onclick to this:

onclick="setcontractid(this,'{!$Component.RadioButtonValue}');"

To call the controller method, use action function and param

<apex:actionFunction name="setcontractid" action="{!onChangeContract}" rerender="">
   <apex:param value="" name="myparam" assignto="{!controllervariable}"/>
</apex:actionFunction>

and change your onClick to:

onclick="setcontractid(this.value);"

You must log in to answer this question.

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