2016-04-05 13 views
0

Görsel kuvveti kullanarak sayfa oluyorum.Nasıl standart sayfa için özel düğme/bağlantı oluşturmak için. Özel düğmeyi/bağlantıyı tıkladıktan sonra sayfayı açmam gerekiyor. bu nasıl yapılır. KodumÖzel Düğme veya Standart denetleyici ile bir Visualforce sayfasına bağlantı

<apex:page standardcontroller="Account" tabstyle="Account" extensions="MyExtension" > 
<apex:form id="form1"> 
    <apex:commandlink action="{!showForm2}" value="Show the Form" rendered="{!showForm}" reRender="form2,op1"/> 
</apex:form> 
<apex:outputpanel id="op1"> 
<apex:form id="form2"> 
<apex:sectionheader title="Account Details" subtitle="{!if(Account.Id==null,'New Account',Account.Name)}"></apex:sectionheader> 
<apex:pageblock mode="edit" id="leadPB" title="Account Edit"> 

<apex:pageblockbuttons > 
<apex:commandbutton action="{!save}" value="Save"></apex:commandbutton> 
<!-- If you wish to implement Save & New functionality you will have to write an Apex Extension with your own Save & New Method --> 
<apex:commandbutton action="{!cancel}" value="Cancel"></apex:commandbutton> 
</apex:pageblockbuttons> 

     <apex:pageBlockSection > 
      <apex:inputtext value="{!Account.LastName}" label="Customer Name"/> 
      <apex:inputtext value="{!Account.PersonMobilePhone}"/> 
      <apex:inputtext value="{!Account.CustomLandLine__c}"/> 
      <apex:inputField value="{!Account.City__c}"/> 
      <apex:inputField value="{!Account.PersonEmail}"/> 
      <apex:inputField value="{!Account.Source__c}"/> 

      <!-- <apex:commandButton action="{!save}" value="Save!"/>--> 
     </apex:pageBlockSection> 
    </apex:pageBlock> 
<apex:pageMessages /> 
</apex:form> 
</apex:outputpanel> 
</apex:page>` 

Benim sınıf kodu

public with sharing class MyExtension { 
    private ApexPages.StandardController sc; 
    public MyExtension(ApexPages.StandardController sc) { 
     this.sc = sc; 
    } 
    public PageReference save() { 
     Account a = (Account) sc.getRecord(); 
     a.OwnerId = [select Id from User where LastName = 'Kapoor'].Id; 
     a.OwnerId = [select Id from User where FirstName = 'Raoul'].Id; 
     return sc.save(); 
    } 
public boolean showForm{get;set;} 

// default the var to false; 
showForm = false; 

public void showForm2(){ 
showForm = true; 
} 
} 

altındadır Ama şu hatayı

Error: Compile Error: unexpected token: '=' at line 15 column 9

Ve benim sayfa

, ben bu hata var kontrolör gösterir

10 bu

cevap

2

sağ this.sc = sc; altına showForm = false; koymak Lütfen çözmek için nasıl. Kurucunun içindeki her şey başlatma/varsayılan değerler içindir.
Denetleyici uzantısı başarıyla kaydedilmediğinden ikinci hatayı aldınız. İlkini düzelttikten sonra, her iki hata da ortadan kalkar.

İlgili konular