来自控制器的Custon对象字段未使用顶点:VF页面中的outputfield显示

时间:2016-05-01 09:48:31

标签: controller salesforce visualforce

  

我正在使用标签在VF页面中显示控制器的自定义对象字段。从picklist中选择值(使用后实现)后,我将标签放入控制器中DB的retreive自定义对象。现在我想在VF页面中显示这个RETREIVED对象的字段onchange of picklist value。那些值没有显示出来。   我知道这是非常基本的,请帮我清除任何愚蠢的错误!

     

VF页面:

<apex:form>
        <apex:pageblock >
            <apex:pageBlocksection title="Attribute Details">
                <apex:tabpanel switchtype="client">
                    <apex:tab label="Script 1" id="s1" labelWidth="90px">
                        <h1>
                            Choose Script:
                        </h1>
                        <apex:selectlist value="{!selectedValue}" size="1" id="selectID">
                            <apex:selectOptions value="{!scriptoptions}" />
                        </apex:selectlist>
                        <br/>
                        <apex:outputPanel id="thisPanel">
                            <apex:actionSupport event="onchange" action="{!setValues}" rerender="thisPanel" />
                            <apex:actionStatus startText="fetching related values..."
                                               stopText="" id="actionStatus"/>
                            <outputfield label="Executioner" value="{!valueResult.Executioner_Emp_ID__c}"/>
                            <br/>
                            <outputfield label="Planner" value="{!valueResult.Planner_Emp_ID__c}"/>
                            <br/>
                            <outputfield label="Reviewer" value="{!valueResult.Reviewer_Emp_ID__c}"/>
                        </apex:outputPanel>
                    </apex:tab>.....
  

控制器:

public class ScriptAttributesController 
{

    public String setValues { get; set; }
    public List<Test_script__c> scriptListWithValues = [select name, id, Executioner__c, Planner__c, Reviewer__c from Test_Script__c];
    public static Test_Script__c valueResult {get;set;}
    public String selectedValue {get;set;}

    //public Test_Script__c returnedTestScript {get;set;}

    public void ScriptAttributesController()
    {
    }

    public List<SelectOption> getScriptoptions()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('select a value','select a value'));
        for(Test_Script__c s: scriptListWithValues )
        {
            options.add(new SelectOption(s.id,s.name));
        }
        return options;
    }

        public void setValues()
    {
        system.debug('ValueResult: '+valueResult);
        system.debug('selectedValue: '+selectedValue);
        valueResult=[select name, id, Executioner_Emp_ID__c, Planner_Emp_ID__c, Reviewer_Emp_ID__c, Iteration__c from Test_Script__c where id=:selectedValue limit 1];
        system.debug('ValueResult: '+valueResult);
    }

1 个答案:

答案 0 :(得分:0)

有两个错误:

  1. 首先, apex:actionSupport 标记应位于 apex:selectlist 中。此外,如果要显示当前操作状态,则应在 apex:actionSupport 中使用 status 属性。

  2. 另一个是你应该使用 apex:outputfield 而不是简单的 outputfield

  3. 这是固定代码:

    <apex:form>
            <apex:pageblock >
                <apex:pageBlocksection title="Attribute Details">
                    <apex:tabpanel switchtype="client">
                        <apex:tab label="Script 1" id="s1" labelWidth="90px">
                            <h1>
                                Choose Script:
                            </h1>
                            <apex:selectlist value="{!selectedValue}" size="1" id="selectID">
                                <apex:selectOptions value="{!scriptoptions}" />
                                <apex:actionSupport event="onchange" action="{!setValues}" rerender="thisPanel" status="actionStatus"/>
                            </apex:selectlist>
                            <br/>
                            <apex:outputPanel id="thisPanel">
                                <apex:actionStatus startText="fetching related values..."
                                                   stopText="" id="actionStatus"/>
                                <apex:outputfield label="Executioner" value="{!valueResult.Executioner_Emp_ID__c}"/>
                                <br/>
                                <apex:outputfield label="Planner" value="{!valueResult.Planner_Emp_ID__c}"/>
                                <br/>
                                <apex:outputfield label="Reviewer" value="{!valueResult.Reviewer_Emp_ID__c}"/>
                            </apex:outputPanel>
                        </apex:tab>.....