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

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
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
<apex:param> must be within <apex:outputLink> in your VF Code.
Try changing accordingly, and let me know the result!
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