function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
amar joshiamar joshi 

both the code are same,one is working another is not working

hi all

i m stuck with funny error my two page's code are same, one is working another is not working

1 working page:
      in this page i m using the selectoption compontant and printing the selected item's id


code is bellow
Code:
//// page code /////
 <apex:page controller="sampleCon">
    <apex:form >
        <apex:selectlist value="{!countries}" title="Choose a country" size="1" required="true">
            <apex:selectOptions value="{!items}" />
        </apex:selectlist><br/>
        <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
    </apex:form>
    <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="testing...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    <p>You have selected:</p>
                    <apex:variable var="c" value="{!countries}">
                    <p>You have selected12333:</p>
                   <apex:outputtext value="{!c}"/>
                    </apex:variable>
                    
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
 </apex:page>


///// controller code /////
public class sampleCon {
 
    String co;
 
    public PageReference test() {
        return null;
    }
 
    public List<SelectOption> getItems() {
    list<account> ac = new account[]{};
    ac = [select id,name from account where name = 'MAKHARIA MACHINERI P.L.'];
     List<SelectOption> options = new List<SelectOption>();
    for(integer i=0;i<ac.size();i++)
       {
String m='hello'+ ac[i].name ;  
        options.add(new SelectOption(ac[i].id,m));
       }
        return options;
    }
 
    public String getCountries() {
        return co;
    }
 
    public void setCountries(String c) {
        this.co = c;
    }
 
 }



 in this code when i press test button i will get the id of the selected item which is in  the list box write now


Not Working code::
         the same thing is here when i press test button i dont get the selected item which is in that list box write now.

code is bellow
Code:
/////page//////
<apex:page controller="convert1" tabstyle="lead">
   <apex:sectionHeader title="Convert Lead"subtitle="{!lead.owner.name}"/>
           Leads can be converted to accounts, contacts, opportunities, and followup tasks.
          <br>You should only convert a lead once you have identified it as qualified.</br>
           <br>After this lead has been converted, it can no longer be viewed or edited as a lead, but can be viewed in lead reports.</br>
            <br> </br>
        <apex:form >
          <apex:pageBlock mode="edit">
             <apex:pageblockButtons >
               <apex:commandButton action="{!convertLead}" value="convert" onclick="Msg()" />
             </apex:pageblockButtons>
             <apex:pageBlockSection title="Convert Lead">
                    <apex:inputfield value="{!lead.Record_Owner__c}"/>
                    <apex:pageblockSectionItem ></apex:pageblockSectionItem>
                       <apex:pageBlockSectionItem >
                         Converted Status
                         <apex:selectlist value="{!string}" size="1" required="True">
                         <apex:selectoption itemvalue="Qualified" itemlabel="qualified"/>
                         </apex:selectlist>
                       </apex:pageBlockSectionItem>
                       <apex:pageblockSectionItem ></apex:pageblockSectionItem>
                       <apex:pageBlockSectionItem >
                        Account name
                          <apex:selectlist value="{!countries}" title="Choose a country" size="1" required="true">
                          <apex:selectOptions value="{!items}" />
                        </apex:selectlist>
                       </apex:pageblocksectionitem>
                       
                         <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
    
    <apex:outputPanel id="out">
        <apex:actionstatus id="status" startText="testing...">
            <apex:facet name="stop">
                <apex:outputPanel >
                    <p>You have selected:</p>
                    <apex:variable var="c" value="{!countries}">
                    <p>You have selected12333:</p>
                   <apex:outputtext value="{!c}"/>
                    </apex:variable>
                    
                </apex:outputPanel>
            </apex:facet>
        </apex:actionstatus>
    </apex:outputPanel>
                       
                       </apex:pageblocksection>
                       <apex:pageblocksection title="Task Information">
                            <apex:inputfield value="{!task.subject}"/>
                            <apex:inputfield value="{!task.Branch_Name__c}" required="True"/>
                            <apex:inputfield value="{!task.ActivityDate}"/>
                            <br><apex:inputfield value="{!task.Description}"/></br>
                      </apex:pageblocksection>
                      <apex:pageBlockSection title="Other Information">
                           <apex:inputfield value="{!task.Priority}"/>
                           <br><apex:inputfield value="{!task.Status}"/></br>
                      </apex:pageBlockSection>
                      <apex:pageblockSection title="Reminder">
                            <apex:inputfield value="{!task.ReminderDateTime}"/>
                       </apex:pageblockSection>
          </apex:pageBlock>
        </apex:form>
</apex:page>

/////controller/////
global class convert1{ 
    

    public PageReference test() {
        return null;
    }


    
//-------------------------------------------------------------------------------------------       
String s ='Qualified';
public String getstring()
{
   return s;
}
public void setstring(String s)
{
   this.s = s;
}

//this part is for getting the account list from database
 String co;
 public String getCountries() {
        return co;
    }
 
    public void setCountries(String c) {
        this.co = c;
    }
 


  String s1;
  lead l;
  public List<SelectOption> getItems() 
    {
       l = [select company from lead where id = :ApexPages.currentPage().getParameters().get('id')];
       list<Account> ac = new account[]{};
       ac = [select id,name from account where name = :l.company];
       List<SelectOption> options = new List<SelectOption>();
       String s4 = '--none--';
         if(ac.size()>=1)
           {
         
              String s2 = 'Create a new Account : '+l.company;
              options.add(new selectOption('03',s4));
              options.add(new SelectOption('01',s2));
                for(Integer i=0;i<ac.size();i++)
                {
                  String s1='Attach to existing :'+ac[i].name;
                  options.add(new SelectOption(ac[i].id,s1));   
                }
          }
            else
            {
               options.add(new selectOption('03',s4));
               String s3 = 'Create a new Account : '+l.company;
               options.add(new SelectOption('02',s3));
            }
             return options;
     }
   
//--The convert button logic--//
     public PageReference convertLead() 
     {
        return null;
     }

//-This logic is for getting the task information from database - //
        Task task;      
         public Task gettask()
          {
            if (task == null)
            task = new Task();
            return task;
          }

//--This is logic geting the lead information as well as record owner from the database--//
          public Lead getLead() 
          {
             Lead a;
             a= [select owner.id,owner.type,owner.name,Record_Owner__c,company from Lead 
                           where id = :ApexPages.currentPage().getParameters().get('id')]; 
             a.Record_Owner__c=a.owner.id;
             return a;
         }
}

 

please help me out
thanks in advance


Message Edited by amar joshi on 09-22-2008 10:26 AM