0

I am encountering the error:

Unknown property LeadStandardController.Savedoc

How do I fix it? Code below.

Page

<apex:page standardController="Lead" extensions="attachmentsample">               
    <apex:form >
        <apex:sectionHeader title="Upload attachment document."/>
            <apex:pageblock >
                <apex:pageblocksection columns="1">
                    <apex:inputfile value="{!myfile.body}" filename="{!myfile.Name}" />    
                </apex:pageblocksection>
            </apex:pageblock>   
    </apex:form> 
    <input type="submit" action="{!Savedoc}" name="submit"/>
</apex:page>

Extension

public class attachmentsample {
        public attachmentsample(Lead controller) {
        }
        public attachmentsample(ApexPages.StandardController controller) {
        }
        Public Attachment myfile;
        Public Attachment getmyfile()
        {
            myfile = new Attachment();
            return myfile;
        }  
        Public Pagereference Savedoc()
        {
            String accid = System.currentPagereference().getParameters().get('id');
            Attachment a = new Attachment(parentId = accid, name=myfile.name, body = myfile.body);        
             /* insert the attachment */
             insert a;
            return NULL;
        }   

    }  
}
1
  • your input tag should be a commandButton
    – cropredy
    Jun 30, 2016 at 15:08

1 Answer 1

1

Your markup should not even compile. The apex:input tag has no attribute called action. The error message is a little opaque, but that's the source of the problem. Here are some components that do have an action attribute that can call an Apex method:

If you are trying to create a submit button, commandButton is the way to go.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .