You need to sign in to do that
Don't have an account?
ERROR MESSAGE --> System.NullPointerException: Argument 1 cannot be null in SELECTOPTION
Hello EveryBody,
Im Creating an Apex page where i have selectList whose options want to be taken from a query
In this im Getting Error as
System.NullPointerException: Argument 1 cannot be null
and my APEX CODE IS
public class posi
{
LIST<selectoption> statusoptns =new list<selectoption>();
string valuename;
public void setvaluename(string valuename)
{
this.valuename='manager';
}
public string getvaluename()
{
return valuename;
}
string s='SELECT A VALUE';
public void setvalus()
{
for(Position__c ptr: [SELECT Position__c.Status__c from Position__c])
{
// This if statement is just to check where error is getting but i cant done it
if(ptr.Status__c==' ')
{
s='abc';
}
else
{
//If i remove the add options in this else area im getting output only 'SELECT A VALUE'
statusoptns.add(new selectoption(ptr.Status__C,ptr.Status__c));
}
}
}
public list<selectoption> getvalus()
{
statusoptns.add(new selectoption(s,s));
setvalus();
return statusoptns;
}
}
and my Visual force page code is
<apex:page controller="posi">
<apex:form >
<apex:pageBlock ><apex:pageBlockSection >
<apex:outputLabel value="VALUES" for="sel">
<apex:selectList value="{!valuename}" size="1" id="sel">
<Apex:selectOptions value="{!valus}">
</Apex:selectOptions>
</apex:selectList></apex:outputLabel>
</apex:pageBlockSection></apex:pageBlock>
</apex:form>
</apex:page>
If any Body knows how to solve it help me as soon as possible
See if this blog post helps you: http://blog.jeffdouglas.com/2008/11/25/dependent-multilevel-selectlists/
Jeff Douglas
Informa Plc
http://blog.jeffdouglas.com
Maybe because the case of the first parameter is incorrect?
statusoptns.add(new selectoption(ptr.Status__C,ptr.Status__c));
the 1st param is ptr.Status__C while the 2nd one is ptr.Status__c (small letter c)
Have you tried this? Thanks.
Regards,
Kerwin
thank u very much for ur help but i got the error by changing the following code
if(ptr.Status__c==' ')
{
s='abc';
}
above to this one
if(ptr.Status__c==null)
{
s='abc';
}