在 onchange 事件后在 visualforce 页面中显示自定义控制器数据

Displaying custom controller data in visualforce page after onchange event

I have a picklist containing names of records of an object, "Test_Script".When I select any option from a picklist("selectlist" & selectoption are used for implementing picklist),at onchange event the other fields related to that record name should be displayed on visualforce page.

VF Page:

<h1>Choose Script:</h1>
<apex:selectlist value="{!selectedValue}" size="1"onchange="{!setValues}">
                            <apex:selectOptions value="{!scriptoptions}" />
                        </apex:selectlist>
                        <br/>
                        Executioner Name: 
                        <outputfield value="{!valueResult.executioner_name}"/>
                        <br/>Planner Name: 
                        <outputfield value="{!valueResult.planner_name}"/>
                        <br/>Reviewer Name: 
                        <outputfield  value="{!valueResult.reviewer_name}"/>

控制器:

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=new Test_Script__c();
    public String selectedValue {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()
    {
        valueResult=[select name, id, Executioner__c, Planner__c, Reviewer__c, Iteration__c from Test_Script__c where name='selectedValue' limit 1];
    }
}

I am not able to see value on screen on change og picklist value

我会说您的 valueResult 缺少 getter。

public Test_Script__c valueResult {get; set;}

并且在控制器中您可以初始化对象。