Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7572955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:03:34+00:00 2026-05-30T16:03:34+00:00

Using the Play! Framework 1.2.4. I’ve got a nifty trait that checks an API

  • 0

Using the Play! Framework 1.2.4. I’ve got a nifty trait that checks an API key and HTTPS, but if I want to access the account associated with that key and reference it in my controller, it throws a type mismatch; found : java.lang.Object required: Long

So here’s my API controller (incomplete):

object API extends Controller with Squeryl with SecureAPI {

  import views.API._

  def job(param:String) = {


    val Job = models.Job
    param match {
      case "new"    => Job.createFromParams(params,thisAccount) //thisAccount comes from the trait
      case "update" =>
      case "get"    =>
      case "list"   =>
    }
  }

}

and the secure trait:

trait SecureAPI {
  self:Controller =>

  @Before
  def checkSecurity(key:String) = {
      if(!self.request.secure.booleanValue) {
          Redirect("https://" + request.host + request.url);
      } else {
          models.Account.getByKey(key) match {
            case Some(account)  =>  {
              renderArgs += "account" -> account.id
              Continue
            }
            case _  =>  Forbidden("Key is not authorized.")
          }
      }
  }

  def thisAccount = renderArgs("account").get
}

How would I properly access thisAccount? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:03:35+00:00Added an answer on May 30, 2026 at 4:03 pm

    Your problem is simply that renderArgs is only declared to return an Object from its get call (which is fair enough because it could be just about anything).

    Consequently the inferred type of your thisAccount method will be () => Object.

    You’ll need to cast the returned type into a Long, something like (though perhaps with some error-checking):

    def thisAccount = renderArgs("account").get.asInstanceOf[Long]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the AVAudioPlayer framework, and I have several sounds that play one
I'm using Flash to play an .flv movieclip on my site, but I want
I have a Play Framework application that sends emails using SMTP server. Now I
I am using FlexJson within my play framework application but at the point I
I have a small site I built using the Play framework that I'm trying
I am able to debug scala controller in play framework using netbeans IDE but
Using play framework 1.2.4 with scala. I have few play jobs that looks like
I'm using the Play! framework and I have a model (an Entity) that has
I am using Play Framework and want to implement Invite Friends feature when user
I'm using the Play Framework and have a question about templates: I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.