• zezuru
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hey guys,

I am like two weeks into visualforce development and am stuck. I have a page with a datatable. one of the columns is basically a link to another popup page which returns selected value from a list. Basically this replicates visualforce lookup for opportunities but with a filter on accountid and an added functionality to create new opportunity if none exists.

 

The problem: everything works well in firefox. The Save option does nothing in IE9. Clicking it like ten times return the error basically saying that all fields are null and so the insert fails. I have set the IE security/privacy configurations as suggested in the online help. I have also tried emulating IE8.

 

The page:

 

<apex:page controller="LookupPopupController" sidebar="false" showheader="false">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<script language="javascript">
   var btnGo = document.getElementById("{!$Component.form.block.section.btnGo}");
   window.onload = new function() 
   { 
      window.focus(); 
      var ele=document.getElementById('{!$Component.form.block.section.query}');
      if (ele)
      {
         ele.focus();
      }
   }
   
   function fillIn(name, id)
   {
      var winMain=window.opener;
      if (null==winMain)
      {
         winMain=window.parent.opener;
      }
      var ele=winMain.document.getElementById('{!$CurrentPage.parameters.namefield}');
      ele.value=name;
      ele=winMain.document.getElementById('{!$CurrentPage.parameters.idfield}');
      ele.value=id;
      CloseWindow();
   }

   function CloseWindow()
   {
      var winMain=window.opener;
      if (null==winMain)
      {
         winMain=window.parent.opener;
      }
      winMain.closeLookupPopup();
   }
</script>

  <apex:messages />
  <apex:form id="form" >  

     <div style="width 100%">
        <apex:pageBlock title="Lookup" id="block">

          <apex:pageBlockSection id="section">
              Filter by Opportunity Name<br/>
              <apex:inputText value="{!query}" id="query"/> 
              <apex:commandButton id="btnGo" value="Search" action="{!runQuery}"/>
          </apex:pageBlockSection>

          <apex:pageBlockSection columns="1">
              <apex:pageBlockTable value="{!Opportunitys}" var="opvar">
                <apex:column headerValue="Name">
                  <apex:outputLink value="#" onclick="fillIn('{!opvar.Name}', '{!opvar.id}')">{!opvar.Name}</apex:outputLink>       
                </apex:column>
                <apex:column headerValue="Quote" value="{!opvar.Quote_Number__c}"/>
                <apex:column headerValue="Amount" value="{!opvar.amount}"/>
                <apex:column headerValue="Probability" value="{!opvar.probability}"/>
              </apex:pageBlockTable>    
          </apex:pageBlockSection>
        </apex:pageBlock>

        <apex:commandlink value="Create New Opportunity..." action="{!toggleContent}" rerender="opportunitypanel"></apex:commandlink>     

        <apex:outputpanel id="opportunitypanel">
        <apex:actionStatus startText="requesting..." stopText="" id="myStatus" />
        <style type="text/css">  
                .toggleContent {display:{!if(showContent,"block","none")};}  
        </style> 
        <div class="toggleContent"> 
        <apex:pageBlock title="New Opportunity">
          <apex:pageBlockSection collapsible="true">
                <apex:inputField value="{!ops.Name}" required="false"/>
                <apex:outputField value="{!ops.AccountId}" />
                <apex:inputField value="{!ops.CloseDate}" required="false"/>
                <apex:inputField value="{!ops.ForecastcategoryName}" required="false"/>
                <apex:inputField value="{!ops.StageName}" required="false"/>
            </apex:pageBlockSection>
          <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" oncomplete="fillIn('{!ops.Name}', '{!ops.Id}')" rerender="error"/>
          </apex:pageBlockButtons>
          </apex:pageBlock>
          </div>
          </apex:outputpanel>   
         </div>
         <div>
             <apex:commandbutton value="Close" onclick="CloseWindow();">  
             </apex:commandbutton> 
         </div>

   </apex:form>
</apex:page>

It is the  <apex:commandButton value="Save" action="{!save}" oncomplete="fillIn('{!ops.Name}', '{!ops.Id}')" rerender="error"/>  code that is unresponsive in IE9.

 

and here's the apex class:

public with sharing class LookupPopupController
{
    public String query {get; set;}
    public String AccId {get; set;}
    public List<Opportunity> Opportunitys {get; set;}
    public Opportunity ops {get; set;}    
    public Boolean showContent { get; set; }  

    public PageReference toggleContent() {  
        if(showContent){  
            showContent = false;  
        }  
        else{  
            showContent = true;  
        }  
        return null;  
    }  
    public PageReference runQuery()
    {
        String query1;
        if (query == null){
           Opportunitys=[select id, name, quote_number__c, amount, probability from Opportunity where AccountId = :AccId];
           }
        else{
           query1 = '%'+query+'%';
           Opportunitys=[select id, name, quote_number__c, amount, probability from Opportunity where AccountId = :AccId and name like :query1];
           }
        return null;
    }
    public LookupPopupController(){
        showContent = false;  
        AccId=System.currentPagereference().getParameters().get('AccId');
        runQuery();
        ops = new Opportunity();
        ops.AccountId = AccId;
    }
    public PageReference save(){
        insert ops;
        return null;
    }
}

 

Thanks in advance for any help..

  • September 13, 2012
  • Like
  • 0