You need to sign in to do that
Don't have an account?

Unable pass the Input value to the apex class
My Vf Page:
I am trying to pass the variable which stores the input field value to my apex controller.But the variable to which i am passing is returning null in the apex class.
My apex class:
What am i doing wrong?
<apex:page standardcontroller="Program_Member_MVN__c" extensions="ProgramMemberCaseAttachment" showHeader="false" > <head> <apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" / > <apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" /> <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" /> <script> j$ = jQuery.noConflict(); j$(document).ready( function () { var contactTable = j$('[id$="accounttable"]').DataTable({ }); }); function Callmefunc(id) { // alert(''+id); var type = document.getElementById(id).value; jQuery('[id$=myHiddenField]').val(id); alert(type); check(type); //return true; } </script> </head> <apex:form > <body> <table id="accounttable" class="display" > <thead> <tr> <th>Edit</th> <th>ID</th> <th>Name</th> <th>Type</th> <th>Attachment Name</th> <th>Description</th> </tr> </thead> <tbody> <apex:actionFunction name="check" action="{!processSelected1}" > <apex:param name="test" value="" assignTo="{!AttType}"/> </apex:actionFunction> <apex:repeat value="{!PMresults}" var="N"> <tr> <!--<apex:inputHidden value="{!AttType}" id="myHiddenField"/>--> <!--<td><apex:commandLink value="Edit" action="{!URLFOR($Action.Attachment_Type__c.Edit, N.Id ,[saveURL='/'+N.Id,retURL='/'+N.Id,saveandnewURL='/'+N.Id])}" target="_blank" styleClass="btn" style="text-decoration:none;padding:1px;"/> --> <td><apex:commandLink value="Save" action="{!processSelected}"> <apex:param name="{!N.Program_Memeber_Id__c}" value="{!N.Program_Memeber_Id__c}" assignTo="{!Attid}"/> <!--<apex:param name="{!N.Type__c}" value="{!N.Type__c}" assignTo="{!AttType}"/> --> </apex:commandLink> </td> <td><apex:outputField value="{!N.Program_Memeber_Id__c}" /></td> <td><apex:outputLink value="/{!N.Id}" target="_blank">{!N.Name}</apex:outputLink></td> <td><apex:inputField value="{!N.Type__c}" id="Check" onchange="Callmefunc('{!$Component.check}');"> <!--<apex:param name="Check" value="{!N.Program_Memeber_Id__c}" assignTo="{!Attid}"/>--> </apex:inputField> </td> <!--<td><apex:outputtext value="{!Attid}"/></td>--> <td><apex:outputField value="{!N.Attachement_Name__c}"/></td> <td><apex:outputField value="{!N.Attachment_Description__c}"/></td> <!--<td>{!N.At.LastModifiedDate}</td>--> <!--<td> <apex:outputField value="{!N.At.Description}"/></td>--> </tr> </apex:repeat> </tbody> </table> </body> </apex:form> </apex:page>
I am trying to pass the variable which stores the input field value to my apex controller.But the variable to which i am passing is returning null in the apex class.
My apex class:
/** * ProgramMemberCaseAttachment * Created By: Varun * Created On: 11/07/2017 * Description: This class is responsible for displaying Attachment Details Under Each Program Member * **/ public with sharing class ProgramMemberCaseAttachment{ public string AttType{get;set;} public Id Attid{get;set;} public List<Attachment_Type__c> PMresults{get;set;} public Program_Member_MVN__c cs; public ProgramMemberCaseAttachment(ApexPages.StandardController controller) { //AttType =''; cs=(Program_Member_MVN__c)controller.getRecord(); List<case> Test = new List<case>([select id from case where Program_Member_MVN__c =: cs.id]); System.debug('Test:'+Test); List<String> Id = new List<String>(); System.debug('AttType:'+AttType); for(case Cs1 : Test){ Id.add(Cs1.id); } PMresults = [select Program_Memeber_Id__c,Id,Attachement_Name__c,Attachment_Description__c,Name,Type__c from Attachment_Type__c where Program_Memeber_Id__c =: cs.id OR Program_Memeber_Id__c IN: Id]; System.debug('PMresults '+PMresults ); } public void processSelected1(){ //AttType = System.currentPageReference().getParameters().get('Test'); System.debug('AttType'+AttType); } public void processSelected(){ System.debug('AttType 1'+AttType ); List<Attachment_Type__c> PMType = new List<Attachment_Type__c>(); Attachment_Type__c At1 = new Attachment_Type__c (); At1 = [select Type__c from Attachment_Type__c where Program_Memeber_Id__c =: Attid]; System.debug('At1 '+At1 ); if(At1.Type__c != null){ At1.Type__c = AttType ; } PMType.add(At1); set<Attachment_Type__c> dedupSet = new set<Attachment_Type__c>(); dedupSet.addAll(PMType); List<Attachment_Type__c> dedupList = new List<Attachment_Type__c>(); dedupList.addAll(dedupSet); System.debug('dedupList'+dedupList); Update dedupList; } }
What am i doing wrong?