function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
amar joshiamar joshi 

cant create task vf page

hi all

             i want to create task visualforece page but get the bellow error
    Could not resolve the entity from <apex:inputField> value binding '{!task.subject}'. inputField can only be used with SObject fields.

my code is as bellow  please help me out.

thanks
Code:
//apex page code
<apex:page controller="myTask">
  <apex:form >
  <apex:pageBlock title="Task" mode="edit">
   <apex:pageBlockButtons >
  <apex:commandButton action="{!save}" value="save"/>
  </apex:pageBlockButtons>
  <apex:pageBlockSection title="Task Information">
  <apex:inputfield id = "subject" value = "{!task.subject}"/>
  </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>


//controller code
public class myTask {

    public PageReference save() {
        return null;
    }


    Task task;

    public Task getTask() {
        
        task = new Task();
        return task;

    }

}

 

Ron HessRon Hess
Try saving the controller first , go into Setup, Apex Classes and save it there,
then save the visualforce page, that worked for me

Somehow in the development mode, the quick fix did not recognize that mytask was returning a task, since it builds this as a string in quick fix mode.
amar joshiamar joshi
i had save the controller in apex class it saved but same error occur as saving the  visualforce page please help me out
it worked for creating an account and opportunity but not worked for task.
amar joshiamar joshi
i got the same error after aftre doning as per Ron Hess's instruction

its worked for account but not for task

my code as bellow
Code:
//VF page logic 
<apex:page controller="Task">
  <apex:form >
  <apex:pageBlock title="Task" mode="edit">
   <apex:pageBlockButtons >
  <apex:commandButton action="{!save}" value="save"/>
  </apex:pageBlockButtons>
  <apex:pageBlockSection title="Task Information">
  <apex:inputField value="{!account.name}"/>
  <apex:inputfield value="{!task.subject}"/>
  </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>

//task controller
public class task {

Task task;
Account account;


    public Task gettask() {
    if (task == null)
           task = new Task();
        return task;
        }
    
       public Account getaccount() {
    if (account == null)
           account = new Account();
        return account;
        }
      public PageReference save() {
      
        return null;
    }

}

 
the error like this:



Could not resolve the entity from <apex:inputField> value binding '{!task.subject}'. inputField can only be used with SObject fields.


Message Edited by amar joshi on 08-19-2008 12:14 PM
Ron HessRon Hess
I have filed a bugreport, i was not able to get this to save
ESES
I think the problem is that you are calling your apex class Task, and thats what gets returned instead of the SObject Task.
Try renaming your class to something else like MyTask.
Ron HessRon Hess
Yes, i see now.

the class Task that you defined was returned when you made the call

 task = new Task();

rather than creating an sobject with all it's fields, you created an instance of the class (called Task) of your own definition.


amar joshiamar joshi
yep

its working

i have  givan class name and instance of class name same thats why it confused and give the error

thanks all for helping me.