Dec12th

概要

Top / 概要

apex:form タグを利用し、その中に入力コンポーネントを記述します。
フォームの送信には apex:commandLink あるいは apex:commandButton タグが利用できます。

apex:inputField

ページ:

apex:page controller="theController">

  <apex:form>
     <apex:pageBlock mode="edit" id="block">
        <apex:pageBlockSection>
           <apex:pageBlockSectionItem>
              <apex:outputLabel for="searchText">Search Text</apex:outputLabel>
              <apex:panelGroup>
                 <apex:inputText id="searchText" value="{!searchText}"/>
                 <apex:commandButton value="Go!" action="{!doSearch}" 
                                     rerender="block" status="status"/>
              </apex:panelGroup>
           </apex:pageBlockSectionItem>
       </apex:pageBlockSection>
       <apex:actionStatus id="status" startText="requesting..."/>
       <apex:pageBlockSection title="Results" id="results" columns="1">
          <apex:pageBlockTable value="{!results}" var="l" 
                              rendered="{!NOT(ISNULL(results))}">
             <apex:column value="{!l.name}"/>
             <apex:column value="{!l.email}"/>
             <apex:column value="{!l.phone}"/>
          </apex:pageBlockTable>
       </apex:pageBlockSection>
     </apex:pageBlock>
  </apex:form>

/apex:page>

コントローラ:
public class theController {

  String searchText;
  List<Lead> results; 
  
  public String getSearchText() {
       return searchText;
  }
  
  public void setSearchText(String s) {
   searchText = s;
  }
  
  public List<Lead> getResults() {
     return results;
  }
  public PageReference doSearch() {
   results = (List<Lead>)[FIND :searchText RETURNING Lead(Name, Email, Phone)][0];
     return null;
  }

}

詳細ヘッダー:
public with sharing class QuestionListController {

   String country = null;
   public List<SelectOption> getRadioList() {
       List<SelectOption> options = new List<SelectOption>();
       for (QuestionnaireHeader__c record: qhListUnMatch) {
           options.add(new SelectOption(record.Id, record.name));
       
       }
       return options;
   }
   public PageReference redraw() {
       
       if ( country  == null) {
           ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'summary - warning', 'detail - warning'));
       }
       ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'summary - info', 'detail - info'));
       return null;
   }
   public String getCountry() { return country; }
   public void setCountry(String country) { this.country = country; }

}

apex:form >

   <apex:selectRadio value="{!country}" layout="pageDirection" >
       <apex:selectOptions value="{!RadioList}"/>
   </apex:selectRadio><p/>
   <apex:commandButton value="Test" action="{!redraw}"  rerender="out" status="status"/>

/apex:form>

  • Apex Page ---

    apex:page controller="testCon">

           <apex:form>
                   <apex:inputField id="number" value="{!menu.Number__c}"/>
                   <apex:inputField id="day" value="{!menu.Day__c}"/>
                   <apex:inputField id="name" value="{!menu.Name__c}"/>
                   <apex:commandButton  action="{!save}" value=" 登 録 "/>
           </apex:form>

    /apex:page>

  • 制御項目(コントローラ) ---

public class testCon {

 //変数宣言
 public menu__c objMenu { get; set; }
 public menu__c getMenu() {
     if(objMenu == null) objMenu = new menu__c();
        return objMenu;
     }
 }
 public PageReference save(){
     insert objMenu;
     return null;
 }

}

  • ここまで ---