Cool, thanks :-) Martijn Brinkers (List) wrote: > That's exactly what I do as well. > > Martijn > > On Sun, 2008-08-03 at 10:49 -0400, Chris Lewis wrote: > >> Angelo, >> >> Following are the very trimmed down versions of my template and page >> class. It shows the delegate and blocks, and how the block to render is >> determined. I didn't want to use a traditional page return for a few >> reasons: 1) Displaying a simple result message doesn't really need a >> full page. 2) This process will probably end up being ajax, which will >> probably mean I'll need the blocks anyway (unless I use a different ajax >> method). >> >> So anyway, here it is: >> >> >> Info.tml >> >> <div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" >> t:type="layouts/general"> >> >> <t:delegate to="content" /> >> >> <t:block id="infoRequest"> >> <div t:type="form" t:id="infoRequest"> >> <!-- ... form details ... --> >> </form> >> </t:block> >> >> <t:block id="messageSent">Thanks!</t:block> >> </div> >> >> >> Info.java >> >> public class Info { >> >> @Persist("flash") >> private Block content; >> >> @Inject >> private Block messageSent; >> >> @Inject >> private Block infoRequest; >> >> void onActivate() { >> if(content == null) >> content = infoRequest; >> } >> >> void onSuccessFromInfoRequest() { >> //Process form - update/save/create entity, send email, etc. >> >> //Set our content block to the messageSent block. >> content = messageSent; >> } >> >> public Block getContent() { >> return content; >> } >> >> } >> >> >> chris >> >> Angelo Chen wrote: >> >>> hi cris, >>> >>> sounds interesting, how about a sample code/template to let us understand >>> more? thanks. >>> >>> angelo >>> >>> >>> Chris Lewis-5 wrote: >>> >>> >>>> Hello all, >>>> >>>> I'm wondering how others handle a simple flow where a user fills out a >>>> form, form is processed, and then a message is shown as a result ("ok" >>>> or "failed"). I have a simple contact form and am handling this like so: >>>> >>>> In my template I have 2 blocks: 1 is the form and the other is the >>>> message (or a place holder). There is also a t:delegate that will render >>>> the page property "content", which is just another block that will be >>>> assigned the form or message block. >>>> >>>> Now because I have 2 different possible "bodies" (the blocks), I have to >>>> have some logic to make sure the correct one gets displayed. So my the >>>> page's content property is annotated as @Persist("flash"), and at the >>>> end of the form submission I set the content member to a message. It's >>>> persisted, so that works. To get the initial content (the form) to >>>> render, I check if the content property is null in onActivate, and if so >>>> assign the form block. >>>> >>>> It works nicely, and I was wondering how others were handling this >>>> common use case and if something stinks about my method. >>>> >>>> Thanks! >>>> >>>> chris >>>> >>>> -- >>>> http://thegodcode.net >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>>> For additional commands, e-mail: [EMAIL PROTECTED] >>>> >>>> >>>> >>>> >>>> >>> >>> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > >
-- http://thegodcode.net