+ Start a Discussion
sayantan bagchi 7sayantan bagchi 7 

Save error: Unknown property 'CustopPopupTaxController.Tax__c'

<apex:page controller="CustopPopupTaxController"  
  title="Search" 
  showHeader="false" 
  sideBar="false" 
  tabStyle="Tax__c" 
  id="pg">

  <apex:form >
  <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
    <apex:tabPanel switchType="client" selectedTab="name1" id="tabbedPanel">

      <!-- SEARCH TAB -->
      <apex:tab label="Search" name="tab1" id="tabOne">

        <apex:actionRegion >  
          <apex:outputPanel id="top" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
            <apex:outputLabel value="Search" style="font-weight:Bold;padding-right:10px;" for="txtSearch"/>
            <apex:inputText id="txtSearch" value="{!searchString}" />
              <span style="padding-left:5px"><apex:commandButton id="btnGo" value="Go" action="{!Search}" rerender="searchResults"></apex:commandButton></span>
          </apex:outputPanel>

          <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
            <apex:pageBlock id="searchResults"> 
              <apex:pageBlockTable value="{!results}" var="a" id="tblResults">
                <apex:column >
                  <apex:facet name="header">
                    <apex:outputPanel >Name</apex:outputPanel>
                  </apex:facet>
                   <apex:outputLink value="javascript:top.window.opener.lookupPick2('{!FormTag}','{!TextBox}_lkid','{!TextBox}','{!a.Id}','{!a.Name}', false)" rendered="{!NOT(ISNULL(a.Id))}">{!a.Name}</apex:outputLink>     
                </apex:column>
              </apex:pageBlockTable>
            </apex:pageBlock>
          </apex:outputPanel>
        </apex:actionRegion>

      </apex:tab>

      <!-- NEW Tax TAB -->
      <apex:tab label="New Tax" name="tab2" id="tabTwo">

        <apex:pageBlock id="newTax" title="New Tax" >

          <apex:pageBlockButtons >
            <apex:commandButton action="{!saveTax}" value="Save"/>
          </apex:pageBlockButtons>
          <apex:pageMessages />

          <apex:pageBlockSection columns="2">
            <apex:repeat value="{!$ObjectType.Tax__c.FieldSets.Tax_field_sets_for_Lookup}" var="f">
              <apex:inputField value="{!Tax__c[f]}"/>
            </apex:repeat>
          </apex:pageBlockSection> 
        </apex:pageBlock> 

      </apex:tab>
    </apex:tabPanel>
  </apex:outputPanel>
  </apex:form>
</apex:page>
This is my visualforce page which is showing a unknown property error. I don't know what is the reason. Below I have given my controller. Please Help me out. I have looked some of the discussions here but unable to understand exactly why this is happening.
public with sharing class CustopPopupTaxController {

  public Tax__c t1 {get;set;} // new account to create
  public List<Tax__c> results{get;set;} // search results
  public string searchString{get;set;} // search keyword

  public CustopPopupTaxController() {
    t1 = new Tax__c();
    // get the current search string
    searchString = System.currentPageReference().getParameters().get('lksrch');
    runSearch();  
  }

  // performs the keyword search
  public PageReference search() {
    runSearch();
    return null;
  }

  // prepare the query and issue the search command
  private void runSearch() {
    // TODO prepare query string for complex serarches & prevent injections
    results = performSearch(searchString);               
  } 

  // run the search and return the records found. 
  private List<Tax__c> performSearch(string searchString) {

    String soql = 'select id, name from Tax__c';
    if(searchString != '' && searchString != null)
      soql = soql +  ' where name LIKE \'%' + searchString +'%\'';
    soql = soql + ' limit 500';
    System.debug(soql);
    return database.query(soql); 

  }

  // save the new account record
  public PageReference saveTax() {
    insert t1;
    // reset the account
    t1 = new Tax__c();
    return null;
  }

  // used by the visualforce page to send the link to the right dom element
  public string getFormTag() {
    return System.currentPageReference().getParameters().get('frm');
  }
  
  

  // used by the visualforce page to send the link to the right dom element for the text box
  public string getTextBox() {
    return System.currentPageReference().getParameters().get('txt');
  }

}

 
Best Answer chosen by sayantan bagchi 7
Vivek_PatelVivek_Patel

Hi sayantan,

Instead of using Tax__c
<apex:inputField value="{!Tax__c[f]}"/>

use <apex:inputField value="{!t1[f]}"/>

which your variable in the controller.


Regards,
Vivek Patel.

Please like or mark this as best answer if this answers your question to help others find better answer and improve the quality of developer forum.