加载弹出窗口时出现错误消息

时间:2012-08-13 11:45:26

标签: salesforce apex-code force.com

我在2按钮上创建了2个弹出窗口。并有一个对象(AC)。在两个弹出窗口中我都有一些要插入的字段。

在第一个弹出窗口中它包含A.name1,A.name2,A.date,A.Edate,A.Pjt等,在第二个弹出窗口中我有字段A.Name1,A.name2。 A.Name1和A.name2是对象中的必填字段。

我的问题是,当我尝试在第一个弹出窗口中插入值时,我得到错误meg“你必须输入一个值”,但即便如此我也输入了值。所以我评论了第二个弹出窗口然后它工作正常但是当第二个弹出窗口被取消注释时,输入该值时会抛出此错误。第二个弹出窗口在第一个弹出窗口中包含相同的2个字段和其他一些字段。

任何人都可以帮我找到这个错误的解决方案。

<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>

1 个答案:

答案 0 :(得分:0)

我认为这是因为你在两个弹出窗口中有相同的对象。如果输入值,例如。第一个弹出窗口中的name1_ c - 第二个弹出窗口中的另一个字段name1 _c仍为空。

尝试创建对象的两个不同实例:

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>