This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final FormMapping<Registration> registrationForm = | |
Forms.automatic(Registration.class, "registration") | |
.nested(Forms.automatic(Address.class, "contactAddress", | |
Forms.factoryMethod(Address.class, "getInstance")).build()) | |
.build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final FormMapping<RegDate> regDateMapping = | |
Forms.basic(RegDate.class, "regDate").fields("month", "year").build(); | |
private static final FormMapping<Registration> registrationForm = | |
Forms.basic(Registration.class, "registration") | |
// whitelist of properties to bind | |
.fields("attendanceReasons", "cv", "interests", "email") | |
.nested(Forms.automatic(UploadedFileWrapper.class, "certificates", | |
null, MappingType.LIST).build()) | |
.nested(Forms.basic(Address.class, "contactAddress", | |
Forms.factoryMethod(Address.class, "getInstance")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final FormMapping<Person> personForm = | |
Forms.automatic(Person.class, "person").build(); | |
… | |
FormData<Person> formData = new FormData<Person>(person, null); | |
FormMapping<Person> filledForm = personForm.fill(formData); | |
// push filledForm to template … | |
… | |
FormData<Person> formData = personForm.bind( | |
new HttpServletRequestParams(request)); | |
if (formData.isValid()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.spinoco.dojo | |
import scalaz.concurrent.Task | |
import scalaz.stream.{ process1, Process } | |
import Process._ | |
import scala.concurrent.duration._ | |
import scalaz.stream.io | |
/* | |
Time to put it all together. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.spinoco.dojo | |
import scalaz.stream.Process | |
import Process._ | |
import scalaz.concurrent.Task | |
import scala.util.Random | |
object Dojo extends Dojo | |
trait Dojo { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object NonDefaultResources { | |
implicit object MySpecificUrlResource extends Resource[URL] { | |
// ... | |
} | |
} | |
def main(args: Array[String]) { | |
import NonDefaultResources.MySpecificUrlResource | |
println("Children of URL: \n: " + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ad 1) Type class trait ("utility" rozhraní, na které budou | |
// adaptovány konkrétní zdroje): | |
trait Resource[R] { | |
def hasChildren(res: R): Boolean | |
def children(res: R): Seq[R] | |
} | |
// Ad 2) Companion object s výchozími implicitními implementacemi | |
// type class traitu pro URL a File: | |
object Resource { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.examples.img | |
import java.io.File | |
import scala.sys.process._ | |
class ImageMagickConverter(convertExec: String) { | |
def resizeImage(in: File, out: File, width: Int, height: Int, quality: Int = ImageMagickConverter.DefaultQuality): Boolean = { | |
val qual = if (quality < 0) ImageMagickConverter.DefaultQuality else if (quality > 100) 100 else quality | |
val inAbsPath = in.getAbsolutePath() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
import play.api.mvc.Action | |
import play.api.mvc.Controller | |
import scala.concurrent.future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import play.api.Logger | |
object Performance extends Controller { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
concurrent.Future { | |
// Nejaky blokujici kod pristupujici k databazi | |
}(Contexts.myDbOperationContext) |
NewerOlder