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 8786393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:36:50+00:00 2026-06-13T21:36:50+00:00

I want to place some helper functions in another file, since they will be

  • 0

I want to place some helper functions in another file, since they will be overly reused. I took the Computer-Databse sample’s listing file:

https://github.com/playframework/Play20/blob/master/samples/scala/computer-database/app/views/list.scala.html

I created a new file, called “listing.scala.html” under the app/views package, and moved the @link function from the original file to it. This new file looks like this:

@(currentSortBy: String, currentOrder: String, currentFilter: String)

@****************************************
* Helper generating navigation links    *
****************************************@
@link(newPage:Int, newSortBy:String) = @{

    var sortBy = currentSortBy
    var order = currentOrder

    if(newSortBy != null) {
        sortBy = newSortBy
        if(currentSortBy == newSortBy) {
            if(currentOrder == "asc") {
                order = "desc"
            } else {
                order = "asc"
            }
        } else {
            order = "asc"
        }
    }

    // Generate the link
    routes.Application.listPerfil(newPage, sortBy, order, currentFilter)

}

So, on my original file, I replaced the @link call, with this one:

<a href="@listing(currentSortBy, currentOrder, currentFilter).link(0, key)">@title</a>

And the problem is, when I try to compile I get this error:

value link is not a member of play.api.templates.Html

But according to the documentation (http://www.playframework.org/documentation/2.0.4/ScalaTemplateUseCases) it seems to be ok.

Any guess?

  • 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-06-13T21:36:52+00:00Added an answer on June 13, 2026 at 9:36 pm

    Play’s templates aren’t the best place for placing advanced conditions, most probably you’ll get better flexibility by processing it in some controller (or other method) which will return you only required link

    ie.:

     <a href="@controllers.Application.link(currentSortBy, currentOrder, currentFilter, 0, key)">@title</a>
    

    In your case proposed link(...) function of Application controller can also return a reverse-route.

    Keep in mind that including other templates is best option for repeating blocks of HTML but sometimes it’s hard to get specified string (mainly because of not trimmed spaces). As you can see there is also problem with calling nested functions. Most probably you can generate whole A tag in the listing.scala.html however using it isn’t comfortable enough (IMHO).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create some global helper functions. I understood that i must place
I want to move some file to other place, using Java SE 1.6 So,
I want to place panels horizontally, but when I drag panels they are going
I want to place a View (A) on top of another View (B). However,
When implementing some helper methods, sometimes, I want to store some computed result somewhere
i want to place a some buttons in the center of a panel, but
I want to declare some php functions and i would like to call those
i want to send some data from Action Helper to view Partial and i
I want to place some extra information (text files, background pic or others) to
Is it reasonable (or secure) to validate CAPTCHA via ajax? I want place a

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.