0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Visualforce ページで <apex:insert> に対して <apex:define> しなかった時にデフォルトで表示されるものを指定する

Last updated at Posted at 2016-11-14

指定方法

 Visualforce では以下のような書き方でテンプレートに対してデータの埋め込みを行うことができる。

parent
<apex:page>
  <apex:outputText value="Hello, " />
  <apex:insert name="name" />
</apex:page>
child
<apex:page>
  <apex:composition template="parent">
    <apex:define name="name">Taro</apex:define>
  </apex:composition>
</apex:page>

結果

Hello, Taro

 この方法では基本的に <> を記述しないと <> の部分には何も出力されない。だが、<> タグの中に記述を入れると <> を書かなかった時にその記述が採用されるという仕様があるようだ。

parent
<apex:page>
  <apex:outputText value="Hello, " />
  <apex:insert name="name1">Taro</apex:insert>
  <apex:outputText value=" and " />
  <apex:insert name="name2">Hanako</apex:insert>
</apex:page>
</apex:page>

結果

Hello, Jiro and Hanako

 ただし、この方法は Salesforce の公式ドキュメント上に仕様として記されているものではないことに注意する。

0
1
0

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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?