Hi Chris, cool approach, maybe can be an entry into howto wikis?
Angelo Chris Lewis-5 wrote: > > > > 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] >>> >>> >>> >>> >> >> > > -- > http://thegodcode.net > > > -- View this message in context: http://www.nabble.com/T5%3A-form%2C-action%2C-result-tp18795277p18829911.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]