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

Visualforce Error Help for this Page System.NullPointerException: Argument 1 cannot be null
<apex:page standardcontroller="MPI_Category__c" extensions="MPIController1" action="{!autoRun}"
tabStyle="Contact">
<style type="text/css">
.m1{
width: 60px;
}
</style>
<apex:form >
<apex:actionFunction name="rerenderSg1" rerender="sg1sSelectList1" >
<apex:param name="firstParam" assignTo="{!catalog}" value="" />
</apex:actionFunction>
<apex:sectionHeader title="MPI {!mpi.name}" subtitle="MPI Item Selection" />
<apex:pageBlock >
<table><tbody>
<tr>
<th>Catalog</th>
<td>
<apex:selectList id="catalog" styleclass="std" size="1"
value="{!catalog}" onchange="rerenderSg1(this.value)" >
<apex:selectOptions value="{!catalogsSelectList}"/>
</apex:selectList>
</td>
<th>Segment1</th>
<td>
<apex:selectList id="sg1sSelectList1" styleclass="std" size="1"
value="{!sg1}" >
<apex:selectOptions value="{!sg1sSelectList1}"/>
</apex:selectList>
</td>
</tr>
</tbody>
</table>
</apex:pageblock>
</apex:form>
</apex:page>
public with sharing class MPIController1 {
public MPI_Category__c mpi {get;set;}
public MPI_Category__c mpiObject {get;set;}
public MPIProducts__c mpi1 {get;set;}
public Boolean sg4Bool {get;set;}
public Boolean sg3Bool {get;set;}
public Boolean sg2Bool {get;set;}
public Boolean sg1Bool {get;set;}
ApexPages.StandardController controller;
Public Boolean ShowpageBlockFlag{get;set;}
public MPIController1(ApexPages.StandardController controller) {
this.controller=controller;
mpi=[Select m.Name from MPI_Category__c m where m.id= :ApexPages.currentPage().getParameters().get('id')];
mpiObject = new MPI_Category__c ();
mpiObject = (MPI_Category__c )controller.getRecord();
}
public PageReference autoRun() {
return null;
}
// Variables to store country and state selected by user
public String catalog {get; set;}
public String sg1 {get;set;}
public String sg2 {get;set;}
public String sg3 {get;set;}
public String sg4 {get;set;}
// Generates catalog dropdown from country settings
public List<SelectOption> getCatalogsSelectList()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('', '--SelectOne--'));
// Find all the catalogs in the custom setting
List<product2> prd= [select id, name, MPI_Catalog__c,MPI_Sg1__c,MPI_Sg2__c,MPI_Sg3__c,MPI_Sg4__c from product2 where MPI_Catalog__c!=null];
set<String> s= new Set<String>();
for(Product2 pr:prd)
{
s.add(pr.MPI_Catalog__c);
}
List<String> list1= new List<String>();
list1.addAll(s);
list1.sort();
for(String s1:list1)
{
options.add(new SelectOption(s1, s1));
}
return options;
}
public List<SelectOption> getSg1sSelectList1() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('', '--SelectOne--'));
System.debug('catalog is -----'+catalog);
List<product2> allsg1 =[select MPI_Catalog__c,MPI_Sg1__c from product2 where MPI_Catalog__c=:catalog];
Map<String,String> allSgValues= new Map<String,String>();
for(Product2 p:allsg1)
{
if(p.MPI_Catalog__c==this.catalog)
{
allSgValues.put(p.MPI_Catalog__c,p.MPI_Sg1__c);
options.add(new SelectOption(p.MPI_Catalog__c, p.MPI_Sg1__c));
}
System.debug('allSgValues are-----'+allSgValues);
}
// If no states are found, just say not required in the dropdown.
if (options.size() > 0) {
options.add(0, new SelectOption('', '--Select One--'));
} else {
options.add(new SelectOption('', 'Not Required'));
}
return options;
}
}
this is my page and controller, getSg1sSelectList1() is not renedering properly.so that Argument 1 canot be null cmg. help me on this
tabStyle="Contact">
<style type="text/css">
.m1{
width: 60px;
}
</style>
<apex:form >
<apex:actionFunction name="rerenderSg1" rerender="sg1sSelectList1" >
<apex:param name="firstParam" assignTo="{!catalog}" value="" />
</apex:actionFunction>
<apex:sectionHeader title="MPI {!mpi.name}" subtitle="MPI Item Selection" />
<apex:pageBlock >
<table><tbody>
<tr>
<th>Catalog</th>
<td>
<apex:selectList id="catalog" styleclass="std" size="1"
value="{!catalog}" onchange="rerenderSg1(this.value)" >
<apex:selectOptions value="{!catalogsSelectList}"/>
</apex:selectList>
</td>
<th>Segment1</th>
<td>
<apex:selectList id="sg1sSelectList1" styleclass="std" size="1"
value="{!sg1}" >
<apex:selectOptions value="{!sg1sSelectList1}"/>
</apex:selectList>
</td>
</tr>
</tbody>
</table>
</apex:pageblock>
</apex:form>
</apex:page>
public with sharing class MPIController1 {
public MPI_Category__c mpi {get;set;}
public MPI_Category__c mpiObject {get;set;}
public MPIProducts__c mpi1 {get;set;}
public Boolean sg4Bool {get;set;}
public Boolean sg3Bool {get;set;}
public Boolean sg2Bool {get;set;}
public Boolean sg1Bool {get;set;}
ApexPages.StandardController controller;
Public Boolean ShowpageBlockFlag{get;set;}
public MPIController1(ApexPages.StandardController controller) {
this.controller=controller;
mpi=[Select m.Name from MPI_Category__c m where m.id= :ApexPages.currentPage().getParameters().get('id')];
mpiObject = new MPI_Category__c ();
mpiObject = (MPI_Category__c )controller.getRecord();
}
public PageReference autoRun() {
return null;
}
// Variables to store country and state selected by user
public String catalog {get; set;}
public String sg1 {get;set;}
public String sg2 {get;set;}
public String sg3 {get;set;}
public String sg4 {get;set;}
// Generates catalog dropdown from country settings
public List<SelectOption> getCatalogsSelectList()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('', '--SelectOne--'));
// Find all the catalogs in the custom setting
List<product2> prd= [select id, name, MPI_Catalog__c,MPI_Sg1__c,MPI_Sg2__c,MPI_Sg3__c,MPI_Sg4__c from product2 where MPI_Catalog__c!=null];
set<String> s= new Set<String>();
for(Product2 pr:prd)
{
s.add(pr.MPI_Catalog__c);
}
List<String> list1= new List<String>();
list1.addAll(s);
list1.sort();
for(String s1:list1)
{
options.add(new SelectOption(s1, s1));
}
return options;
}
public List<SelectOption> getSg1sSelectList1() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('', '--SelectOne--'));
System.debug('catalog is -----'+catalog);
List<product2> allsg1 =[select MPI_Catalog__c,MPI_Sg1__c from product2 where MPI_Catalog__c=:catalog];
Map<String,String> allSgValues= new Map<String,String>();
for(Product2 p:allsg1)
{
if(p.MPI_Catalog__c==this.catalog)
{
allSgValues.put(p.MPI_Catalog__c,p.MPI_Sg1__c);
options.add(new SelectOption(p.MPI_Catalog__c, p.MPI_Sg1__c));
}
System.debug('allSgValues are-----'+allSgValues);
}
// If no states are found, just say not required in the dropdown.
if (options.size() > 0) {
options.add(0, new SelectOption('', '--Select One--'));
} else {
options.add(new SelectOption('', 'Not Required'));
}
return options;
}
}
this is my page and controller, getSg1sSelectList1() is not renedering properly.so that Argument 1 canot be null cmg. help me on this
i have understood that you are selecting the values and adding the required values to the list using for loop...
make sure that the selected list does not have any empty or null values in it...
Check your model for that...
All Answers
i have understood that you are selecting the values and adding the required values to the list using for loop...
make sure that the selected list does not have any empty or null values in it...
Check your model for that...
got it thank you, query is returning null and adding to the select list. so that it is cmg.
can you plz mark it as a best answer... as some one else can easily get access to this issue...
Thanks...