0

I am looking to create a web form that will create cases with the information filled out on it. Right now I am just trying to get the basic nuts and bolts working. I have built a form, used the standard case controller, and created an extension.

To start, here is the form. It is very basic and comes together just fine:

 <apex:page sidebar="false" showHeader="false"standardController="Case" extensions="PartnerSupportCaseController">
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection title = "Partner Support Form">
          <apex:inputField value="{!Case.Supplied_Email__c}"/> 
       </apex:pageBlockSection>
        <apex:pageBlockSection >
           <apex:inputText required="true" value="{!Case.Subject}"/>
        </apex:pageBlockSection>    
        <apex:pageBlockSection >
            <apex:inputTextArea required="true" rows="5" value="{!Case.Description}"/> 
        </apex:pageBlockSection>

        <apex:commandButton action = "{!Save}" value = "Save" /> 
    </apex:pageBlock> 
 </apex:form>
</apex:page>

The problem, I believe, lies in the extension:

public class PartnerSupportCaseController {

    public Case supportCase {get;set;}

    public PartnerSupportCaseController(ApexPages.StandardController controller)
    {
        supportCase = New Case();
    }

    public pagereference Save()
    {
        insert supportCase;
        PageReference pg = Page.<PartnerSupportThankYou>;
        pg.setredirect(true);
        return pg;
    }


}

I have made reference to a very basic thank you page that I threw together, as I want the user redirected to that page after they fill out the form. (I can worry about querying and returning the case number for them to view and save for future reference later on). What is happening is that I am getting an error on the visualforce page stating: Unknown constructor 'PartnerSupportCaseController.PartnerSupportCaseController(ApexPages.StandardController controller)'

Also, an error is stating: Unexpected token ';' in line 13 (the line that contains PageReference pg = Page.;).

As I mentioned, I am really just trying to plug some of the nuts and bolts together here, so the styling and other functionality is lacking. I was hoping that someone had some insight as to what I am doing wrong in plugging these two components together.

THanks, thanks. -CP

1

The error 'Unexpected Token' is because

PageReference pg = Page.<PartnerSupportThankYou>; 

is invalid syntax - remove the < and >.

and because that failed, the class failed to compile so the VF page will get an error unknown constructor

That said, it looks like you are going to have a binding issue between the VF page and the standardController Extension class. Your VF page is trying to bind

<apex:inputField value="{!Case.Supplied_Email__c}"/>

to the standard object Case yet your Controller is manipulating/saving a different variable, not bound to the VF page supportCase.

A typical pattern to resolve this would be to change the Constructor to

public PartnerSupportCaseController(ApexPages.StandardController stdController) {
  this.supportCase = (Case)stdController.getRecord();
}

as the getRecord() handles the binding between the VF page {!Case.xxx} and your controller variable. For more reading - see Building a Controller Extension

  • Thanks alot. This has been quite helpful. I'm going to mark it as the best answer in a moment, but there is one issue: this.supportCase = (Case)stdController.getRecord(); is throwing the error "Variable does not exist: std controller. It was not resolved when i wrote out the full word "Standard" either – Chris P Oct 22 '15 at 19:55
  • However, removing std and just having it say "controller" did remove the error – Chris P Oct 22 '15 at 20:07
  • my bad - i was copying from sfdc doc without looking to see how you declared the variable; fixed answer; – cropredy Oct 22 '15 at 22:37

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.