質問

PlayFramework2.2を使用しました:

マイテンプレートは次のとおりです。

@(topiclink:String, head: String, rate: Int, topicid:Int, summary: String, pic_url:String)
@if(topiclink=="Shoplist"){
<a class="list-group-item" href="@routes.ShoplistController.pagelist(topicid.toString())">
}else {
 <a class="list-group-item" href="@routes.PageController.pagelist(topicid.toString())"> 

}</a>
.

私はもっとOOPを書いたく、私は:

のパラメータを使いたいという意味です。
@(topiclink:Controller, head: String, rate: Int, topicid:Int, summary: String, pic_url:String)
.

直接@ topiclink.pageList(topicid.tostring())

それから私は直接対応コントローラのページ集計に到達することができます。

役に立ちましたか?

解決

コントローラを直接渡すことはおそらく悪いアイデアです - コントローラがあなたが望むデータ(PageList)を表すオブジェクトを作成することを検討してください。

あなたが「合格」しても、それを「渡す」ためのコントローラの仕事です - これらすべてのものはパラメータです。あなたが本当にコントローラを望むなら、あなたのページを作成するコントローラ内でこのキーワード:

views.html.index.myPage(this, otherParam, ...)
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top