首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >加载弹出式窗口时的错误消息

加载弹出式窗口时的错误消息
EN

Stack Overflow用户
提问于 2012-08-13 11:45:26
回答 1查看 865关注 0票数 1

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

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

我的问题是,当我试图在第一个弹出窗口中插入值时,我得到了错误meg,即“您必须输入A值”,但即使这样,我也输入了该值。因此,我注释了第二个弹出,然后它运行良好,但是当第二个弹出式弹出取消注释时,这个错误被抛出事件,值被输入。第二个弹出窗口在第一个字段和其他字段中包含相同的两个字段。

有人能帮我找到这个错误的解决方案吗。

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2012-08-13 13:56:37

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

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

顶点级:

代码语言:javascript
复制
public YourObject AC1 { get; set; }
public YourObject AC2 { get; set; }

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

第一个弹出窗口:

代码语言:javascript
复制
<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>

第二个弹出窗口:

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11933660

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档