• vivek.kumar.ax1255
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

I am integrating with salesforce through java there in Opportunity there is a field named CloseDate . my code for the same is opportunitySObject.setField("CloseDate", "2010-01-01"); but i getmessage='Close Date: value not of required type: 2010-01-01' statusCode='INVALID_TYPE_ON_FIELD_IN_RECORD'

what i see by quering the database is CloseDate in 2010-01-01 format i.e. yyyy-MM-dd.

Please help.

Hi all.

 

I'm quite new to salesforce.

 

I have an inputText tag on a custom component that has it's value set to a property on the controller. Yeasterday this was working fine but today it seems that the controllers and views are not wired up and so the property is always empty, regardless of what the user puts in the input box.

 

My VF page lists multiple of these components in a dataList, and to each of these components I pass as an attribute the parent VF page. The parents VF page controller has a collection that contains the components that are listed on the page.

 

I then have a method on each of the components that returns the text that is supposed to be in the property on the component controller.

 

That was supposed to allow me to call an action method from the page and in that method loop through the components on the page and retrieve the text in the components input box.

 

Again that was working yesterday but not today. Something else that might shed some light is that the commandButton on the page was also not calling the method assigned to its action attribute.

 

VF Page

 

 

<apex:page sidebar="false" showHeader="false" controller="questionsController">

<apex:form >

<apex:outputText value="{!SurveyResponse.Account_Survey__r.Survey__r.Name}" /> <apex:dataList value="{!Questions}" var="Question" id="dlQuestions">

<apex:outputText value="{!Question.Name}" />

<c:QuestionOptions Question="{!Question}" PageController="{!This}" />

</apex:dataList>

<apex:commandLink action="{!SubmitResponse}" value="Submit" id="btnSubmit" immediate="true" /> <apex:messages />

</apex:form>

</apex:page>

 

 Page Controller

 

public class questionsController {

private List<comp_QuestionOptionsController> questionOptionsControllers;

public void AddQuestionOptionsController(comp_QuestionOptionsController controller){

Boolean exists = false;

for(comp_QuestionOptionsController existing: questionOptionsControllers){

if(existing == controller){

exists = true;

break;

}

}

if(!exists)

questionOptionsControllers.add(controller);

}

 

public questionsController getThis(){

return this;

}

 

public Survey_Response__c surveyResponse{get; private set;}

 

public Id optionsId{get;set;}

 

public questionsController(){

String responseId = ApexPages.currentPage().getParameters().get('id');

questionOptionsControllers = new List<comp_QuestionOptionsController>();

SurveyResponse = [

SELECT Id, Account_Survey__r.Survey__r.Id, Account_Survey__r.Survey__r.Name

FROM Survey_Response__c

WHERE Id = :responseId

];

}

 

public List<Question__c> getQuestions(){

List<Question__c> questions = [

SELECT Name,Response_Type__c,

(

SELECT Id, Name

FROM Options__r

)

FROM Question__c

WHERE Survey__c = :surveyResponse.Account_Survey__r.Survey__r.Id

];

return questions;

}

 

public PageReference SubmitResponse(){

List<Answer__c> answers = new List<Answer__c>();

try{

for(comp_QuestionOptionsController controller:questionOptionsControllers){

answers.add(new Answer__c(

Question__c = controller.MyQuestion.Name,

Answer__c = controller.getAnswer(),

Rating__c = 'Excellent',

Survey_Response__c = surveyResponse.Id

));

}

insert answers;

}catch(DmlException ex){ApexPages.addMessages(ex);}

return null;

}

 

}

 

 VF Component

 

<apex:component controller="comp_QuestionOptionsController">

<apex:attribute name="PageController" type="questionsController" assignTo="{!MyPage}" required="true" description="The controller for the page." />

<apex:attribute name="Question" description="The parent Question" type="Question__c" required="true" assignTo="{!MyQuestion}" />

 

<apex:selectList rendered="{!DropDownListVisible}" size="1" multiselect="false" value="{!SelectedItems}" > <apex:selectOptions value="{!Items}" />

</apex:selectList>

 

<apex:inputText rendered="{!TextOrNumberOrDateVisible}" value="{!TextValue}" />

 

<apex:selectCheckboxes rendered="{!CheckBoxesVisible}" value="{!SelectedItems}">

<apex:selectOptions value="{!Items}" />

</apex:selectCheckboxes>

 

<apex:selectRadio rendered="{!RadioButtonsVisible}" value="{!SelectedItems}">

<apex:selectOptions value="{!Items}" />

</apex:selectRadio>

</apex:component>

 

 

 

 

 Component Controller

 

public class comp_QuestionOptionsController{

public questionsController MyPage{

get;

set{

((questionsController)value).AddQuestionOptionsController(this);

}

}

 

public Question__c MyQuestion{get;set;}

 

public Boolean DropDownListVisible{

get{

return MyQuestion.Response_Type__c == 'Drop Down List';

}

}

 

public Boolean TextOrNumberOrDateVisible{

get{

return MyQuestion.Response_Type__c == 'Number' || MyQuestion.Response_Type__c == 'Free Text' || MyQuestion.Response_Type__c == 'Date';

}

}

 

public Boolean CheckBoxesVisible{

get{

return MyQuestion.Response_Type__c == 'Check Boxes';

}

}

 

public Boolean RadioButtonsVisible{

get{

return MyQuestion.Response_Type__c == 'Radio Button List';

}

}

 

public String TextValue{get;set;}

 

public String[] SelectedItems{get;set;}

 

public List<SelectOption> getItems(){

List<SelectOption> items = new List<SelectOption>();

for(Option__c option:MyQuestion.Options__r){

items.add(new SelectOption(option.Id,option.Name));

}

return items;

}

 

public String getAnswer(){

String answer = '';

if(DropDownListVisible || CheckBoxesVisible || RadioButtonsVisible){

//for(Integer i=0;i<SelectedItems.size() - 1; i++){

//answer = answer + SelectedItems[i] + ', ';

//}

answer = 'multi';

}

 

if(TextOrNumberOrDateVisible){

//answer = 'text';

answer = TextValue;

}

 

//if(answer.endsWith(', '))

//answer = answer.substring(0, answer.lastIndexOf(' ') - 1);

//if(answer == '')

//answer = 'answer was empty';

 

return answer;

}

}

 

 I don't get any errors with this. It is just that the "TextValue" property on the component controller is always empty.

 

Any help would be greatly appreciated, I'm pulling my hair out over this one!

 

Thanks 

 

 

 

Message Edited by deano on 02-03-2010 02:59 PM
  • February 03, 2010
  • Like
  • 0