Permalink
Browse files

Closes #938. Closes #1095. Better support to asJsExp in foreign key …

…references. Better handling of Nullable fields in forms and display
  • Loading branch information...
1 parent e1cf30c commit d2d60dfe29712d9155e6c4e00fb0179426a7fe19 @dpp dpp committed Aug 24, 2011
@@ -237,6 +237,23 @@ trait MappedNullableField[NullableFieldType <: Any,OwnerType <: Mapper[OwnerType
* All fields of this type are NULLable
*/
override final def dbNotNull_? : Boolean = false
+
+ override def toString = is.map(_.toString) openOr ""
+
+ /**
+ * Create an input field for the item
+ */
+ override def _toForm: Box[NodeSeq] =
+ S.fmapFunc({s: List[String] => this.setFromAny(s)}){funcName =>
+ Full(appendFieldId(<input type={formInputType}
+ name={funcName}
+ value={is match {
+ case null => ""
+ case Full(null) => ""
+ case Full(s) => s.toString
+ case _ => ""
+ }}/>))
+ }
}
/**
@@ -250,6 +250,8 @@ extends MappedLong[T](theOwner) with MappedForeignKey[Long,T,O] with BaseForeign
def asSafeJs(obs: Box[KeyObfuscator]): JsExp =
obs.map(o => JE.Str(o.obscure(dbKeyToTable, is))).openOr(JE.Num(is))
+ override def asJsExp: JsExp = if (defined_?) super.asJsExp else JE.JsNull
+
override def asJsonValue: Box[JsonAST.JValue] =
if (defined_?) super.asJsonValue else Full(JsonAST.JNull)
@@ -28,7 +28,7 @@ import scala.xml.{NodeSeq, Text}
/**
* A menu location
*/
-trait Loc[T <: AnyRef] {
+trait Loc[T] {
def name: String
def link: Loc.Link[T]
@@ -655,11 +655,24 @@ object Loc {
}
object Snippet {
+
+ /**
+ * A trait that does nothing other than allow the disabiguation of two different call-by-name parameters
+ * for apply()
+ */
+ trait CallByNameDispatchSnippet
+
+ /**
+ * Vend the trait that does nothing other than allow the disabiguation of two different call-by-name parameters
+ * for apply()
+ */
+ implicit def vendCallByNameDispatchSnippet: CallByNameDispatchSnippet = new CallByNameDispatchSnippet {}
+
/**
* Build a Loc.Snippet instance out of a name and a DispatchSnippet (or StatefulSnippet, LiftScreen or Wizard).
* The "render" method will be invoked on the Dispatch snippet
*/
- def apply(name: String, snippet: => DispatchSnippet): Snippet =
+ def apply(name: String, snippet: => DispatchSnippet)(implicit disambiguate: CallByNameDispatchSnippet): Snippet =
new Snippet(name, ns => snippet.dispatch("render")(ns)) // Issue #919
/**

0 comments on commit d2d60df

Please sign in to comment.