当前位置: 首页>>代码示例>>Scala>>正文


Scala MessagesApi类代码示例

本文整理汇总了Scala中play.api.i18n.MessagesApi的典型用法代码示例。如果您正苦于以下问题:Scala MessagesApi类的具体用法?Scala MessagesApi怎么用?Scala MessagesApi使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MessagesApi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: ChangePasswordController

//设置package包名称以及导入依赖的类
package controllers

import javax.inject.Inject

import com.mohiva.play.silhouette.api._
import com.mohiva.play.silhouette.api.exceptions.ProviderException
import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository
import com.mohiva.play.silhouette.api.util.{ Credentials, PasswordHasherRegistry, PasswordInfo }
import com.mohiva.play.silhouette.impl.providers.CredentialsProvider
import models.services.UserService
import play.api.i18n.{ I18nSupport, Messages, MessagesApi }
import play.api.libs.concurrent.Execution.Implicits._
import play.api.mvc.Controller
import utils.auth.{ DefaultEnv, WithProvider }

import scala.concurrent.Future

class ChangePasswordController @Inject() (
  val messagesApi: MessagesApi,
  silhouette: Silhouette[DefaultEnv],
  userService: UserService,
  credentialsProvider: CredentialsProvider,
  authInfoRepository: AuthInfoRepository,
  passwordHasherRegistry: PasswordHasherRegistry
)
  extends Controller with I18nSupport {

  def view = silhouette.SecuredAction(WithProvider[DefaultEnv#A](CredentialsProvider.ID)) { implicit request =>
    Ok(views.html.changePassword(new myform.MyChangePasswordForm(), request.identity))
  }

  def submit = silhouette.SecuredAction(WithProvider[DefaultEnv#A](CredentialsProvider.ID)).async { implicit request =>
    new myform.MyChangePasswordForm().bindFromRequest match {
      case form: myform.MyChangePasswordForm => Future.successful(BadRequest(views.html.changePassword(form, request.identity)))
      case data: myform.MyChangePasswordFormData => {
        val (currentPassword, newPassword) = (data.currentPassword, data.newPassword)
        val credentials = Credentials(request.identity.email.getOrElse(""), currentPassword)
        credentialsProvider.authenticate(credentials).flatMap { loginInfo =>
          val passwordInfo = passwordHasherRegistry.current.hash(newPassword)
          authInfoRepository.update[PasswordInfo](loginInfo, passwordInfo).map { _ =>
            Redirect(routes.ChangePasswordController.view()).flashing("success" -> Messages("password.changed"))
          }
        }.recover {
          case e: ProviderException =>
            Redirect(routes.ChangePasswordController.view()).flashing("error" -> Messages("current.password.invalid"))
        }
      }
    }
  }
} 
开发者ID:serversideapps,项目名称:silhmojs,代码行数:51,代码来源:ChangePasswordController.scala

示例2: ResetPasswordController

//设置package包名称以及导入依赖的类
package controllers

import java.util.UUID
import javax.inject.Inject

import com.mohiva.play.silhouette.api._
import com.mohiva.play.silhouette.api.repositories.AuthInfoRepository
import com.mohiva.play.silhouette.api.util.{ PasswordHasherRegistry, PasswordInfo }
import com.mohiva.play.silhouette.impl.providers.CredentialsProvider
import models.services.{ AuthTokenService, UserService }
import play.api.i18n.{ I18nSupport, Messages, MessagesApi }
import play.api.libs.concurrent.Execution.Implicits._
import play.api.mvc.Controller
import utils.auth.DefaultEnv

import scala.concurrent.Future

class ResetPasswordController @Inject() (
  val messagesApi: MessagesApi,
  silhouette: Silhouette[DefaultEnv],
  userService: UserService,
  authInfoRepository: AuthInfoRepository,
  passwordHasherRegistry: PasswordHasherRegistry,
  authTokenService: AuthTokenService
)
  extends Controller with I18nSupport {

  def view(token: UUID) = silhouette.UnsecuredAction.async { implicit request =>
    authTokenService.validate(token).map {
      case Some(authToken) => Ok(views.html.resetPassword(new myform.MyResetPasswordForm(), token))
      case None => Redirect(routes.SignInController.view()).flashing("error" -> Messages("invalid.reset.link"))
    }
  }

  def submit(token: UUID) = silhouette.UnsecuredAction.async { implicit request =>
    authTokenService.validate(token).flatMap {
      case Some(authToken) =>
        new myform.MyResetPasswordForm().bindFromRequest match {
          case form: myform.MyResetPasswordForm => Future.successful(BadRequest(views.html.resetPassword(form, token)))
          case data: myform.MyResetPasswordFormData => userService.retrieve(authToken.userID).flatMap {
            case Some(user) if user.loginInfo.providerID == CredentialsProvider.ID =>
              val passwordInfo = passwordHasherRegistry.current.hash(data.password)
              authInfoRepository.update[PasswordInfo](user.loginInfo, passwordInfo).map { _ =>
                Redirect(routes.SignInController.view()).flashing("success" -> Messages("password.reset"))
              }
            case _ => Future.successful(Redirect(routes.SignInController.view()).flashing("error" -> Messages("invalid.reset.link")))
          }
        }
      case None => Future.successful(Redirect(routes.SignInController.view()).flashing("error" -> Messages("invalid.reset.link")))
    }
  }
} 
开发者ID:serversideapps,项目名称:silhmojs,代码行数:53,代码来源:ResetPasswordController.scala

示例3: Products

//设置package包名称以及导入依赖的类
package controllers

import play.api.mvc._
import javax.inject.Inject
import play.api.i18n.{Messages, MessagesApi, I18nSupport}
import play.api.data.Form
import play.api.data.Forms.{mapping, longNumber, nonEmptyText}
import models.Product

class Products @Inject() (val messagesApi: MessagesApi) extends Controller with I18nSupport {
  def list = Action { implicit request =>
    val products = Product.findAll
    Ok(views.html.products.list(products))
  }

  def show(ean: Long) = Action {
    implicit request => Product.findByEan(ean).map {
      // rendering product details
      product => Ok(views.html.products.details(product))
    }.getOrElse(NotFound)  // return page 404
  }

  private val productForm: Form[Product] = Form(
    mapping(
      "ean" -> longNumber.verifying("validation.ean.duplicate", Product.findByEan(_).isEmpty),  // form? field? ????
      "name" -> nonEmptyText,
      "description" -> nonEmptyText
    )(Product.apply)(Product.unapply) // form? model ?? mapping
  )

  def save = Action {
    implicit request => val newProductForm = productForm.bindFromRequest()

    newProductForm.fold(
      hasErrors = {
        form => Redirect(routes.Products.newProduct()).
          flashing(Flash(form.data) + ("error" -> Messages("validation.errors")))
      },
      success = {
        newProduct => Product.add(newProduct)
        val message = Messages("products.new.success", newProduct.name)
        Redirect(routes.Products.show(newProduct.ean)).flashing("success" -> message)
      }
    )
  }

  def newProduct = Action {
    implicit request => val form = if (request2flash.get("error").isDefined)
      productForm.bind(request2flash.data)
    else
      productForm

    Ok(views.html.products.editProduct(form))
  }
} 
开发者ID:makeajourney,项目名称:play-products-example,代码行数:56,代码来源:Products.scala

示例4: CoinController

//设置package包名称以及导入依赖的类
package controllers

import javax.inject.Inject

import com.mohiva.play.silhouette.api.{Environment, Silhouette}
import com.mohiva.play.silhouette.impl.authenticators.CookieAuthenticator
import forms.CoinAddForm
import models.User
import models.coin.{Person, WorkEntry}
import models.common.Pagination
import play.api.i18n.MessagesApi
import play.api.mvc.{Action, AnyContent}

import scala.concurrent.Future


class CoinController @Inject()(
                                val messagesApi: MessagesApi,
                                val env: Environment[User, CookieAuthenticator]
                              ) extends Silhouette[User, CookieAuthenticator] {

  val itemsPerPage = 9

  
  def remove(id: Long): Action[AnyContent] = SecuredAction.async { implicit request =>
    WorkEntry.remove(id)
    Future.successful(Redirect(routes.CoinController.landing()))
  }
} 
开发者ID:wirvomgut,项目名称:curo,代码行数:30,代码来源:CoinController.scala

示例5: ApplicationController

//设置package包名称以及导入依赖的类
package controllers

import javax.inject._
import play.api._
import play.api.mvc._
import play.api.data._
import play.api.data.Forms._
import javax.inject.Inject
// Play needs these to generate form messages
import play.api.i18n.I18nSupport
import play.api.i18n.MessagesApi
import views._
import model.{PropertySearchForm}


@Singleton
class ApplicationController @Inject()(val messagesApi: MessagesApi) extends Controller with I18nSupport {

  val searchForm = Form(
    "Address" -> nonEmptyText
  )

  def index = Action {
    Ok(views.html.index("Enter an Address", searchForm, ""))
  }

  def searchProperty() = Action { implicit request =>

    PropertySearchForm.form.bindFromRequest.fold(
      // if any error in submitted data
      errors => BadRequest(views.html.index("Enter an Address", searchForm, "Error ocurred")),
      data => {
        Ok(views.html.index("Enter an Address", searchForm, data.address))
      })
  }

} 
开发者ID:jordac67,项目名称:real_estate_prices,代码行数:38,代码来源:ApplicationController.scala

示例6: PasswordSettingsData

//设置package包名称以及导入依赖的类
package controllers.my.settings

import controllers.{ HasConfig, HasUserService, Security }
import javax.inject.Inject
import jp.t2v.lab.play2.auth.AuthElement
import models.user.UserService
import models.user.Roles._
import play.api.Configuration
import play.api.data.Form
import play.api.data.Forms._
import play.api.data.validation._
import play.api.i18n.{ I18nSupport, MessagesApi }
import play.api.mvc.Controller
import scala.concurrent.{ ExecutionContext, Future }

case class PasswordSettingsData(currentPassword: String, newPassword: String, verifyPassword: String)

class PasswordSettingsController @Inject() (
    val config: Configuration,
    val users: UserService,
    val messagesApi: MessagesApi,
    implicit val ctx: ExecutionContext
  ) extends Controller with AuthElement with HasConfig with HasUserService with Security with I18nSupport {

  private val matchingPasswords: Constraint[PasswordSettingsData] = Constraint("constraints.valid"){ d =>
    if (d.newPassword == d.verifyPassword) Valid else Invalid("Passwords must match")
  }

  val passwordSettingsForm = Form(
    mapping(
      "current" -> nonEmptyText,
      "new" -> nonEmptyText,
      "verify" -> nonEmptyText
    )(PasswordSettingsData.apply)(PasswordSettingsData.unapply).verifying(matchingPasswords)
  )

  def index() = StackAction(AuthorityKey -> Normal) { implicit request =>
    Ok(views.html.my.settings.password(passwordSettingsForm, loggedIn.user))
  }

  def updatePassword() = AsyncStack(AuthorityKey -> Normal) { implicit request =>
    passwordSettingsForm.bindFromRequest.fold(
      formWithErrors =>
        Future.successful(BadRequest(views.html.my.settings.password(formWithErrors, loggedIn.user))),

      f => {
        users.updatePassword(loggedIn.user.getUsername, f.currentPassword, f.newPassword)
          .map { _ match {
            case Right(_) =>
              Redirect(routes.PasswordSettingsController.index).flashing("success" -> "Your password has been updated.")
            case Left(errorMessage) =>
              Redirect(routes.PasswordSettingsController.index).flashing("error" -> errorMessage)
          }}.recover { case t:Throwable => {
            t.printStackTrace()
            Redirect(routes.PasswordSettingsController.index).flashing("error" -> "There was an error while updating your password.")
          }}
      }
    )
  }

} 
开发者ID:pelagios,项目名称:recogito2,代码行数:62,代码来源:PasswordSettingsController.scala

示例7: LoginData

//设置package包名称以及导入依赖的类
package controllers.landing

import controllers.{ HasConfig, HasUserService, Security }
import javax.inject.{ Inject, Singleton }
import jp.t2v.lab.play2.auth.{ AuthElement, LoginLogout }
import models.document.DocumentService
import models.user.UserService
import play.api.Configuration
import play.api.data.Form
import play.api.data.Forms._
import play.api.i18n.{ I18nSupport, MessagesApi }
import play.api.mvc.{ Action, Controller }
import scala.concurrent.{ ExecutionContext, Future }

case class LoginData(usernameOrPassword: String, password: String)

@Singleton
class LoginLogoutController @Inject() (    
    val config: Configuration,
    val users: UserService,
    implicit val ctx: ExecutionContext,
    val messagesApi: MessagesApi
  ) extends Controller with AuthElement with HasConfig with HasUserService with Security with LoginLogout with I18nSupport {

  private val MESSAGE = "message"

  private val INVALID_LOGIN = "Invalid Username or Password"

  val loginForm = Form(
    mapping(
      "username" -> nonEmptyText,
      "password" -> nonEmptyText
    )(LoginData.apply)(LoginData.unapply)
  )

  def showLoginForm(destination: Option[String]) = Action { implicit request =>
    destination match {
      case None => Ok(views.html.landing.login(loginForm))
      case Some(dest) => Ok(views.html.landing.login(loginForm)).withSession("access_uri" -> dest)
    }
  }

  def processLogin = Action.async { implicit request =>
    loginForm.bindFromRequest.fold(
      formWithErrors =>
        Future(BadRequest(views.html.landing.login(formWithErrors))),

      loginData =>
        users.validateUser(loginData.usernameOrPassword, loginData.password).flatMap {
          case Some(validUser) => gotoLoginSucceeded(validUser.getUsername)
          case None => Future(Redirect(routes.LoginLogoutController.showLoginForm()).flashing(MESSAGE -> INVALID_LOGIN))
        }
    )
  }

  def logout = Action.async { implicit request =>
    gotoLogoutSucceeded
  }

} 
开发者ID:pelagios,项目名称:recogito2,代码行数:61,代码来源:LoginLogoutController.scala

示例8: LoginController

//设置package包名称以及导入依赖的类
package controllers
import javax.inject._
import models.{LoginData, UserData}
import play.api.cache._
import play.api.data.Forms._
import play.api.data._
import play.api.i18n.{I18nSupport, MessagesApi}
import play.api.mvc.{Action, _}
import services.ImpConfService
import services.MD5

@Singleton
class LoginController @Inject()(cache: CacheApi,statusService: ImpConfService)(implicit val messagesApi: MessagesApi) extends Controller with I18nSupport  {

  val loginForm = Form(
    mapping(
      "name" -> text,
      "pass"-> text
    )(LoginData.apply)(LoginData.unapply)
  )

  def index = Action { implicit request =>

    Ok(views.html.login())
  }
  def login = Action{ implicit request=>
    loginForm.bindFromRequest.fold(
      errorForm=>{

        BadRequest(views.html.login())
      },
      validForm=> {

        val user = cache.get[UserData](validForm.name)
       user match {
         case Some(UserData(name,fname,mname,lname,age,pass,mobile,gender,hobbies,status,isSuspended))=>if(isSuspended=="true")  Redirect(routes.LoginController.index()).flashing("success" -> "you has been blocked ")
          else {
            if(pass== MD5.hash(validForm.pass))  Redirect(routes.ProfileController.index())withSession (request.session + ("mySession" -> s"${validForm.name}"))
                                                else Redirect(routes.LoginController.index()).flashing("success" -> "please enter correct password")}
          case None=>  Redirect(routes.LoginController.index()).flashing("success" -> "you are not valid user")
        }
      }

    )

  }

} 
开发者ID:SHUB9914,项目名称:AjaxPlay-SHUBHAM,代码行数:49,代码来源:LoginController.scala

示例9: RestApi

//设置package包名称以及导入依赖的类
package controllers

import javax.inject.Inject

import scala.concurrent.Future
import com.mohiva.play.silhouette.api.Silhouette
import play.api.libs.json._
import play.api.mvc._
import play.api.i18n.{I18nSupport, Messages, MessagesApi}
import models.User
import User._
import com.mohiva.play.silhouette.api.actions.SecuredErrorHandler
import utils.auth.CookieEnv

class RestApi @Inject() (
                          val messagesApi: MessagesApi,
                          val silhouette: Silhouette[CookieEnv]) extends Controller with I18nSupport {

  import silhouette._

  def profile = SecuredAction.async { implicit request =>
    val json = Json.toJson(request.identity.profileFor(request.authenticator.loginInfo).get)
    val prunedJson = json.transform(
      (__ \ 'loginInfo).json.prune andThen
        (__ \ 'passordInfo).json.prune andThen
        (__ \ 'oauth1Info).json.prune)
    prunedJson.fold(
      _ => Future.successful(InternalServerError(Json.obj("error" -> Messages("error.profileError")))),
      js => Future.successful(Ok(js))
    )
  }

  val errorHandler = new SecuredErrorHandler {
    override def onNotAuthenticated(implicit request: RequestHeader) = {
      Future.successful(Unauthorized(Json.obj("error" -> Messages("error.profileUnauth"))))
    }
    override def onNotAuthorized(implicit request: RequestHeader) = {
      Future.successful(Forbidden("local.not.authorized"))
    }
  }
} 
开发者ID:tm-sukehiro,项目名称:play-hands-on,代码行数:42,代码来源:RestApi.scala

示例10: ErrorHandler

//设置package包名称以及导入依赖的类
package utils

import javax.inject.{Inject, Provider}

import com.mohiva.play.silhouette.api.actions.SecuredErrorHandler
import play.api.http.DefaultHttpErrorHandler
import play.api.i18n.{I18nSupport, Messages, MessagesApi}
import play.api.mvc.Results._
import play.api.mvc.{RequestHeader, Result}
import play.api.routing.Router
import play.api.{Configuration, OptionalSourceMapper}

import scala.concurrent.Future
import controllers.{WebJarAssets, routes}

class ErrorHandler @Inject() (
                               val messagesApi: MessagesApi,
                               env: play.api.Environment,
                               config: Configuration,
                               sourceMapper: OptionalSourceMapper,
                               router: javax.inject.Provider[Router],
                               p: Provider[WebJarAssets])
  extends DefaultHttpErrorHandler(env, config, sourceMapper, router)
    with SecuredErrorHandler with I18nSupport {

  // https://www.playframework.com/documentation/2.5.x/Migration25#Handling-legacy-components
  implicit lazy val webJarAssets = p.get()

  override def onNotAuthenticated(implicit request: RequestHeader): Future[Result] =
    Future.successful(Redirect(routes.Auth.signIn()))

  override def onNotAuthorized(implicit request: RequestHeader): Future[Result] =
    Future.successful(Redirect(routes.Auth.signIn()).flashing("error" -> Messages("error.accessDenied")))

  override def onNotFound(request: RequestHeader, message: String): Future[Result] =
    Future.successful(Ok(views.html.errors.notFound(request)))

  override def onServerError(request:RequestHeader, exception:Throwable):Future[Result] =
    Future.successful(Ok(views.html.errors.serverError(request, exception)))
} 
开发者ID:tm-sukehiro,项目名称:play-hands-on,代码行数:41,代码来源:ErrorHandler.scala

示例11: UsersController

//设置package包名称以及导入依赖的类
package controllers

import javax.inject.{Inject, Singleton}

import forms.CreateUserForm
import play.api.i18n.{I18nSupport, MessagesApi}
import play.api.mvc.{Action, Controller}
import repository.Users


@Singleton
class UsersController @Inject() (val messagesApi: MessagesApi)
  extends Controller with I18nSupport {

  def index = ???

  def show(id: Long) = Action { implicit request =>
    Users.findById(id).map { user =>
      Ok(views.html.users.show(user))
    }.getOrElse(NotFound)
  }

  // new
  def signup() = Action {
    Ok(views.html.users.signup(CreateUserForm.userForm))
  }

  def edit(id: Int) = ???

  // TODO: Protesting CSRF
  def create() = Action { implicit request =>
    CreateUserForm.userForm.bindFromRequest.fold(
      errorForm => {
        // TODO: Redirect routes.UsersController.signup()
        BadRequest(views.html.users.signup(errorForm))
      },
      user => {
        val created = Users.create(user.name, user.email, user.password)
        Redirect(routes.UsersController.show(created.id))
          .flashing("success" -> "Welcome to the Sample App!")
      }
    )
  }

  def update = ???

  def destroy = ???
} 
开发者ID:benevolent0505,项目名称:My-PlayFramework-Sample,代码行数:49,代码来源:UsersController.scala

示例12: Users

//设置package包名称以及导入依赖的类
package controllers

import javax.inject._

import actors.{WebSockets, UsersArea}
import akka.actor._
import play.api.Play.current
import play.api.data.Form
import play.api.data.Forms._
import play.api.i18n.{I18nSupport, MessagesApi}
import play.api.libs.json.JsValue
import play.api.mvc.{Action, Controller, WebSocket}

import scala.concurrent.Future

@Singleton
class Users @Inject()(val messagesApi: MessagesApi, system: ActorSystem) extends Controller with I18nSupport {
  val User = "user"

  val nickForm = Form(single("nickname" -> nonEmptyText))

  def index = Action { implicit request =>
    request.session.get(User).map { user =>
      Redirect(routes.Users.chat()).flashing("info" -> s"Redirected to chat as $user user")
    }.getOrElse(Ok(views.html.index(nickForm)))
  }

  def name = Action { implicit request =>
    nickForm.bindFromRequest.fold(
      formWithErrors => {
        BadRequest(views.html.index(formWithErrors))
      },
      nickname => {
        Redirect(routes.Users.chat())
          .withSession(request.session + (User -> nickname))
      }
    )
  }

  def leave = Action { implicit request =>
    Redirect(routes.Users.index()).withNewSession.flashing("success" -> "See you soon!")
  }

  def chat = Action { implicit request =>
    request.session.get(User).map { user =>
      Ok(views.html.chat(user))
    }.getOrElse(Redirect(routes.Users.index()))
  }

  def socket = WebSocket.tryAcceptWithActor[JsValue, JsValue] { implicit request =>
    Future.successful(request.session.get(User) match {
      case None => Left(Forbidden)
      case Some(uid) => Right(WebSockets.props(uid))
    })
  }
} 
开发者ID:maltiyadav,项目名称:messaging-system-websockets,代码行数:57,代码来源:Users.scala

示例13: ApartmentController

//设置package包名称以及导入依赖的类
package controllers

import com.google.inject.Inject
import models.{Apartment, ApartmentForm}
import play.api.i18n.{Messages, I18nSupport, MessagesApi}
import play.api.mvc.{Action, Controller}
import services.ApartmentService

import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits._


class ApartmentController @Inject()(apartmentService: ApartmentService, val messagesApi: MessagesApi) extends Controller with I18nSupport with Secured {

  def dashboard = IsAuthenticated {
  username =>
     implicit request =>
      apartmentService.listAllApartments map {
        apartments => Ok(views.html.apartment(ApartmentForm.form, apartments))
      }
  }

  def addApartment() = Action.async { implicit request =>
    ApartmentForm.form.bindFromRequest.fold(
      errorForm => Future.successful(Ok(views.html.apartment(errorForm, Seq.empty[Apartment]))),
      data => {
        val newApartment = Apartment(0, data.name, data.rooms, data.area)
        apartmentService.addApartment(newApartment).map(res =>
          Redirect(routes.ApartmentController.dashboard()).flashing(Messages("flash.success") -> res)
        )
      })

  }

  def deleteApartment(id: Long) = Action.async { implicit request =>
    apartmentService.deleteApartment(id) map { res =>
      Redirect(routes.ApartmentController.dashboard())

    }

  }
} 
开发者ID:kunalherkal,项目名称:rental-manager,代码行数:43,代码来源:ApartmentController.scala

示例14: UIController

//设置package包名称以及导入依赖的类
package controllers

import java.util.concurrent.TimeUnit
import play.api.cache.CacheApi
import play.api.data.Form
import play.api.data.Forms._
import play.api.i18n.{ I18nSupport, MessagesApi }
import play.api.mvc.{ Action, Controller }
import scala.concurrent.ExecutionContext
import scala.concurrent.duration.Duration


class UIController(val messagesApi: MessagesApi, cacheApi: CacheApi, teaHubController: TEAHubController)(implicit executionContext: ExecutionContext) extends Controller with I18nSupport {
  val togglTokenForm = Form(single("togglToken" -> text()))
  val projectName = Form(single("projectName" -> text()))

  def management = Action { implicit request => Ok(views.html.user_management()) }

  def listPost = Action { implicit request =>
    {
      togglTokenForm.bindFromRequest().fold(
        error => // Warning here because 'error' is never used
          BadRequest(views.html.setup_projects(togglTokenForm, "An error occurred.")),
        data => {
          cacheApi.set("togglToken", data, Duration(1, TimeUnit.DAYS)) // TODO: in the future this will be stored on
          // the DB
          Ok(views.html.projects())
        }
      )
    }
  }

  def listGet = Action { implicit request =>
    Ok(views.html.projects())
  }

  def setup = Action { implicit request => Ok(views.html.setup_projects(togglTokenForm, "")) }
  def details = Action { implicit request => Ok(views.html.project_details()) }

  def newProject = Action.async { implicit request =>
    teaHubController.togglProjects.map(projects => Ok(views.html.new_project(projectName, projects)))
  }

  def issues = Action { implicit request => Ok(views.html.issues()) }
  def profile = Action { implicit request => Ok(views.html.profile()) }

} 
开发者ID:lunatech-labs,项目名称:teahub,代码行数:48,代码来源:UIController.scala

示例15: Products

//设置package包名称以及导入依赖的类
package controllers

import play.api.mvc.{Action, Controller}
import models.Product
import javax.inject.Inject
import play.api.i18n.{I18nSupport, Messages, MessagesApi}


class Products @Inject()(val messagesApi: MessagesApi, implicit val configuration:play.api.Configuration) extends Controller with I18nSupport{
	def list = Action {request => 
		val products = Product.findAll
		Ok(views.html.products.list(products, Messages("application.name")))
	}

	def show(ean:Long) = Action{implicit request => 
		Product.findByEan(ean).map{ product => 
			Ok(views.html.products.details(product))
			}.getOrElse(NotFound)
	}
} 
开发者ID:WackStr,项目名称:PlayProducts,代码行数:21,代码来源:Products.scala


注:本文中的play.api.i18n.MessagesApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。