function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
吉田 丈治吉田 丈治 

複数のパラメータでVisualforceページの表示を切り替えるような実装

Visualforceページに
・ユーザー一覧
・年月
のようなドロップダウンリスト2つを置き、移動ボタンを押すとその2つのパラメータを含んだURLへと遷移するような事をしたいと思っています。
URLは /apex/pageName?uid=ユーザーID&yearmonth=2017-01
のようなイメージです。

該当するユーザの該当月のEvent一覧を出力するようなイメージなのですが、どのような実装が可能でしょうか。

・表示されるドロップダウンリストは該当ユーザと年月が選択された状態になっていると尚良い
・ユーザを受け取ると、年月のドロップダウンリストはEventが存在している年月のみだと尚良い

特に分からないこと
・年月のドロップダウンリストのようなものを自動生成出来るのか
Taiki YoshikawaTaiki Yoshikawa
年月のドロップダウンリストですが、Apex内で生成することは可能です。
/**
 * 年選択リスト値取得
 */
public List<SelectOption> getSelectYearItem() {

    Integer startYear = System.today().year();

    List<SelectOption> options = new List<SelectOption>();
    for (Integer i = startYear - 5; i < startYear + 5; i++) {
        options.add(new SelectOption(String.valueOf(i), String.valueOf(i)));
    }

    return options;
}

/**
 * 月選択リスト値取得
 */
public List<SelectOption> getSelectMonthItem() {

    List<SelectOption> options = new List<SelectOption>();
    for (Integer i = 1; i <= 12; i++) {
        options.add(new SelectOption(String.valueOf(i), String.valueOf(i)));
    }

    return options;
}

ページ側は次のようになります。
<apex:pageBlockSection columns="1" id="selction">
    <apex:outputPanel id="selectListPanel">
        <apex:selectList value="{!selectYear}" multiselect="false" size="1" id="selectYear">
            <apex:selectOptions value="{!selectYearItem}" id="selectYearItem" />
        </apex:selectList>
        <apex:outputText value=" 年 " />
        <apex:selectList value="{!selectMonth}" multiselect="false" size="1" id="selectMonth">
            <apex:selectOptions value="{!selectMonthItem}" id="selectMonthItem" />
        </apex:selectList>
        <apex:outputText value=" 月 " />
    </apex:outputPanel>
</apex:pageBlockSection>

このようにapex:selectListとapex:selectOptionsを利用することで任意の選択リストを用意することができます。
Visualforce Developers Guideに詳細な利用方法を確認できます。
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_selectList.htm