[Lift] Re: date management
The code Derek included: // Set the up the RequstVar to initialize a new MyUserClass by default object userVar extends RequestVar[MyUserClass](MyUserClass.create) By default creates a MyUserClass instance. Maybe you want to init the RequestVar as an Empty Box and then conditionally modify it. object userVar extends RequestVar[Box[MyUserClass]](Empty) Then after you save, you can set the RequestVar to Empty again. Without looking at your code, this is a guess, I could be/probably am wrong. On Jun 25, 12:10 am, g-man wrote: > OK, things are working well with RequestVar, but now I need to know > how to kill it! > > After I create and save my record, if I refresh the browser, I get > another record created. I did a temporary hack-fix with: > > if(! myRecord.saved_?) > > but I would just like to kill the RequestVar after the first round of > record creation-saving. > > In terms of your example above, how would I do that? > > On Jun 8, 7:18 am, Derek Chen-Becker wrote: > > > Generally you can either use RequestVars or a StatefulSnippet class to keep > > the values around on form resubmission. If you're using a Mapper class, you > > really just need one RequestVar to hold your Mapper instance. For example, > > if I had a Mapper class for a person with first name, last name and email, I > > could do something like this in my snippet class: > > > ... > > // Set the up the RequstVar to initialize a new MyUserClass by default > > object userVar extends RequestVar[MyUserClass](MyUserClass.create) > > > def editMyUser (xhtml : NodeSeq) : NodeSeq = { > > // We define a val to capture the current value of the userVar. This > > will be used to reinject later, as well > > // as for current access > > val current = userVar.is > > ... > > def saveMyUser () { > > current.validate match { ... > > ... > > current.save > > } > > } > > > bind("user", xhtml, > > // First we re-inject the current MyUserClass instance using a > > hidden field > > "current" -> SHtml.hidden(() => userVar(current)) > > // normal fields follow, e.g. > > "name" -> SHtml.text(current.name.is, current.name(_)) > > // alternatively, you could do both steps in the first form > > field: > > "name" -> SHtml.text(current.name.is, { in => userVar(current); > > current.name(in) }) > > ... > > ) > > } > > ... > > > Let me know if you have any questions on that. > > > Derek > > > On Fri, Jun 5, 2009 at 9:47 PM, g-man wrote: > > > > I now have the due date arriving OK from the jQuery datepicker, and I > > > cobbled together some ugliness to give days left until the ToDo due > > > date, so that is good. > > > > My problem now is since we are not using the 'magic' of the _toForm > > > methods for the form elements, I have to set each var value for the > > > model field from the input SHtml data, as was done in the PocketChange > > > app AddEntry.scala file. > > > > What is happening is that the initialization for each var is resetting > > > the form if validation fails, so I guess I need to institute some > > > RequestVars to remember the form values for resubmission, right? > > > > All my questions will take take the form of 'how to' recipes of > > > foundational webapp elements, as you can see. My plan is to develop > > > them for a 'cookbook' section of the wiki, so that's why I am asking > > > one simple conceptual thing at a time. > > > > Therefore, what I have to learn now is all about form binding and > > > recalling form value state if validation fails, so please break that > > > down for me. > > > > Thanks as always! > > > > On Jun 3, 10:25 pm, Derek Chen-Becker wrote: > > > > Box is the base class. What you want is Full("2"). > > > > > Derek > > > > > On Wed, Jun 3, 2009 at 8:53 PM, g-man wrote: > > > > > > Very good! > > > > > > I did a little homework, rearranged some things, and am getting some > > > > > nice results with the 'manual method'... > > > > > > Since I am following the PocketChange app now rather than the ToDo > > > > > example, there is no 'todo' val in scope to bind, so the > > > > > todo.priority.toForm method will not work. > > > > > > I have SHtml.select working with a mapping for my choices, and I can > > > > > use Empty for my default, but how do I get a Box["2"] as my default? > > > > > > On Jun 3, 7:21 am, Derek Chen-Becker wrote: > > > > > > The only issue I would mention is that there's currently an open > > > ticket > > > > > > because MappedDateTime won't save the time portion when you use > > > Derby. I > > > > > > haven't had time to triage this yet. > > > > > > > Derek > > > > > > > On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett > > > > > > > >wrote: > > > > > > > > Greg, > > > > > > > > I dont really use toForm; have you explored "doing it manually"? > > > > > > > It > > > > > > > seems like that would be able to tell you if there is a problem > > > with > > > > > > >
[Lift] Re: date management
OK, things are working well with RequestVar, but now I need to know how to kill it! After I create and save my record, if I refresh the browser, I get another record created. I did a temporary hack-fix with: if(! myRecord.saved_?) but I would just like to kill the RequestVar after the first round of record creation-saving. In terms of your example above, how would I do that? On Jun 8, 7:18 am, Derek Chen-Becker wrote: > Generally you can either use RequestVars or a StatefulSnippet class to keep > the values around on form resubmission. If you're using a Mapper class, you > really just need one RequestVar to hold your Mapper instance. For example, > if I had a Mapper class for a person with first name, last name and email, I > could do something like this in my snippet class: > > ... > // Set the up the RequstVar to initialize a new MyUserClass by default > object userVar extends RequestVar[MyUserClass](MyUserClass.create) > > def editMyUser (xhtml : NodeSeq) : NodeSeq = { > // We define a val to capture the current value of the userVar. This > will be used to reinject later, as well > // as for current access > val current = userVar.is > ... > def saveMyUser () { > current.validate match { ... > ... > current.save > } > } > > bind("user", xhtml, > // First we re-inject the current MyUserClass instance using a > hidden field > "current" -> SHtml.hidden(() => userVar(current)) > // normal fields follow, e.g. > "name" -> SHtml.text(current.name.is, current.name(_)) > // alternatively, you could do both steps in the first form > field: > "name" -> SHtml.text(current.name.is, { in => userVar(current); > current.name(in) }) > ... > ) > } > ... > > Let me know if you have any questions on that. > > Derek > > On Fri, Jun 5, 2009 at 9:47 PM, g-man wrote: > > > I now have the due date arriving OK from the jQuery datepicker, and I > > cobbled together some ugliness to give days left until the ToDo due > > date, so that is good. > > > My problem now is since we are not using the 'magic' of the _toForm > > methods for the form elements, I have to set each var value for the > > model field from the input SHtml data, as was done in the PocketChange > > app AddEntry.scala file. > > > What is happening is that the initialization for each var is resetting > > the form if validation fails, so I guess I need to institute some > > RequestVars to remember the form values for resubmission, right? > > > All my questions will take take the form of 'how to' recipes of > > foundational webapp elements, as you can see. My plan is to develop > > them for a 'cookbook' section of the wiki, so that's why I am asking > > one simple conceptual thing at a time. > > > Therefore, what I have to learn now is all about form binding and > > recalling form value state if validation fails, so please break that > > down for me. > > > Thanks as always! > > > On Jun 3, 10:25 pm, Derek Chen-Becker wrote: > > > Box is the base class. What you want is Full("2"). > > > > Derek > > > > On Wed, Jun 3, 2009 at 8:53 PM, g-man wrote: > > > > > Very good! > > > > > I did a little homework, rearranged some things, and am getting some > > > > nice results with the 'manual method'... > > > > > Since I am following the PocketChange app now rather than the ToDo > > > > example, there is no 'todo' val in scope to bind, so the > > > > todo.priority.toForm method will not work. > > > > > I have SHtml.select working with a mapping for my choices, and I can > > > > use Empty for my default, but how do I get a Box["2"] as my default? > > > > > On Jun 3, 7:21 am, Derek Chen-Becker wrote: > > > > > The only issue I would mention is that there's currently an open > > ticket > > > > > because MappedDateTime won't save the time portion when you use > > Derby. I > > > > > haven't had time to triage this yet. > > > > > > Derek > > > > > > On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett > > > > > >wrote: > > > > > > > Greg, > > > > > > > I dont really use toForm; have you explored "doing it manually"? It > > > > > > seems like that would be able to tell you if there is a problem > > with > > > > > > toForm on MappedDateTime. > > > > > > > I use mapped date time quite a bit and have no problems at all > > > > > > persisting the dates :-) > > > > > > > Cheers, Tim > > > > > > > On Jun 3, 3:09 am, g-man wrote: > > > > > > > Are there no ideas for my problem? > > > > > > > > I have many more questions saved up, but would like to clear each > > out > > > > > > > before starting a new one. > > > > > > > > Thanks again! > > > > > > > > On May 31, 1:57 pm, g-man wrote: > > > > > > > > > As I proceed to enhance the ToDo example, I have added a new > > field > > > > to > > > > > > > > the ToDo.scala model: > > > > > > > > > object dueOn extends MappedDateTime(this) { > > > > > > > > final val dateFormat = DateFormat.getDateIns
[Lift] Re: date management
Nice! Things are moving now, thanks to your guidance. It's a matter of: 1) knowing what you want to do, and 2) knowing how to do things with Scala... duh, yea. I will post my results in a few days after I get everything working well, but the RequestVar is doing its job. On Jun 8, 7:18 am, Derek Chen-Becker wrote: > Generally you can either use RequestVars or a StatefulSnippet class to keep > the values around on form resubmission. If you're using a Mapper class, you > really just need one RequestVar to hold your Mapper instance. For example, > if I had a Mapper class for a person with first name, last name and email, I > could do something like this in my snippet class: > > ... > // Set the up the RequstVar to initialize a new MyUserClass by default > object userVar extends RequestVar[MyUserClass](MyUserClass.create) > > def editMyUser (xhtml : NodeSeq) : NodeSeq = { > // We define a val to capture the current value of the userVar. This > will be used to reinject later, as well > // as for current access > val current = userVar.is > ... > def saveMyUser () { > current.validate match { ... > ... > current.save > } > } > > bind("user", xhtml, > // First we re-inject the current MyUserClass instance using a > hidden field > "current" -> SHtml.hidden(() => userVar(current)) > // normal fields follow, e.g. > "name" -> SHtml.text(current.name.is, current.name(_)) > // alternatively, you could do both steps in the first form > field: > "name" -> SHtml.text(current.name.is, { in => userVar(current); > current.name(in) }) > ... > ) > } > ... > > Let me know if you have any questions on that. > > Derek > > On Fri, Jun 5, 2009 at 9:47 PM, g-man wrote: > > > I now have the due date arriving OK from the jQuery datepicker, and I > > cobbled together some ugliness to give days left until the ToDo due > > date, so that is good. > > > My problem now is since we are not using the 'magic' of the _toForm > > methods for the form elements, I have to set each var value for the > > model field from the input SHtml data, as was done in the PocketChange > > app AddEntry.scala file. > > > What is happening is that the initialization for each var is resetting > > the form if validation fails, so I guess I need to institute some > > RequestVars to remember the form values for resubmission, right? > > > All my questions will take take the form of 'how to' recipes of > > foundational webapp elements, as you can see. My plan is to develop > > them for a 'cookbook' section of the wiki, so that's why I am asking > > one simple conceptual thing at a time. > > > Therefore, what I have to learn now is all about form binding and > > recalling form value state if validation fails, so please break that > > down for me. > > > Thanks as always! > > > On Jun 3, 10:25 pm, Derek Chen-Becker wrote: > > > Box is the base class. What you want is Full("2"). > > > > Derek > > > > On Wed, Jun 3, 2009 at 8:53 PM, g-man wrote: > > > > > Very good! > > > > > I did a little homework, rearranged some things, and am getting some > > > > nice results with the 'manual method'... > > > > > Since I am following the PocketChange app now rather than the ToDo > > > > example, there is no 'todo' val in scope to bind, so the > > > > todo.priority.toForm method will not work. > > > > > I have SHtml.select working with a mapping for my choices, and I can > > > > use Empty for my default, but how do I get a Box["2"] as my default? > > > > > On Jun 3, 7:21 am, Derek Chen-Becker wrote: > > > > > The only issue I would mention is that there's currently an open > > ticket > > > > > because MappedDateTime won't save the time portion when you use > > Derby. I > > > > > haven't had time to triage this yet. > > > > > > Derek > > > > > > On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett > > > > > >wrote: > > > > > > > Greg, > > > > > > > I dont really use toForm; have you explored "doing it manually"? It > > > > > > seems like that would be able to tell you if there is a problem > > with > > > > > > toForm on MappedDateTime. > > > > > > > I use mapped date time quite a bit and have no problems at all > > > > > > persisting the dates :-) > > > > > > > Cheers, Tim > > > > > > > On Jun 3, 3:09 am, g-man wrote: > > > > > > > Are there no ideas for my problem? > > > > > > > > I have many more questions saved up, but would like to clear each > > out > > > > > > > before starting a new one. > > > > > > > > Thanks again! > > > > > > > > On May 31, 1:57 pm, g-man wrote: > > > > > > > > > As I proceed to enhance the ToDo example, I have added a new > > field > > > > to > > > > > > > > the ToDo.scala model: > > > > > > > > > object dueOn extends MappedDateTime(this) { > > > > > > > > final val dateFormat = DateFormat.getDateInstance > > > > > > > > (DateFormat.SHORT) > > > > > > > > override def asHtml = Text(dateFormat.format(is))
[Lift] Re: date management
Generally you can either use RequestVars or a StatefulSnippet class to keep the values around on form resubmission. If you're using a Mapper class, you really just need one RequestVar to hold your Mapper instance. For example, if I had a Mapper class for a person with first name, last name and email, I could do something like this in my snippet class: ... // Set the up the RequstVar to initialize a new MyUserClass by default object userVar extends RequestVar[MyUserClass](MyUserClass.create) def editMyUser (xhtml : NodeSeq) : NodeSeq = { // We define a val to capture the current value of the userVar. This will be used to reinject later, as well // as for current access val current = userVar.is ... def saveMyUser () { current.validate match { ... ... current.save } } bind("user", xhtml, // First we re-inject the current MyUserClass instance using a hidden field "current" -> SHtml.hidden(() => userVar(current)) // normal fields follow, e.g. "name" -> SHtml.text(current.name.is, current.name(_)) // alternatively, you could do both steps in the first form field: "name" -> SHtml.text(current.name.is, { in => userVar(current); current.name(in) }) ... ) } ... Let me know if you have any questions on that. Derek On Fri, Jun 5, 2009 at 9:47 PM, g-man wrote: > > I now have the due date arriving OK from the jQuery datepicker, and I > cobbled together some ugliness to give days left until the ToDo due > date, so that is good. > > My problem now is since we are not using the 'magic' of the _toForm > methods for the form elements, I have to set each var value for the > model field from the input SHtml data, as was done in the PocketChange > app AddEntry.scala file. > > What is happening is that the initialization for each var is resetting > the form if validation fails, so I guess I need to institute some > RequestVars to remember the form values for resubmission, right? > > All my questions will take take the form of 'how to' recipes of > foundational webapp elements, as you can see. My plan is to develop > them for a 'cookbook' section of the wiki, so that's why I am asking > one simple conceptual thing at a time. > > Therefore, what I have to learn now is all about form binding and > recalling form value state if validation fails, so please break that > down for me. > > Thanks as always! > > > On Jun 3, 10:25 pm, Derek Chen-Becker wrote: > > Box is the base class. What you want is Full("2"). > > > > Derek > > > > On Wed, Jun 3, 2009 at 8:53 PM, g-man wrote: > > > > > Very good! > > > > > I did a little homework, rearranged some things, and am getting some > > > nice results with the 'manual method'... > > > > > Since I am following the PocketChange app now rather than the ToDo > > > example, there is no 'todo' val in scope to bind, so the > > > todo.priority.toForm method will not work. > > > > > I have SHtml.select working with a mapping for my choices, and I can > > > use Empty for my default, but how do I get a Box["2"] as my default? > > > > > On Jun 3, 7:21 am, Derek Chen-Becker wrote: > > > > The only issue I would mention is that there's currently an open > ticket > > > > because MappedDateTime won't save the time portion when you use > Derby. I > > > > haven't had time to triage this yet. > > > > > > Derek > > > > > > On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett > > > >wrote: > > > > > > > Greg, > > > > > > > I dont really use toForm; have you explored "doing it manually"? It > > > > > seems like that would be able to tell you if there is a problem > with > > > > > toForm on MappedDateTime. > > > > > > > I use mapped date time quite a bit and have no problems at all > > > > > persisting the dates :-) > > > > > > > Cheers, Tim > > > > > > > On Jun 3, 3:09 am, g-man wrote: > > > > > > Are there no ideas for my problem? > > > > > > > > I have many more questions saved up, but would like to clear each > out > > > > > > before starting a new one. > > > > > > > > Thanks again! > > > > > > > > On May 31, 1:57 pm, g-man wrote: > > > > > > > > > As I proceed to enhance the ToDo example, I have added a new > field > > > to > > > > > > > the ToDo.scala model: > > > > > > > > > object dueOn extends MappedDateTime(this) { > > > > > > > final val dateFormat = DateFormat.getDateInstance > > > > > > > (DateFormat.SHORT) > > > > > > > override def asHtml = Text(dateFormat.format(is))} > > > > > > > > > Next, I added a binding in the TD.scala snippet within the add > > > method > > > > > > > of the TD class: > > > > > > > > > def doBind(form: NodeSeq) = { > > > > > > > bind("todo", form, "desc" -> todo.desc.toForm, > > > > > > > "priority" -> todo.priority.toForm, > > > > > > > "dueOn" -> todo.dueOn.toForm, > > > > > > > "submit" -> submit("create new Task", > > > > > > > chec
[Lift] Re: date management
I now have the due date arriving OK from the jQuery datepicker, and I cobbled together some ugliness to give days left until the ToDo due date, so that is good. My problem now is since we are not using the 'magic' of the _toForm methods for the form elements, I have to set each var value for the model field from the input SHtml data, as was done in the PocketChange app AddEntry.scala file. What is happening is that the initialization for each var is resetting the form if validation fails, so I guess I need to institute some RequestVars to remember the form values for resubmission, right? All my questions will take take the form of 'how to' recipes of foundational webapp elements, as you can see. My plan is to develop them for a 'cookbook' section of the wiki, so that's why I am asking one simple conceptual thing at a time. Therefore, what I have to learn now is all about form binding and recalling form value state if validation fails, so please break that down for me. Thanks as always! On Jun 3, 10:25 pm, Derek Chen-Becker wrote: > Box is the base class. What you want is Full("2"). > > Derek > > On Wed, Jun 3, 2009 at 8:53 PM, g-man wrote: > > > Very good! > > > I did a little homework, rearranged some things, and am getting some > > nice results with the 'manual method'... > > > Since I am following the PocketChange app now rather than the ToDo > > example, there is no 'todo' val in scope to bind, so the > > todo.priority.toForm method will not work. > > > I have SHtml.select working with a mapping for my choices, and I can > > use Empty for my default, but how do I get a Box["2"] as my default? > > > On Jun 3, 7:21 am, Derek Chen-Becker wrote: > > > The only issue I would mention is that there's currently an open ticket > > > because MappedDateTime won't save the time portion when you use Derby. I > > > haven't had time to triage this yet. > > > > Derek > > > > On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett > >wrote: > > > > > Greg, > > > > > I dont really use toForm; have you explored "doing it manually"? It > > > > seems like that would be able to tell you if there is a problem with > > > > toForm on MappedDateTime. > > > > > I use mapped date time quite a bit and have no problems at all > > > > persisting the dates :-) > > > > > Cheers, Tim > > > > > On Jun 3, 3:09 am, g-man wrote: > > > > > Are there no ideas for my problem? > > > > > > I have many more questions saved up, but would like to clear each out > > > > > before starting a new one. > > > > > > Thanks again! > > > > > > On May 31, 1:57 pm, g-man wrote: > > > > > > > As I proceed to enhance the ToDo example, I have added a new field > > to > > > > > > the ToDo.scala model: > > > > > > > object dueOn extends MappedDateTime(this) { > > > > > > final val dateFormat = DateFormat.getDateInstance > > > > > > (DateFormat.SHORT) > > > > > > override def asHtml = Text(dateFormat.format(is))} > > > > > > > Next, I added a binding in the TD.scala snippet within the add > > method > > > > > > of the TD class: > > > > > > > def doBind(form: NodeSeq) = { > > > > > > bind("todo", form, "desc" -> todo.desc.toForm, > > > > > > "priority" -> todo.priority.toForm, > > > > > > "dueOn" -> todo.dueOn.toForm, > > > > > > "submit" -> submit("create new Task", > > > > > > checkAndSave)} > > > > > > > Then, the todo.html template gets a bind point: > > > > > > > > > > > > > ... > > > > > > > > > > > > > > > > > > > > > > > > > When I check the database, the record does save, and all the other > > > > > > fields are OK, but the date itself is . > > > > > > > Somehow, it seems the text of the input field is not getting > > changed > > > > > > into a Date object for the database to handle, right? > > > > > > > When I look at the PocketChange app from the book, everything is > > done > > > > > > completely differently from the ToDo example (no use of _toForm, > > for > > > > > > instance). > > > > > > > I know dates and times are convoluted in Java, so what am I > > missing? > > > > > > > Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: date management
Box is the base class. What you want is Full("2"). Derek On Wed, Jun 3, 2009 at 8:53 PM, g-man wrote: > > Very good! > > I did a little homework, rearranged some things, and am getting some > nice results with the 'manual method'... > > Since I am following the PocketChange app now rather than the ToDo > example, there is no 'todo' val in scope to bind, so the > todo.priority.toForm method will not work. > > I have SHtml.select working with a mapping for my choices, and I can > use Empty for my default, but how do I get a Box["2"] as my default? > > > On Jun 3, 7:21 am, Derek Chen-Becker wrote: > > The only issue I would mention is that there's currently an open ticket > > because MappedDateTime won't save the time portion when you use Derby. I > > haven't had time to triage this yet. > > > > Derek > > > > On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett >wrote: > > > > > > > > > Greg, > > > > > I dont really use toForm; have you explored "doing it manually"? It > > > seems like that would be able to tell you if there is a problem with > > > toForm on MappedDateTime. > > > > > I use mapped date time quite a bit and have no problems at all > > > persisting the dates :-) > > > > > Cheers, Tim > > > > > On Jun 3, 3:09 am, g-man wrote: > > > > Are there no ideas for my problem? > > > > > > I have many more questions saved up, but would like to clear each out > > > > before starting a new one. > > > > > > Thanks again! > > > > > > On May 31, 1:57 pm, g-man wrote: > > > > > > > As I proceed to enhance the ToDo example, I have added a new field > to > > > > > the ToDo.scala model: > > > > > > > object dueOn extends MappedDateTime(this) { > > > > > final val dateFormat = DateFormat.getDateInstance > > > > > (DateFormat.SHORT) > > > > > override def asHtml = Text(dateFormat.format(is))} > > > > > > > Next, I added a binding in the TD.scala snippet within the add > method > > > > > of the TD class: > > > > > > > def doBind(form: NodeSeq) = { > > > > > bind("todo", form, "desc" -> todo.desc.toForm, > > > > > "priority" -> todo.priority.toForm, > > > > > "dueOn" -> todo.dueOn.toForm, > > > > > "submit" -> submit("create new Task", > > > > > checkAndSave)} > > > > > > > Then, the todo.html template gets a bind point: > > > > > > > > > > > > ... > > > > > > > > > > > > > > > > > > > > > > When I check the database, the record does save, and all the other > > > > > fields are OK, but the date itself is . > > > > > > > Somehow, it seems the text of the input field is not getting > changed > > > > > into a Date object for the database to handle, right? > > > > > > > When I look at the PocketChange app from the book, everything is > done > > > > > completely differently from the ToDo example (no use of _toForm, > for > > > > > instance). > > > > > > > I know dates and times are convoluted in Java, so what am I > missing? > > > > > > > Thanks! > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: date management
Very good! I did a little homework, rearranged some things, and am getting some nice results with the 'manual method'... Since I am following the PocketChange app now rather than the ToDo example, there is no 'todo' val in scope to bind, so the todo.priority.toForm method will not work. I have SHtml.select working with a mapping for my choices, and I can use Empty for my default, but how do I get a Box["2"] as my default? On Jun 3, 7:21 am, Derek Chen-Becker wrote: > The only issue I would mention is that there's currently an open ticket > because MappedDateTime won't save the time portion when you use Derby. I > haven't had time to triage this yet. > > Derek > > On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett > wrote: > > > > > Greg, > > > I dont really use toForm; have you explored "doing it manually"? It > > seems like that would be able to tell you if there is a problem with > > toForm on MappedDateTime. > > > I use mapped date time quite a bit and have no problems at all > > persisting the dates :-) > > > Cheers, Tim > > > On Jun 3, 3:09 am, g-man wrote: > > > Are there no ideas for my problem? > > > > I have many more questions saved up, but would like to clear each out > > > before starting a new one. > > > > Thanks again! > > > > On May 31, 1:57 pm, g-man wrote: > > > > > As I proceed to enhance the ToDo example, I have added a new field to > > > > the ToDo.scala model: > > > > > object dueOn extends MappedDateTime(this) { > > > > final val dateFormat = DateFormat.getDateInstance > > > > (DateFormat.SHORT) > > > > override def asHtml = Text(dateFormat.format(is))} > > > > > Next, I added a binding in the TD.scala snippet within the add method > > > > of the TD class: > > > > > def doBind(form: NodeSeq) = { > > > > bind("todo", form, "desc" -> todo.desc.toForm, > > > > "priority" -> todo.priority.toForm, > > > > "dueOn" -> todo.dueOn.toForm, > > > > "submit" -> submit("create new Task", > > > > checkAndSave)} > > > > > Then, the todo.html template gets a bind point: > > > > > > > > > ... > > > > > > > > > > > > > > > > > When I check the database, the record does save, and all the other > > > > fields are OK, but the date itself is . > > > > > Somehow, it seems the text of the input field is not getting changed > > > > into a Date object for the database to handle, right? > > > > > When I look at the PocketChange app from the book, everything is done > > > > completely differently from the ToDo example (no use of _toForm, for > > > > instance). > > > > > I know dates and times are convoluted in Java, so what am I missing? > > > > > Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: date management
The only issue I would mention is that there's currently an open ticket because MappedDateTime won't save the time portion when you use Derby. I haven't had time to triage this yet. Derek On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett wrote: > > Greg, > > I dont really use toForm; have you explored "doing it manually"? It > seems like that would be able to tell you if there is a problem with > toForm on MappedDateTime. > > I use mapped date time quite a bit and have no problems at all > persisting the dates :-) > > Cheers, Tim > > On Jun 3, 3:09 am, g-man wrote: > > Are there no ideas for my problem? > > > > I have many more questions saved up, but would like to clear each out > > before starting a new one. > > > > Thanks again! > > > > On May 31, 1:57 pm, g-man wrote: > > > > > > > > > As I proceed to enhance the ToDo example, I have added a new field to > > > the ToDo.scala model: > > > > > object dueOn extends MappedDateTime(this) { > > > final val dateFormat = DateFormat.getDateInstance > > > (DateFormat.SHORT) > > > override def asHtml = Text(dateFormat.format(is))} > > > > > Next, I added a binding in the TD.scala snippet within the add method > > > of the TD class: > > > > > def doBind(form: NodeSeq) = { > > > bind("todo", form, "desc" -> todo.desc.toForm, > > > "priority" -> todo.priority.toForm, > > > "dueOn" -> todo.dueOn.toForm, > > > "submit" -> submit("create new Task", > > > checkAndSave)} > > > > > Then, the todo.html template gets a bind point: > > > > > > > > ... > > > > > > > > > > > > > > When I check the database, the record does save, and all the other > > > fields are OK, but the date itself is . > > > > > Somehow, it seems the text of the input field is not getting changed > > > into a Date object for the database to handle, right? > > > > > When I look at the PocketChange app from the book, everything is done > > > completely differently from the ToDo example (no use of _toForm, for > > > instance). > > > > > I know dates and times are convoluted in Java, so what am I missing? > > > > > Thanks! > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: date management
Greg, I dont really use toForm; have you explored "doing it manually"? It seems like that would be able to tell you if there is a problem with toForm on MappedDateTime. I use mapped date time quite a bit and have no problems at all persisting the dates :-) Cheers, Tim On Jun 3, 3:09 am, g-man wrote: > Are there no ideas for my problem? > > I have many more questions saved up, but would like to clear each out > before starting a new one. > > Thanks again! > > On May 31, 1:57 pm, g-man wrote: > > > > > As I proceed to enhance the ToDo example, I have added a new field to > > the ToDo.scala model: > > > object dueOn extends MappedDateTime(this) { > > final val dateFormat = DateFormat.getDateInstance > > (DateFormat.SHORT) > > override def asHtml = Text(dateFormat.format(is))} > > > Next, I added a binding in the TD.scala snippet within the add method > > of the TD class: > > > def doBind(form: NodeSeq) = { > > bind("todo", form, "desc" -> todo.desc.toForm, > > "priority" -> todo.priority.toForm, > > "dueOn" -> todo.dueOn.toForm, > > "submit" -> submit("create new Task", > > checkAndSave)} > > > Then, the todo.html template gets a bind point: > > > > > ... > > > > > > > > > When I check the database, the record does save, and all the other > > fields are OK, but the date itself is . > > > Somehow, it seems the text of the input field is not getting changed > > into a Date object for the database to handle, right? > > > When I look at the PocketChange app from the book, everything is done > > completely differently from the ToDo example (no use of _toForm, for > > instance). > > > I know dates and times are convoluted in Java, so what am I missing? > > > Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: date management
Are there no ideas for my problem? I have many more questions saved up, but would like to clear each out before starting a new one. Thanks again! On May 31, 1:57 pm, g-man wrote: > As I proceed to enhance the ToDo example, I have added a new field to > the ToDo.scala model: > > object dueOn extends MappedDateTime(this) { > final val dateFormat = DateFormat.getDateInstance > (DateFormat.SHORT) > override def asHtml = Text(dateFormat.format(is))} > > Next, I added a binding in the TD.scala snippet within the add method > of the TD class: > > def doBind(form: NodeSeq) = { > bind("todo", form, "desc" -> todo.desc.toForm, > "priority" -> todo.priority.toForm, > "dueOn" -> todo.dueOn.toForm, > "submit" -> submit("create new Task", > checkAndSave)} > > Then, the todo.html template gets a bind point: > > > ... > > > > > When I check the database, the record does save, and all the other > fields are OK, but the date itself is . > > Somehow, it seems the text of the input field is not getting changed > into a Date object for the database to handle, right? > > When I look at the PocketChange app from the book, everything is done > completely differently from the ToDo example (no use of _toForm, for > instance). > > I know dates and times are convoluted in Java, so what am I missing? > > Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---