+ Start a Discussion
balu palavalasabalu palavalasa 

error in line 0

hi all, 

I have witten a vf code in which it shows "Error in ine 0 " i could not understand whats the error is. Please halp me in sorting out the issue.
Below is my code: 
------------------------
<apex:page standardController="Account" recordSetVar="accs">
<style>
.activetab {background-color : #9ACD32 ; color:white;}
.inactivetab {backgound-color :  #DCDCDC ; color:white;}
</style>

<apex:tabpanel switchtype="Client" selectedtab="Accounts" id="tabpanel1"
tabclass="activetab" inactivetabclass="inactivetab">
<apex:tab label="Account Details" name="Accounts" id="1"> 

 <apex:pageblock title="All Accounts"> 
 <apex:pageblocktable value="{!accs}" var="a">
 <apex:column title="Action" >
 <apex:outputLink value="{!URLFOR($Action.Account.Edit,a.id)}">Edit
 </apex:outputLink>&nbsp;|&nbsp;
 <apex:outputlink value="{!URLFOR($Action.Account.Delete,a.id)}">Del</apex:outputlink>
 </apex:column>
 <apex:column value="{!a.Name}"/>
 <apex:column value="{!a.Phone}"/> 
 </apex:pageblocktable>
 
 </apex:pageblock>
 
 </apex:tab>
 </apex:tabpanel>
 
</apex:page>

Error is :

Error in line 0

 
Best Answer chosen by balu palavalasa
Pradeep SinghPradeep Singh
<apex:page Controller="selectlistoption">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >        
            <apex:outputlabel value="Enter Country"/>
            <apex:inputText value="{!str}" label="Country"/>
            <apex:commandButton value="Add" action="{!addCountry}" reRender="None"/> 
            <apex:commandButton value="submit" rerender="showdetails"/>
        </apex:pageBlockSection>    
        
        <apex:pageBlockSection id="showdetails">      
            <apex:selectlist size="1" value="{!selectedstr}">           
                <apex:selectoptions value="{!country}"/>
            </apex:selectlist>       
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
 
</apex:page>

-----------------
public class selectlistoption {
    
  
      public string str{get;set;}  
      public string selectedstr{get;set;}   
      public list<selectoption> country{get;set;}
       
    public selectlistoption (){
        str = '';
        country = new list<selectoption>();
    }
    
    public void addCountry()
    {
        system.debug('-----' + str);
        country.add(new selectoption(str,str));       
    }
    
   

}

You were using str for both the selected one and the inputtext.

All Answers

Pradeep SinghPradeep Singh
Hi, please change the value of id tag (id="1") of <apex:tag> to somename like id ="tagId" and save. Just did and it got saved.
Please let me know if you still face any issue.
If this solves the issue,please mark it as best answer.
balu palavalasabalu palavalasa
hi pradeep,

thank you for your eply.It is working now.
balu palavalasabalu palavalasa
hi pradeep,

i have another doubt. I've witten a code which has to take input from an input box and add the input to select options until submit button is pressed.
that is as long as i give input and click on add button it should keep on adding the given input texts to select option list. and if i click on submit button it should display the selectoptions list.

vf code :

<
apex:page Controller="selectlistoption">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
         
            <apex:outputlabel value="Enter Country"/>
            <apex:inputText value="{!str}"/>
            <apex:commandButton value="Add" action="{!setCountry}"/> 
            <apex:commandButton value="submit" rerender="showdetails"/>
        </apex:pageBlockSection>    
        
    <apex:pageBlockSection id="showdetails">
      
            <apex:selectlist size="1" value="{!str}">
           
                <apex:selectoptions value="{!country}"/>
                 </apex:selectlist>
        
 
        
        </apex:pageBlockSection>
                    </apex:pageBlock>
    </apex:form>
 
</apex:page>

Controller :

public class selectlistoption {
    
  
      public   string str{get;set;}
    
       public  list<selectoption> country{get;set;}
    
    public pagereference setCountry()
    {
         
        country.add(new selectoption(str,str));
        return null;
       
    }
    
   

}

Error :

System.NullPointerException: Argument 1 cannot be null
Error is in expression '{!setCountry}' in component <apex:commandButton> in page selectlist: Class.selectlistoption.setCountry: line 11, column 1
Class.selectlistoption.setCountry: line 11, column 1

 
Pradeep SinghPradeep Singh
<apex:page Controller="selectlistoption">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >        
            <apex:outputlabel value="Enter Country"/>
            <apex:inputText value="{!str}" label="Country"/>
            <apex:commandButton value="Add" action="{!addCountry}" reRender="None"/> 
            <apex:commandButton value="submit" rerender="showdetails"/>
        </apex:pageBlockSection>    
        
        <apex:pageBlockSection id="showdetails">      
            <apex:selectlist size="1" value="{!selectedstr}">           
                <apex:selectoptions value="{!country}"/>
            </apex:selectlist>       
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
 
</apex:page>

-----------------
public class selectlistoption {
    
  
      public string str{get;set;}  
      public string selectedstr{get;set;}   
      public list<selectoption> country{get;set;}
       
    public selectlistoption (){
        str = '';
        country = new list<selectoption>();
    }
    
    public void addCountry()
    {
        system.debug('-----' + str);
        country.add(new selectoption(str,str));       
    }
    
   

}

You were using str for both the selected one and the inputtext.
This was selected as the best answer
balu palavalasabalu palavalasa
thank you pradeep.