1

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

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

我的问题是,当我尝试在第一个弹出窗口中插入值时,我收到错误消息“你必须输入一个值”,但即便如此我输入了值。所以我评论了第二个弹出窗口然后它工作正常但是当第二个弹出窗口未注释时抛出这个错误事件输入值。第二个弹出窗口包含与第一个相同的 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>
4

1 回答 1

0

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

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

顶点类:

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>
于 2012-08-13T13:56:37.973 回答