You need to sign in to do that
Don't have an account?
Thorsten Heinrich
passing null value when pass parameter using action function..Please help
<apex:actionFunction name="hitMe" action="{!iWantMyJSValues}">
<apex:param name="one" value="" assignTo="{!valueOne}" />
//passsing null value here
</apex:actionFunction>
$(document).ready(function(){
$("#stars-green").rating('create',{coloron:'green',onClick:function(){
var ratings = this.attr('data-rating');
alert('ratings is ' + ratings); // getting correct value in ratings
hitMe(ratings);
alert('function is ' +hitMe);
}
});
});
<div id="stars-green" data-rating="4"></div>
public PageReference iWantMyJSValues() {
valueOne = Apexpages.currentPage().getParameters().get('one'); // getting null value here
system.debug('******************valueOne******************'+valueOne);
return null;
}
<apex:param name="one" value="" assignTo="{!valueOne}" />
//passsing null value here
</apex:actionFunction>
$(document).ready(function(){
$("#stars-green").rating('create',{coloron:'green',onClick:function(){
var ratings = this.attr('data-rating');
alert('ratings is ' + ratings); // getting correct value in ratings
hitMe(ratings);
alert('function is ' +hitMe);
}
});
});
<div id="stars-green" data-rating="4"></div>
public PageReference iWantMyJSValues() {
valueOne = Apexpages.currentPage().getParameters().get('one'); // getting null value here
system.debug('******************valueOne******************'+valueOne);
return null;
}
Don't pass anything in hitMe call so it will be null automatically.
hitMe(ratings) should be replace with hitMe();
I hope this will help you.
Thanks,
Naval
Remove below line from your controller.
valueOne = Apexpages.currentPage().getParameters().get('one'); // getting null value here
Don't change this as well.
<apex:form >
<apex:actionFunction name="hitMe" action="{!iWantMyJSValues}">
<apex:param name="one" value="" assignTo="{!valueOne}" />
</apex:actionFunction>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta charset="utf-8"/><title>Metronic | Dashboard 2</title>
<script>
(function ( $ ) {
$.fn.rating = function( method, options ) {
method = method || 'create';
// This is the easiest way to have default options.
var settings = $.extend({
// These are the defaults.
limit: 5,
value: 0,
glyph: "glyphicon-star",
coloroff: "gray",
coloron: "gold",
size: "2.0em",
cursor: "default",
onClick: function () {},
endofarray: "idontmatter"
}, options );
var style = "";
style = style + "font-size:" + settings.size + "; ";
style = style + "color:" + settings.coloroff + "; ";
style = style + "cursor:" + settings.cursor + "; ";
if (method == 'create')
{
//this.html(''); //junk whatever was there
//initialize the data-rating property
this.each(function(){
attr = $(this).attr('data-rating');
if (attr === undefined || attr === false) { $(this).attr('data-rating',settings.value); }
})
//bolt in the glyphs
for (var i = 0; i < settings.limit; i++)
{
this.append('<span data-value="' + (i+1) + '" class="ratingicon glyphicon ' + settings.glyph + '" style="' + style + '" aria-hidden="true"></span>');
}
//paint
this.each(function() { paint($(this)); });
}
if (method == 'set')
{
this.attr('data-rating',options);
this.each(function() { paint($(this)); });
}
if (method == 'get')
{
return this.attr('data-rating');
}
//register the click events
this.find("span.ratingicon").click(function() {
rating = $(this).attr('data-value')
$(this).parent().attr('data-rating',rating);
paint($(this).parent());
settings.onClick.call( $(this).parent() );
})
function paint(div)
{
rating = parseInt(div.attr('data-rating'));
div.find("input").val(rating); //if there is an input in the div lets set it's value
div.find("span.ratingicon").each(function(){ //now paint the stars
var rating = parseInt($(this).parent().attr('data-rating'));
var value = parseInt($(this).attr('data-value'));
if (value > rating) { $(this).css('color',settings.coloroff); }
else { $(this).css('color',settings.coloron); }
})
}
};
}( jQuery ));
$(document).ready(function(){
$("#stars-green").rating('create',{coloron:'green',onClick:function(){
var ratings = this.attr('data-rating');
alert('ratings is ' + ratings);
hitMe(ratings);
alert('function is ' +hitMe);
}
});
});
</script>
<div id="stars-green" data-rating="4"></div>
</apex:form></apex:page>
It seems there is nothing wrong with your VF page code. Can you please post your controller here.
Thanks,
Naval
public PageReference iWantMyJSValues() {
// valueOne = Apexpages.currentPage().getParameters().get('one');
system.debug('******************valueOne******************'+valueOne);
return null;
}
Public List<Lead_Inspector__c> removeacc;
public Integer rowNum{get;set;}
Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}
Decimal totalcount =0;
public decimal percentage{get;set;}
public boolean test = false;
Public List<Lead_Inspector__c> getLeads{get;set;}
public Date startDate{get;set;}
public Date endDate{get;set;}
public string searchstring {get;set;}
public List<SelectOption> countrieLst {get;set;}
public String selectedCountry{get;set;}
public String selectedValues {get;set;}
public String valueOne { get; set; }
public String valueTwo { get; set; }
private List<Lead_Inspector__c> accounts;
private String sortDirection = 'ASC';
private String sortExp = 'name';
public Date datename{ get; set; }
public List<Id> hideListId = new List<Id>();
public String recordId;
public String val1 {get; set;}
public user currentuser{get;set;}
public List<SelectOption> getColumns()
{
countrieLst = new List<SelectOption>();
countrieLst.add(new SelectOption('','-- Select Field --'));
countrieLst.add(new SelectOption('Lead__c','Company'));
countrieLst.add(new SelectOption('Branch__c','Branch'));
countrieLst.add(new SelectOption('Duration__c','Duration'));
countrieLst.add(new SelectOption('HitConv__c','Hits'));
countrieLst.add(new SelectOption('Tags__c','Tags'));
return countrieLst;
}
public ApexPages.StandardSetController setCon {
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT id, Name, Date_Time_first_visit__c, Lead__c, Branch__c, Converted_To_Lead__c,Converted_To_Account__c, Hits__c, Total_Hits__c, Duration__c, Origin__c, Rating__c,Lead_Score__c, Tags__c FROM Lead_Inspector__c where Id not in: hideListId]));
}
return setCon;
}
set;
}
public Decimal getTotalHits(){
Decimal totalWebsitecount=0;
List<Lead_Inspector__c> leadList = new List<Lead_Inspector__c>();
for(Lead_Inspector__c a : (List<Lead_Inspector__c>)setCon.getRecords())
{
totalWebsitecount = a.Total_Hits__c;
totalcount= totalcount+totalWebsitecount;
// system.debug('++++++++++++++++++++++totalcount ++++++++++++++++++++++++++'+totalcount );
}
percentage = Math.round(totalcount * 100) / 100.0;
// system.debug('++++++++++++++++++++++percentage ++++++++++++++++++++++++++'+percentage);
return totalcount ;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('10','10'));
options.add(new SelectOption('50','50'));
options.add(new SelectOption('100','100'));
options.add(new SelectOption('200','200'));
return options;
}
//Sorting code starts
public String sortExpression
{
get
{
return sortExp;
}
set
{
//if the column is clicked on then switch between Ascending and Descending modes
if (value == sortExp)
sortDirection = (sortDirection == 'ASC')? 'DESC' : 'ASC';
else
sortDirection = 'ASC';
sortExp = value;
}
}
public String getSortDirection()
{
//if not column is selected
if (sortExpression == null || sortExpression == '')
return 'ASC';
else
return sortDirection;
}
public void setSortDirection(String value)
{
sortDirection = value;
}
public List<Lead_Inspector__c> getAccounts() {
if(startDate!=null && endDate!=null)
{
system.debug('***********************Date Picker of getAccounts() ***************************'+startDate+'*****************'+endDate);
accounts = [SELECT id,name,Date_Time_first_visit__c,Hits__c, Lead__c, Converted_To_Lead__c, Branch__c,Converted_To_Account__c, Total_Hits__c, Duration__c, Origin__c, Rating__c, Lead_Score__c, Tags__c FROM Lead_Inspector__c WHERE Date_Time_first_visit__c >=:startDate AND Date_Time_first_visit__c <=:endDate+1];
if(rowNum!= null)
{
System.debug('DAta before removal is: '+ accounts);
accounts.remove(rowNum);
System.debug('DAta after removal is: '+ accounts);
}
return accounts;
// accounts = Database.query('Select id,name, Date_Time_first_visit__c, Lead__c, Branch__c,Converted_To_Account__c, Converted_To_Lead__c, Total_Hits__c, Duration__c, Origin__c, Rating__c,Lead_Score__c, Tags__c FROM Lead_Inspector__c where Lead__c like \'%'+searchstring+'%\'order by ' + sortFullExp + ' limit 1000');
}
if(searchstring!=null && selectedCountry!=null)
{
// system.debug('***********************inside else ifffff ***************************'+selectedCountry+'TESSSSSSST'+searchstring);
string sortFullExp = sortExpression + ' ' + sortDirection;
selectedValues=selectedCountry;
//query the database based on the sort expression
// accounts = Database.query('Select id, Date_Time_first_visit__c, Lead__c, Branch__c, Converted_To_Lead__c, Total_Hits__c, Duration__c, Origin__c, Rating__c,Lead_Score__c, Tags__c FROM Lead_Inspector__c where Lead__c like \'%'+searchstring+'%\' order by ' + sortFullExp + ' limit 1000');
String qs = 'Select id,name, Date_Time_first_visit__c,Hits__c, Lead__c, Branch__c,Converted_To_Account__c, Converted_To_Lead__c, Total_Hits__c, Duration__c, Origin__c, Rating__c,Lead_Score__c, Tags__c FROM Lead_Inspector__c where ' +selectedCountry+' Like \'%'+searchstring+'%\' order by ' + sortFullExp;
System.debug('Query string is: '+ qs);
accounts = database.query(qs);
if(rowNum!= null)
{
System.debug('DAta before removal is: '+ accounts);
accounts.remove(rowNum);
System.debug('DAta after removal is: '+ accounts);
return accounts;
}
else
return accounts;
}
else
{
/*
system.debug('***********************inside else***************************'+selectedCountry);
string sortFullExp = sortExpression + ' ' + sortDirection;
selectedValues=selectedCountry;
//query the database based on the sort expression
accounts = Database.query('Select id,name,Hits__c, Date_Time_first_visit__c, Lead__c, Branch__c,Converted_To_Account__c, Converted_To_Lead__c, Total_Hits__c, Duration__c, Origin__c, Rating__c,Lead_Score__c, Tags__c FROM Lead_Inspector__c order by ' + sortFullExp + ' limit 1000');
return accounts;
*/
if(size!=null)
{
setCon.setpagesize(size);
System.debug('******in if*******'+(List<Lead_Inspector__c>)setCon.getRecords());
return (List<Lead_Inspector__c>)setCon.getRecords();
}
else{
setCon.setpagesize(10);
System.debug('******in else*******'+(List<Lead_Inspector__c>)setCon.getRecords());
return (List<Lead_Inspector__c>)setCon.getRecords();
}
}
}
public pageReference refresh() {
setCon = null;
getAccounts();
setCon.setPageNumber(1);
return null;
}
public pageReference show()
{
getAccounts();
return null;
}
public pageReference searchStr(){
getAccounts();
return null;
}
public void displaingTable(){
system.debug('Start Date:'+startDate);
system.debug('End Date:'+endDate);
getAccounts();
}
public pagereference refreshPage(){
getAccounts();
system.debug('***********************Inside refreshPage***************************'+size);
return null;
}
// ***********inline edit function*******
public pagereference saveAccounts(){
try{
update accounts;
PageReference nextpage= new PageReference('https://eu6.salesforce.com/apex/LeadInspectorTest');
nextpage.setredirect(true);
return nextpage;
}
catch(Exception e){
string message='Data Base error during saving…';
ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.ERROR, message));
return null;
}
}
public PageReference iWantMyJSValues() {
// valueOne = Apexpages.currentPage().getParameters().get('one');
system.debug('******************valueOne******************'+valueOne);
return null;
}
}