Custom Views in SecureSocial in Java

I saw several questions on this topic, but no one answered the part I was stuck on. By the way, based on the problems that people face, I could offer to provide a standard java version of TemplatesPlugin in the end.

The problem I have is that I copied the two required views from SecureSocial to my views folder and changed RequestHeader, as others noted: play.api.mvc.RequestHeader, and now I get:

ambiguous implicit values: both method requestHeader in object PlayMagicForJava of type => play.api.mvc.RequestHeader and value request of type play.api.mvc.RequestHeader match expected type play.api.mvc.RequestHeader

Version: Play-2.1.1, Java 7, SecureSocial from the wizard.

EDIT:

Play Compile:

[error] C:\Java\AwsConsole\app\views\secure\login.scala.html:41: ambiguous impli
cit values:
[error]  both method requestHeader in object PlayMagicForJava of type => play.ap
i.mvc.RequestHeader
[error]  and value request of type play.api.mvc.RequestHeader
[error]  match expected type play.api.mvc.RequestHeader
[error]                         @provider(p.id)
[error]                                  ^
[error] C:\Java\AwsConsole\app\views\secure\provider.scala.html:20: ambiguous im
plicit values:
[error]  both method requestHeader in object PlayMagicForJava of type => play.ap
i.mvc.RequestHeader
[error]  and value request of type play.api.mvc.RequestHeader
[error]  match expected type play.api.mvc.RequestHeader
[error]                 <form action = "@securesocial.core.providers.utils.Route
sHelper.authenticateByPost("userpass").absoluteURL(IdentityProvider.sslEnabled)"

[error]
                                                  ^
[error] two errors found
[error] (compile:compile) Compilation failed

View after playback run:

Internal server error, for (GET) [/] ->

sbt.PlayExceptions$CompilationException: Compilation error[ambiguous implicit va
lues:
 both method requestHeader in object PlayMagicForJava of type => play.api.mvc.Re
questHeader
 and value request of type play.api.mvc.RequestHeader
 match expected type play.api.mvc.RequestHeader]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun
$apply$16.apply(PlayReloader.scala:349) ~[na:na]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15$$anonfun
$apply$16.apply(PlayReloader.scala:349) ~[na:na]
        at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(Pl
ayReloader.scala:349) ~[na:na]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$2$$anonfun$apply$15.apply(Pl
ayReloader.scala:346) ~[na:na]
        at scala.Option.map(Option.scala:133) ~[scala-library.jar:na]
+5
source share
1 answer

, , RoutesHelper.authenticateByPost( "userpass" ). absoluteURL. :

  • java TemplatesPlugin getLoginPage:

    @Override
    public <A> Html getLoginPage(final play.api.mvc.Request<A> request, final Form<Tuple2<String, String>> form,
            final Option<String> msg) {
        return views.html.login.render(request, form, msg);
    }
    
  • ( ) login.scala.html :

    @(request: play.api.mvc.RequestHeader, loginForm: play.api.data.Form[(String,String)], errorMsg: Option[String] = None)
    
  • login.scala.html provider, ( ).

    • login.scala.html 41,

      @provider(p.id)
      

      @provider(request, p.id)
      
    • login.scala.html 55,

      @provider("userpass", Some(loginForm))
      

      @provider(request, "userpass", Some(loginForm))
      
  • ( ) provider.scala.html , :

    @(request: play.api.mvc.RequestHeader, providerId: String, loginForm: Option[play.api.data.Form[(String, String)]] = None)
    
  • 20 ( , RuntimeException: There is no HTTP Context available from here):

    <form action = "@securesocial.core.providers.utils.RoutesHelper.authenticateByPost("userpass").absoluteURL(IdentityProvider.sslEnabled)(request)"
    

, , .

: java TemplatesPlugin scala ( ).

+8

All Articles