2012-08-13 144 views
1

我在2按鈕上創建了2個彈出窗口。並有一個對象(AC)。在兩個彈出我有一些領域插入。加載彈出窗口時出現錯誤消息

在第一個彈出窗口中包含A.name1,A.name2,A.date,A.Edate,A.Pjt等,並在第二個彈出窗口中顯示字段A.Name1,A.name2。 A.Name1和A.name2是對象中必需的字段。

我的問題是,當我嘗試在第一個彈出窗口中插入值時,出現錯誤「我必須輸入一個值」,但即使如此我輸入了值。所以我評論第二彈出,然後它工作正常,但當第二彈出是取消註釋這個錯誤是引發事件的價值進入。第二個彈出框在第一個和其他一些字段中包含相同的兩個字段。

任何人都可以幫我找到這個錯誤的解決方案。

<apex:outputPanel id="tstpopup"> 
    <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/> 
     <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}"> 
     <apex:pageblock > 
      <apex:pageblocksection > 
       <apex:pageblocksectionitem > 
       <apex:outputlabel value="name1: " /> 
       <apex:inputfield id="proj" value="{!AC.name1__c}" /> 
       </apex:pageblocksectionitem> 
       <apex:pageblocksectionitem > 
       <apex:outputlabel value="name2: " /> 
       <apex:inputfield id="role" value="{!AC.name2__c}" /> 
       </apex:pageblocksectionitem> 
       <p/> 
       <apex:commandbutton value="Pencil in a New Project" action="{!save}" /> 
       <apex:commandbutton value="Cancel" action="{!closePopup}" immediate="true" /><br/><br/><br/> 
       </apex:pageblocksection> 
       </apex:pageblock> 
     </apex:outputPanel> 
    </apex:outputPanel> 


<apex:outputPanel id="tstpopup1"> 
    <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/> 
     <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}"> 
     <apex:pageblock > 
      <apex:pageblocksection > 
       <apex:pageblocksectionitem > 
       <apex:outputlabel value="name1: " /> 
       <apex:inputfield id="proj1" value="{!AC.name1__c}" /> 
       </apex:pageblocksectionitem><p/> 
       <apex:pageblocksectionitem > 
       <apex:outputlabel value="Date: " /> 
       <apex:inputfield id="sd" value="{!AC.Date__c}" /> 
       </apex:pageblocksectionitem> 
       <apex:pageblocksectionitem > 
       <apex:outputlabel value="EDate: " /> 
       <apex:inputfield id="ed" value="{!AC.EDate__c}" /> 
       </apex:pageblocksectionitem> 
       <apex:pageblocksectionitem > 
       <apex:outputlabel value="Proj: " /> 
       <apex:inputfield id="pl" value="{!AC.Pjt__c}" /> 
       </apex:pageblocksectionitem> 
       <apex:pageblocksectionitem > 
       <apex:outputlabel value="Charge: " /> 
       <apex:inputfield id="charge" value="{!AC.Charge__c}" /> 
       </apex:pageblocksectionitem> 
       <apex:pageblocksectionitem > 
       <apex:outputlabel value="Name2: " /> 
       <apex:inputfield id="role1" value="{!AC.name2__c}" /> 
       </apex:pageblocksectionitem> 
       <apex:pageblocksectionitem > 
       <apex:outputlabel value="time: " /> 
       <apex:inputfield id="overtime" value="{!AC.time__c}" /> 
       </apex:pageblocksectionitem>     
       </apex:pageblocksection> 
       <apex:commandbutton value="Assign to a New Project" action="{!assign}" /> 
       <apex:commandbutton value="Cancel" action="{!closePopup}" immediate="true" /><br/><br/><br/> 
       </apex:pageblock> 
     </apex:outputPanel> 
    </apex:outputPanel> 
+0

莫非你提供第二次彈出? – mast0r 2012-08-13 13:41:44

回答

0

我想這是因爲你在兩個彈出窗口中有相同的對象。如果你輸入一個值例如。 name1_ c在您的第一個彈出窗口中 - 第二個彈出窗口中的其他字段名稱1 _c仍爲空。

嘗試創建自己的對象的兩個diferent實例:

的Apex類:

public YourObject AC1 { get; set; } 
public YourObject AC2 { get; set; } 

// Constructor 
public YourClassName(){ 
    AC1 = new YourObject(); 
    AC2 = new YourObject(); 
} 

首先彈出:

<apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp1}"> 
    <apex:pageblock > 
     <apex:pageBlockButtons> 
      <apex:commandbutton value="Assign to a New Project" action="{!assign1}" /> 
      <apex:commandbutton value="Cancel" action="{!closePopup1}" immediate="true" />    
     </apex:pageBlockButtons> 
     <apex:pageblocksection > 
      <apex:pageblocksectionitem > 
       <apex:outputlabel value="name1: " /> 
       <apex:inputfield id="proj1" value="{!AC1.name1__c}" /> 
      </apex:pageblocksectionitem> 
      <apex:pageblocksectionitem > 
       <apex:outputlabel value="Name2: " /> 
       <apex:inputfield id="role1" value="{!AC1.name2__c}" /> 
      </apex:pageblocksectionitem> 
      <!-- other fields from the instance 1 of the object --> 
      .... 
     </apex:pageblocksection> 
    <apex:pageblock > 
<apex:outputPanel> 

第二彈出:

<apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp2}"> 
    <apex:pageblock > 
     <apex:pageBlockButtons> 
      <apex:commandbutton value="Assign to a Another Project" action="{!assign2}" /> 
      <apex:commandbutton value="Cancel" action="{!closePopup2}" immediate="true" />    
     </apex:pageBlockButtons> 
     <apex:pageblocksection > 
      <apex:pageblocksectionitem > 
       <apex:outputlabel value="name1: " /> 
       <apex:inputfield id="proj2" value="{!AC2.name1__c}" /> 
      </apex:pageblocksectionitem> 
      <apex:pageblocksectionitem > 
       <apex:outputlabel value="Name2: " /> 
       <apex:inputfield id="role2" value="{!AC2.name2__c}" /> 
      </apex:pageblocksectionitem> 
      <!-- other fields from the instance 2 of the object --> 
      .... 
     </apex:pageblocksection> 
    <apex:pageblock > 
    <apex:outputPanel>