controllers/config/AppConfig.scala:142: could not find implicit value for parameter messages: play.api.i18n.Messages
[error] Ok(au.com.ecpr.emr.views.html.config.appconfig(appConfigData, theDateTime.toString))
package au.com.ecpr.emr.controllers.config
import java.util.Date._
import javax.inject._
import scala.concurrent.{ ExecutionContext, Future }
import play.api._
import play.api.mvc._
import play.api.i18n._
import play.api.data.Form
import play.api.data.Forms._
import play.api.data.validation.Constraints._
import play.api.libs.json.Json
import au.com.ecpr.Utilities
import au.com.ecpr.emr.models.config.SystemUser
class AppConfig @Inject() (val messagesApi: MessagesApi)(implicit ec: ExecutionContext)
extends Controller
with I18nSupport {
...
def appConfig = Action {
val appConfigData = appConfigForm.fill(CreateAppConfigForm("URL",
"subDomain",
"region",
AppModifiedByForm("GavinB",
"Gavin",
"Baumanis")))
val utilities = new au.com.ecpr.Utilities()
val theDateTime = utilities.dateTimeFormat_AU_now
// The line below is #142 - where the error is reported.
Ok(au.com.ecpr.emr.views.html.config.appconfig(appConfigData, theDateTime.toString))
} // End appconfig
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/b0c1747d-646c-415e-9cc6-9a51a68c16b0%40googlegroups.com.
import javax.inject.Inject
import play.api.i18n.I18nSupport
class MyController @Inject()(val messagesApi: MessagesApi)
extends Controller with I18nSupport {
// ...
The I18nSupport trait gives you an implicit Messages value as long as there is a Lang or a RequestHeader in the implicit scope.
Note: If you have a RequestHeader in the implicit scope, it will use the preferred language extracted from the Accept-Language header and matching one of the MessagesApi supported languages. You should add a Messages implicit parameter to your template like this: @()(implicit messages: Messages).
Note: Also, Play “knows” out of the box how to inject a MessagesApi value (that uses the DefaultMessagesApi implementation), so you can just annotate your controller with the @javax.inject.Inject annotation and let Play automatically wire the components for you.
@()(implicit messages: Messages).
@(appConfigData : Form[au.com.ecpr.emr.controllers.config.CreateAppConfigForm],
theDateTime : String)(implicit messages : Messages)
Note: Also, Play “knows” out of the box how to inject a MessagesApi value (that uses the DefaultMessagesApi implementation), so you can just annotate your controller with the @javax.inject.Inject annotation and let Play automatically wire the components for you.
expected start of definition
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/b0c1747d-646c-415e-9cc6-9a51a68c16b0%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/2b80f68b-3732-4a41-9009-f4da53af1a1e%40googlegroups.com.
Action { implicit request =>
So...While the documentation tells you, you need a RequestHeader in scope : that's (sincerely) good to know - but where is the explanation of how to ensure that you have requirement covered off in your code?Again - what he documentation lacks is a "complete" example of;A form that uses messages / il8n for field labels, headings (perhaps), ...A controller to handle the internationalised form.
(Or at least something like;"See it in action here in this g8 template...That you can get via xxxxxxx
I really don't want to sound like all I am doing is complaining.... because that's not correct.I am more than happy to contribute to the documentation - but if I can't get the code to work - and since I don't (obviously) understand the requirements to get it to work.... then assisting is (currently) out of the question.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/2b80f68b-3732-4a41-9009-f4da53af1a1e%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAA%3D11HxPisiP0iPdHAYT0uz4UU%2BiTTMwrVG8NFbtkjfe8nipdw%40mail.gmail.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Play Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/j1YdT_jIdmY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAJmgB6312YGwFkC-%2BV3pptDQ5KpFChY62J0zY%3DK5k5VoN3EAiQ%40mail.gmail.com.
package au.com.ecpr.emr.controllers.config
import java.util.Date._
import javax.inject.Inject
import scala.concurrent.{ ExecutionContext, Future }
import play.api._
import play.api.mvc._
import play.api.i18n._
import play.api.data.Form
import play.api.data.Forms._
import play.api.data.validation.Constraints._
import play.api.libs.json.Json
import au.com.ecpr.Utilities
import au.com.ecpr.emr.models.config.SystemUser
/** "Interface" between the model and the view.
* it contains the actions required for an event and ALSO contains any related business logic for
* those actions.
*
*/
class AppConfig @Inject() (val messagesApi: MessagesApi)(implicit ec: ExecutionContext)
extends Controller
with I18nSupport {
/** Class pseudo-constructor
*
* The Forms object defines the mapping method. This method takes the names and constraints of
* the form, and also takes two functions: an apply function AND an unapply function.
*
* Normally we would also create a "full name" from the first and last name. But we have left
* them separated here - to show how to used Nested values in Play forms.
*
*/
/** HTTP form data is never directly bound to your model classes. Instead, you use an instance
* of play.api.data.Form.
*
*/
val appConfigForm: Form[CreateAppConfigForm] = Form {
mapping(
"URL" -> nonEmptyText,
"subDomain" -> nonEmptyText,
"region" -> nonEmptyText,
"appModifiedBy" -> mapping(
"userName" -> text,
"firstName" -> text,
"lastName" -> text)(AppModifiedByForm.apply)(AppModifiedByForm.unapply))(CreateAppConfigForm.apply)(CreateAppConfigForm.unapply)
} // End appConfigForm
/** Default / Home Page
*
* @return the Index (home) page for the application.
* @since 0.1.0
* @version 0.1.0
* @author gavinbaumanis
*/
def index = Action {
Ok(au.com.ecpr.emr.views.html.index())
} // End index
/** System Administration menu
*
* @return the System Administration page for the application.
* @since 0.1.0
* @version 0.1.0
* @author gavinbaumanis
*/
def sysConfig = Action {
Ok(au.com.ecpr.emr.views.html.config.sysconfig())
} // End sysconfig
/** Application Configuration Actions
*
* @return the Application Configuration page for THIS install
* @since 0.1.0
* @version 0.1.0
* @author gavinbaumanis
*/
def appConfig = Action { implicit request =>
/** Get the current values stored in the database to display in the view via the above
* mapping.
*
*/
/** TODO: get data from data source Then replace handwritten values with those retrieved
*
*/
val appConfigData = appConfigForm.fill(CreateAppConfigForm("URL",
"subDomain",
"region",
AppModifiedByForm("GavinB",
"Gavin",
"Baumanis")))
// Display the HTML form for THIS Application's System Configuration
/** REMOVEME :
* This is temporary for us to create a NOW timestamp to show in the prototype. When
* we start retrieving real data this will go away.
*
*/
val utilities = new au.com.ecpr.Utilities()
val theDateTime = utilities.dateTimeFormat_AU_now
// Display the HTML form for THIS Application's System Configuration
Ok(au.com.ecpr.emr.views.html.config.appconfig(appConfigData, theDateTime.toString))
} // End appconfig
/** SAVE the contents of the AppConfig Form.
*
*/
def appConfigSubmit = Action {
// TODO: verify the contents of the form are valid
// TODO: save the form
// Saved. Now return to the SYS config Menu
Redirect(au.com.ecpr.emr.controllers.config.routes.AppConfig.sysConfig)
} // End appconfigsubmit
} // End Application controller class
/** Case classes
*
* The following case classes are used "here" within the controller only.
* It is quite often the case that the model representation and that which is needed within a view
* are different.
*
* So we can use the controller as an appropriate place to hold this interfacing code.
*/
/** Interfacing class between the model and the view for AppModifiedByForm
* @param userName The user name of the logged-in user completing this change
* @param firstName The first name of the logged-in user completing this change
* @param lastName The last name of the logged-in user completing this change
* @since 0.1.0
* @version 0.1.0
* @author gavinbaumanis
*/
case class AppModifiedByForm(userName: String, firstName: String, lastName: String)
/** Interfacing class between the model and the view for CreateAppConfigForm
* @param subDomain the subDomain to prepend to ecpr.com.au for distinguishing between sites
* @param region the region used for setting date / time locales.
* @param modifiedBy form that contains modifiedBy data
* @since 0.1.0
* @version 0.1.0
* @author gavinbaumanis
*/
case class CreateAppConfigForm(URL: String,
subDomain: String,
region: String,
modifiedBy: AppModifiedByForm)
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAA%3D11Hxgy98wGzzzoXPtvV5ZrbjTHJhvSvjNKgM7qNRxLQcG5w%40mail.gmail.com.--
You received this message because you are subscribed to a topic in the Google Groups "Play Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/j1YdT_jIdmY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAB6eXyXT6mYWu4ud6R4DTVkPPkjpAdvPxsR7oKEM7iREoVxM%3DA%40mail.gmail.com.
The annotation goes on the constructor, exactly as shown in the code example at the beginning of your email. The annotation is just needed to tell your runtime DI framework that an instance can be created by calling that constructor. There's nothing special here; this should be the same as in all the examples in the documentation, just with different constructor parameters.
public MyClass {
@javax.inject.Inject
public MyClass(play.i18n.MessagesApi messagesApi) { ... }
expected start of definition
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAJmgB61%2BGZX7ELwCL5%2BdXyii8dLpuRTxNCGVW3sQsDMUw6tDtg%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAB6eXyU3OcCx7wV1iWfqA8yR44DdsKAtYVgH3h2M8LuLAeChgQ%40mail.gmail.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Play Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/j1YdT_jIdmY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAA%3D11Hyw7YFc8MgsANq_w45ca8up%2B_Qghtc0768btd2w0T6Kqg%40mail.gmail.com.
class InsuranceDetails @Inject() (val messagesApi: MessagesApi)(implicit ec: ExecutionContext)
extends Controller
with I18nSupport {
...
def insuranceDetails = Action { implicit request =>
...
The views start with;
@(insuranceDetailsData : Form[au.com.ecpr.emr.controllers.pas.CreateInsuranceDetailsForm],
theDateTime : String)(implicit messages : Messages)
...
NoClassDefFoundError: play/api/i18n/I18nSupport$ResultWithLang
No source available, here is the exception stack trace:
->java.lang.NoClassDefFoundError: play/api/i18n/I18nSupport$ResultWithLang
java.lang.Class.getDeclaredMethods0(Native Method)
java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
java.lang.Class.getDeclaredMethods(Class.java:1975)
com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:688)
com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:380)
com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165)
com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:616)
com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:572)
com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:558)
com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:887)
com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:808)
com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:285)
com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:217)
com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:893)
com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:46)
com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50)
com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:134)
com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
com.google.inject.Guice.createInjector(Guice.java:99)
com.google.inject.Guice.createInjector(Guice.java:84)
play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:137)
play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:163)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:160)
play.utils.Threads$.withContextClassLoader(Threads.scala:21)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:160)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:125)
scala.Option.map(Option.scala:146)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:125)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:123)
scala.util.Success.flatMap(Try.scala:231)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:123)
play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:115)
scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/3517b6af-a24e-44be-b387-dfc130362d07%40googlegroups.com.
-Gavin.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAB6eXyU3OcCx7wV1iWfqA8yR44DdsKAtYVgH3h2M8LuLAeChgQ%40mail.gmail.com.
--
--
You received this message because you are subscribed to a topic in the Google Groups "Play Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/j1YdT_jIdmY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/CAA%3D11Hyw7YFc8MgsANq_w45ca8up%2B_Qghtc0768btd2w0T6Kqg%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/7ccc2e5d-7cda-4da0-8e99-3d20023e7405%40googlegroups.com.
NoClassDefFoundError: play/api/i18n/I18nSupport$ResultWithLang