[Play 2.7-Java] access Http.Request attrs in template

Hi,
I have defined:

public class ActAttrs {
    public static final TypedKey<Optional<SqlRow>> BID_DETAIL_DATA = TypedKey.create("detailData");

Then filled in the attrs with a resultSet from database in an action composition:

newReq = req.addAttr(ActAttrs.BID_DETAIL_DATA, optRow);
return delegate.call(newReq);

But how to access this attrs in template?

@(assetsFinder: AssetsFinder,
        df2: DecimalFormat,
        ro: restrictOr)(tabContent: Html)(implicit request: Http.Request, messages: play.i18n.Messages)

@request.attrs().get( **?**TypedKey**?**).asInstanceOf[Optional[SqlRow]] ...

Thanks.

hey @petahathub,

You can directly reference that TypedKey in your template:

@request.attrs().get(com.acme.models.ActAttrs.BID_DETAIL_DATA)

Best.

Aha. Simple.

I had

@import action.ActAttrs
...
@request.attrs().get(ActAttrs.BID_DETAIL_DATA)

But it was doggedly resulting in No member BID_DETAIL_DATA in object ActAttrs error.
Probably I needed sbt clean first :slight_smile:
Now it works.

Thank you.