Hi Thiago,

As you suggested, I looked into blocks and the delegate component
instead. Now my UI code is all nicely in templates hooked up to
different components. My code for the forms is nicely in separate
classes away from the UI. You saved me hours of work by pointing me in
the right direction with that, and no doubt a lot of headaches in the
future. I also wasn't aware that "Tapestry never interprets HTML
generated in MarkupWriter or Element or OutputRaw", so that's good to
know for future (but should be unnecessary anyway).

I really appreciate your help.

Steve (Still a tapestry noob, but ever so slightly less now).

On 12 August 2013 13:44, Thiago H de Paula Figueiredo
<thiag...@gmail.com> wrote:
> On Mon, 12 Aug 2013 07:27:07 -0300, Steve <steves...@gmail.com> wrote:
>
>> Hi!
>
>
> Hi!
>
>
>> I have a component at the moment, aptly named "HelloComponent". The
>> component has a void renderMessage method in it. The method uses a
>> parameter which is passed to the component which it uses create an
>> object (All of the possible objects inherit from the same interface),
>> which is then uses to get a form. The form is then returned as a
>> string and is written out using the writer.write method.
>
>
> Why are you returning the form as a String instead of rendering it through a
> template? Unless you have an incredibly specific requirement, it doesn't
> make any sense and only complicates stuff needlessly.
>
>
>> The intention
>> is that the form shows on the page where the component is - and this
>> work. Now actual problem is when the form is submitted. I created an
>> "Object onSuccess()" method in the component, and it seemed to not be
>> called.
>
>
> onSuccess() and other Form component events are only triggered if you use
> the Form component in a template. Tapestry never interprets HTML generated
> in MarkupWriter or Element or OutputRaw.
>
>
>> So, my question is, if I write a form using the renderMessage method
>> inside a component, which method does that trigger and in which class
>> (Page class or component)?
>
>
> It will trigger no event in no class, explanation above.
>
>
>> The reason I am doing it this way is
>> because the intention is to have many different forms (Depending on
>> which object needs setting up). The form is meant to come from the
>> object itself (The interface has a method getConfigurationForm which
>> makes it) and passes it to the component.
>
>
> You know mixing entity and UI code is a very, very, very wrong thing, right?
> ;) I'd never, never ever do that. Why do you want the form to come from the
> object itself? I really can't imagine a good reason for doing so, specially
> inside a Tapestry component.
>
>
>> The component when the data
>> is submitted will put that into the object (or that is the idea).
>
>
> If you don't really need to have the object pass the form to your component,
> and I guess you probably don't need that, I think you should use blocks and
> the Delegate component instead. See this example:
> http://tapestry.apache.org/switching-cases.html. You'd just need to adapt
> the logic to know which block (each one containing a different form) will be
> used for a given object (the getCase() method).
>
>
>> There is a good chance i'm doing something very wrong here, but I
>> can't see why it's not working, or what a better way is.
>
>
> You're right about this. :)
>
>
>> Steve (Tapestry noob for now, but hopefully not for long).
>
>
> :D
>
>
>> P.S, sorry for posting this in the wrong topic originally, I now see
>> how the mailing list works - sorry for that.
>
>
> PS: I'm sorry for suggesting that for you and not noticing that you've
> already posted in the right way. :)
>
> --
> Thiago H. de Paula Figueiredo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to