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
karthic sankar 9karthic sankar 9 

I am unable to get value from VisualForce page to Controller

Hi Experts,

Can anyone pls help me why I am gettting NULL value here.

MY Contoller

public class ViewQAAMController {

    public PageReference MyMethod() {
        System.debug('I am called');
        pageReference pg = new pageReference('http://www.google.com/');
        pg.setRedirect(true);
        return pg;
    }
    
    public void callMe()
    {
        System.debug('I am called by JavaScript' + ValueFromVF);
        
    }


    public String valueFromVF { get; set; }
    //valueFromVF
   
    public List<AggregateResult> BadgeList
  {
      get
      {
          List<AggregateResult> badges = [select Week__c, max(createddate) apple from QAAM_Weekly_Planner__c Max group by Week__c order by max(createddate) desc LIMIT 10];
          return badges;
      }
      set;
  }
    
   }

My VF page:

<apex:page controller="ViewQAAMController">
<apex:form >
<apex:actionFunction action="{!callMe}" name="callthisinJavaScript" reRender="a" />
<apex:pageBlock >

<apex:pageBlockTable value="{!BadgeList}" var="data" align="center" styleClass="table table-striped" >
<apex:column headerValue="MyValues">
<apex:outputLink value="{!data['Week__c']}" onclick="openWindow()">{!data['Week__c']}</apex:outputLink>
<apex:param name="weekValue" value="{!data['Week__c']}" assignTo="{!valueFromVF}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
<script>
function openWindow(){
         window.open('/apex/AddQAAMWeeklyPlanner');
         alert(callthisinJavaScript());
         callthisinJavaScript();
        }
    </script>
</apex:page>


I am getting value as NULL in controller

Regards
Karthic
 
Footprints on the MoonFootprints on the Moon
Hey Karthic,
<apex:param> must be within <apex:outputLink> in your VF Code.
<apex:outputLink id="outputLink" value="{!data['Week__c']}" onclick="openWindow()">
	<apex:param name="weekValue" value="{!data['Week__c']}" assignTo="{!<Your variable from Controller>}"/>
</apex:outputLink>

Try changing accordingly, and let me know the result!
karthic sankar 9karthic sankar 9
Hi Footprints on the moon,

My bad Sorry.. I have tried as suggested, Still I am getting null value, please help.

Controller:

public class ViewQAAMController {
 
    //valueFromVF
   public String valueFromVF { get; set; }
    public List<AggregateResult> BadgeList
  {
      get
      {
          List<AggregateResult> badges = [select Week__c, max(createddate) apple from QAAM_Weekly_Planner__c Max group by Week__c order by max(createddate) desc LIMIT 10];
          return badges;
      }
      set;
  }
    
     public void CallThisMethod()
    {
        System.debug('The value from VF is '+valueFromVF);
        
    }
    
  
   }

Visual Force

<apex:page controller="ViewQAAMController">
<apex:form >
<apex:actionFunction action="{!CallThisMethod}" name="callthisinJavaScript" reRender="a" />
<apex:pageBlock >
<div align="center" draggable="false" >
<apex:commandButton value="New" onclick="openQAAM()" disabled="false"/>
</div>
<apex:pageBlockTable value="{!BadgeList}" var="data" align="center" styleClass="table table-striped" >
<apex:column headerValue="MyValues">
<apex:outputLink id="PBValue" value="{!data['Week__c']}" onclick="javascript:openWindow('{!$Component.PBValue}')">
<apex:param name="weekValue" value="{!data['Week__c']}" assignTo="{!valueFromVF}"/>
{!data['Week__c']}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
<script>
function openWindow(Arg){
    var str = document.getElementById('{!$Component.PBValue}');
    alert(str);
         window.open('/apex/AddQAAMWeeklyPlanner');
         callthisinJavaScript();    
        }
        
        function openQAAM()
        {
        window.open('/apex/AddQAAMWeeklyPlanner');
        }
    </script>
</apex:page>


Kindly Help.

Regards
Karthic