LoginSignup
9
11

More than 5 years have passed since last update.

【質問】ページ遷移の際のパラメータ渡しについて

Last updated at Posted at 2014-04-16

閲覧ありがとうございます。
Salesforce,Visualforce,Apexに関する質問です。

ページ1で、ある商品を選択するボタンを押すと
その商品の詳細が載ったページ2に遷移するページを作成しています。
ページ1のcommandButtonにparamを使って、ページ2へid情報を渡したいです。

いくつかのページを参考にしましたがこちらのページが自分のやりたいことに
最も近いと思い、それにかなり近く組んでみたつもりなのですが、上手くいきません。

【コントローラ】

public with sharing class testController {
    public List<MerchandiseInventoryControl__c> targetList {get; set;}
    public String targetId {get; set;}

    public testController() {
    }

    public Pagereference doSelect() {
  targetId = ApexPages.currentPage().getParameters().get('tgtm');
        targetList = testDao.getTargetRecs(targetId);
        return Page.Page2;
    }

}


【ページ1】
<apex:page controller="testController">
    <apex:form >
    <apex:pageBlock title="商品一覧">
        <apex:pageBlockSection >
                <apex:pageBlockTable value="{!inventoryList}" var="im">  
                    <apex:column >
                        <apex:commandButton value="この商品を選択する" action="{!doSelect}">
                            <apex:param name="tgtm" value="{!im.Name}" assignTo="{!targetId}"  id="tgtm"/>
                        </apex:commandButton>
                    </apex:column>
                </apex:pageBlockTable>      
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

【ページ2】
<apex:page controller="testController">
    <apex:form >
        <apex:pageBlock title="選択した商品の情報">
        <apex:pageBlockSection >
                <apex:pageBlockTable value="{!targetList}" var="tl">
                </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

色々試してみたのですが、どうしてもページ2の方にid情報が渡らないので
質問させていただきました。
どうか、よろしくお願い申し上げます。

9
11
22

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
11