0
class InstitutionController extends Controller { 
    def updateInstitution = Action { implicit request => 
     { 
      request.body.asJson.get.validate[GallreyJsonValidationForUpdate].fold(
      valid = { 
       updateInstitution => 
       { 
         Redirect(routes.GalleryController.updateGallreyObject()).flashing("uuid"- >updateInstitution.uuid,"institutionName"->updateInstitution.institutionName,"details"->updateInstitution.details) 
       } 
      }, 
      invalid = { 
       errors => 
       { 
        val json=commonUtils.getResponse(Http.Status.BAD_REQUEST, ServerResponseMessages.VALIDATION_FAILED,JsError.toJson(errors)) 
        log.error("sending error in json{}", json) 
        BadRequest(json) 
       } 
      }) 
     } 
     } 

c'est l'action que je allez être redirigé versaction ne réoriente à une autre action dans le jeu-cadre

class GalleryController extends Controller { 
def updateGallreyObject = Action { implicit request => 
    { 
     val uuid=request.flash.get("uuid") 
     val institutionName=request.flash.get("institutionName") 
     val details=request.flash.get("details") 
     Ok("some details") 
}} 
} 

est ici le fichier boucle je suis en utilisant

contentType="Content-type: application/json"; 

data='{ "uuid" : "123" , "institutionName" : "abc" , "details" : "some details" 

}'; 
echo " " 
echo "------------------ Sending Data ------------------" 
echo " " 
echo "Content-Type : " $contentType 
echo "Data : " $data 


echo " " 
echo "------------------  Response  ------------------" 
echo " " 
echo " " 


curl --include --request POST --header "Content-type: application/json" --data "$data" http://localhost:9000/institution/update 

la réponse i obtenir est

HTTP/1.1 303 See Other 
Location: /gallery/update 
Set-Cookie: PLAY_FLASH=uuid=123 &institutionName=abc&details=some+details; Path=/; HTTPOnly 
Date: Sat, 04 Mar 2017 14:40:29 GMT 
Content-Length: 0 

voici la routePourquoi ne pas rediriger vers updateGallreyObject Action? ce que je fais mal s'il vous plaît aider, je le veux à rediriger vers updateGallreyObject action avec les données s'il vous plaît aider, je me attends à cette réponse « quelques détails »

mise à jour je l'ai déjà cette voie

POST /gallery/update         controllers.GalleryController.updateGallreyObject 

Répondre

0

Parce que vous besoin d'un mappage pour votre updateGallreyObject dans les itinéraires.

GET /galery     controllers.GalleryController.updateGallreyObject 

P.S. Reformatez votre code avant de le poster ici. Vous voudrez probablement utiliser un formateur externe tel que Scalariform ou Scalafmt.

+0

je l'ai déjà ajouté dans le fichier d'itinéraire – swaheed

0

Essayez d'utiliser match mais fold, tout comme dans la documentation: https://www.playframework.com/documentation/2.3.x/ScalaJsonCombinators#Putting-it-all-together

request.body.asJson.get.validate[GallreyJsonValidationForUpdate] match { 
    case s: JsSuccess[GallreyJsonValidationForUpdate] => { 
    val updateInstitution: GallreyJsonValidationForUpdate = s.get 

    Redirect(routes.GalleryController.updateGallreyObject()).flashing("uuid"- >updateInstitution.uuid,"institutionName"->updateInstitution.institutionName,"details"->updateInstitution.details) 
    } 
    case e: JsError => { 
    val json=commonUtils.getResponse(Http.Status.BAD_REQUEST, ServerResponseMessages.VALIDATION_FAILED,JsError.toJson(errors)) 
    log.error("sending error in json{}", json) 
    BadRequest(json) 
    } 
}