0

Below is my code VF PAGE

<apex:page controller="SurveyController" >
<apex:form >
    <apex:outputLabel ><b> Surveys: </b></apex:outputLabel>
    <apex:selectList value="{!surveyid}" size="1" multiselect="false">
        <apex:selectOptions value="{!SelectedId}" />     
    </apex:selectList>
<p> 
    </p>                

<apex:outputPanel id="theForm">
    <apex:pageBlock >
        <apex:commandButton value="Display Survey" action="{!GetRecordPage}" reRender="theForm" id="bor"/>       
        <apex:outputPanel rendered="{!submit}" >
            <p>

                </p>
            <apex:repeat value="{!RecordFetching}" var="fetch">    
                <apex:outputField value="{!fetch.name}"/>
                <p>

                </p>

                <apex:inputField rendered="{! IF( fetch.Type__c == "Text"  , TRUE, FALSE) }" value="{!ResponseProperty.ResponseText__c}"  />

                <apex:selectList rendered="{! IF( fetch.Type__c == "Picklist"  , TRUE, FALSE) }" size="1" multiselect="false" value="{!selectedPicklist}">
                    <apex:selectOptions value="{!PicklistAns}"/>
                </apex:selectList>

                <p>

                </p>
            </apex:repeat>
            <apex:commandButton value="Submit Survey" action="{!SubmitSurvey}" reRender="theForm"/>
        </apex:outputPanel>

    </apex:pageBlock>
</apex:outputPanel>
</apex:form>

CONTROLLER

public class SurveyController { 
    public string surveyid{get;set;} 
    public List<Survey__c> surv = new List<Survey__c>(); 
    public List<Question__c> Questions = new List<Question__c>();
    public List<Response__c> ResponsePage = new List<Response__c>();
    public List<Answer__c> AnswerPage = new List<Answer__c>();
    public List<Question__c> bdoc;
    public boolean submit {get;set;}
    public Answer__c AnswerProperty {get;set;}
    public Response__c ResponseProperty {get;set;}
    public string selectedPicklist{get;set;}

    public SurveyController() //Constructor
    {
        submit = false;
        ResponseProperty= new Response__c();
        AnswerProperty = new Answer__c();
    }

    public List<SelectOption> getSelectedId() 
    {            

        List<SelectOption> opt = new List<SelectOption>();           
        surv=[SELECT Id,Name from Survey__c];         

        for(Survey__c obj:surv)
        {
            opt.add(new SelectOption(obj.id,obj.Name));        
        } 
        return opt;
    }   

    Public PageReference GetRecordPage()
    {
        submit = true;  
        return null;   
    }

    Public List<Question__c> GetRecordFetching()
    {
       bdoc =  new List<Question__c>();   
       List<Question__c> Questions = [SELECT Name,Type__c from Question__c where Survey__c= :surveyid];
       //List<Answer__c> Answers = [SELECT Name from Question__c ];
       if(Questions.size() > 0)
       {
                bdoc.addall(Questions);        
       }    
       return bdoc;
    } 

    public List<SelectOption> getPicklistAns()
    {
        List<SelectOption> APicklist = new List<SelectOption>(); 
        AnswerPage= [Select Name from Answer__c];
        for(Answer__c obj:AnswerPage)
        {
            APicklist.add(new SelectOption(obj.id,obj.Name));
            System.debug(obj.Name);
        }
        return Apicklist;    
    }

    Public void SubmitSurvey()
    {
        if(ResponseProperty.ResponseText__c!=NULL){
            ResponseProperty.Survey__c=surveyid;
            insert ResponseProperty;
        }    
    }

}
1

Okay the error is because you are quoting a value in double quotes within a double quote. The error is because of following lines.

<apex:inputField rendered="{! IF( fetch.Type__c == "Text"  , TRUE, FALSE) }" value="{!ResponseProperty.ResponseText__c}"  />
<apex:selectList rendered="{! IF( fetch.Type__c == "Picklist"  , TRUE, FALSE) }" size="1" multiselect="false" value="{!selectedPicklist}">

You can use single quote if within a double quoted string or vise-versa. Do the following this will fix your problem

<apex:inputField rendered="{! IF( fetch.Type__c == 'Text'  , TRUE, FALSE) }" value="{!ResponseProperty.ResponseText__c}"  />
<apex:selectList rendered="{! IF( fetch.Type__c == 'Picklist'  , TRUE, FALSE) }" size="1" multiselect="false" value="{!selectedPicklist}">
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.