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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:49:09+00:00 2026-06-12T04:49:09+00:00

I think I have misunderstood something about the Play 2 framework. In my Application

  • 0

I think I have misunderstood something about the Play 2 framework.

In my Application Controller I fetch a Company object from the DB
and I would like to make some operations on it in my view.

companyView.scala.html:

@(company: Company)

@main("Welcome to Play 2.0") { 
 <h1>@{company.name}</h1>

}

Application Controller:

package controllers;

import models.Company;
import play.*;
import play.mvc.*;

import views.html.*;

public class Application extends Controller {

    public static Result company(String rest) {             
        Company company = 
                Company.find.where().ilike("restfulIdentifier.identifier", rest).findUnique();
        return ok(companyView.render(company));
    }   
}

But return ok(companyView.render(company)); results in compilation error since companyView.render wants a string.

If I look at the forms sample application:

/**
     * Handle the form submission.
     */
    public static Result submit() {
        Form<Contact> filledForm = contactForm.bindFromRequest();

        if(filledForm.hasErrors()) {
            return badRequest(form.render(filledForm));
        } else {
            Contact created = filledForm.get();
            return ok(summary.render(created));
        }
    }

There is no problem with rendering an object. I guess that the solution is fairly simple and
that I have missed some crucial part of the documentation. Please explain this to me!

  • 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-12T04:49:11+00:00Added an answer on June 12, 2026 at 4:49 am

    My steps in this case would be as follows:

    1. Change the scala template, we hve to tell the scala templates the our Company belongs to the model class: (but also change to @company.name as suggested by Jordan.

       @(company: models.Company)
      
       @main("Welcome to Play 2.0") { 
         <h1>@company.name</h1>
      
       }
      
    2. run command play clean

    3. Then run play debug ~run

    By executing play debug ~run you will trigger to compile the the play application on each SAVE of one of your project files.

    NOTE: The Play templates are basically functions. These functions needs to be compiled and everything used in these functions needs to be declared before use. Just as in regular Java development.

    The fact that the your render object wants a string could be the result of:

    • @(company: Company) could not be resolved to the model Company.
    • The last compilation had a @(company: String)

    Good luck!

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

Sidebar

Related Questions

Apparently, I have completely misunderstood its semantics. I thought of something like this: A
I think I may have misunderstood something here... But here goes. I'm using the
I must have misunderstood something. I simply want to use performSelector: to call one
I am building something for mobile and would like somehow to clear, null objects,
I think I might have greatly misunderstood the usage of gluperspective() and require help.
I am converting an old script from ASP to ASP.NET and would like some
I think I misunderstand something about MVC. I'm trying to do the following: public
I think I have misunderstood how Javascript prototypal inheritance works. Specifically, the prototypes internal
I have downloaded TableView sample code '4_TableViewCellSubviews' from internet. I am trying to run
I'm a little confused about how EGit workes. I have an existing git repository

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.