You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Steve <st...@gmail.com> on 2013/08/12 12:27:07 UTC

Form inside component isn't working as I expected (Fairly new to tapestry, help greatly appreciated!)

Hi!

I'm fairly new to Tapestry and i'm working on a project at the moment.
>From what I have found so far, it's fantastic and I am really enjoying
using it for my work. I've come a little stuck on something in
particular though which I'm sure will have come up many times before,
but I can't seem to find an answer for.

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. 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. Ok, so I then created the same method in the page class rather
than the component class, again that was not called. I then put an id
on the form (t:id="foo"), and created a method in the component class
called onSubmitFromFoo() and then got the error "Method
com.syn.ama.components.tools.HelloComponent.onSubmitFromFoo()
references component id 'Foo' which does not exist."

So.. my next thing to try was to put this method in the page class
(Seems odd to me). Then I got this error which was fairly expected:
"Method com.syn.ama.pages.addassignment.Step2.onSubmitFromFoo()
references component id 'Foo' which does not exist.

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)? 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. The component when the data
is submitted will put that into the object (or that is the idea).

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.

Thanks, I really appreciate any help. If my message is confusing in
places, please do ask and I can hopefully explain some more.

Steve (Tapestry noob for now, but hopefully not for long).

P.S, sorry for posting this in the wrong topic originally, I now see
how the mailing list works - sorry for that.

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


Re: Form inside component isn't working as I expected (Fairly new to tapestry, help greatly appreciated!)

Posted by Steve <st...@gmail.com>.
Thanks Howard and Lenny for the guidance.
I'll order the paper back book. Looking at the contents online it does
look like it covers some items which my current book doesn't.

It's very nice to have such a supportive community, thanks again.
Hopefully I can give something back as soon as I know what I'm doing myself :).

Steve



On 13 August 2013 20:37, Lenny Primak <lp...@hope.nyc.ny.us> wrote:
> I second that.  That's how I learned tapestry and it was quick and easy.
>
> On Aug 13, 2013, at 12:55 PM, Howard Lewis Ship wrote:
>
>> I'd recomment Igor Drobiasko's book ... very up to date!
>>
>> http://www.tapestry5book.com/
>>
>>
>> On Tue, Aug 13, 2013 at 4:34 AM, Steve <st...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> Yes - Living and learning.
>>> This project which I am doing is actually part of my PhD, I needed to
>>> build something quick that would be reliable and easy to expand in
>>> future (To allow me to start gathering some early results from users).
>>> In my undergraduate studies in Computer Science the main language
>>> taught is java, but no frameworks are really taught. When I ran
>>> through the hi-low tutorial myself, I fell in love with tapestry. I
>>> got the feeling of wow, I can create anything with this, and bought
>>> Tapestry 5 book by Alexander Kolesnikov to learn some more. I started
>>> the project in a little bit of a rush having not used Tapestry for a
>>> project before and not quite finished reading the book which is why I
>>> make these big mistakes. I just love how easy it is to refactor and
>>> move things around withing it all falling to pieces.
>>>
>>> I just wanted to let you know I came in today to work on my project,
>>> and because of your help - things are actually working well - you have
>>> made my week.
>>>
>>> If there is anything I can give you a hand with (Although, I see I
>>> can't help you with development!), such as user testing or anything,
>>> please do let me know.
>>>
>>> Thanks,
>>> Steve
>>>
>>>
>>> On 12 August 2013 19:10, Thiago H de Paula Figueiredo
>>> <th...@gmail.com> wrote:
>>>> On Mon, 12 Aug 2013 14:43:56 -0300, Steve <st...@gmail.com> wrote:
>>>>
>>>>> Hi Thiago,
>>>>
>>>>
>>>> Hi!
>>>>
>>>>
>>>>> 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.
>>>>
>>>>
>>>> Yay! Nice!
>>>>
>>>>
>>>>> 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).
>>>>
>>>>
>>>> You're not the first person to not be aware of this in the mailing list,
>>> and
>>>> you'll probably won't be the last. :)
>>>>
>>>>
>>>>> I really appreciate your help.
>>>>
>>>>
>>>> ;)
>>>>
>>>>
>>>>> Steve (Still a tapestry noob, but ever so slightly less now).
>>>>
>>>>
>>>> As we say here in my country, living and learning. :)
>>>>
>>>>
>>>> --
>>>> Thiago H. de Paula Figueiredo
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>> --
>> Howard M. Lewis Ship
>>
>> Creator of Apache Tapestry
>>
>> The source for Tapestry training, mentoring and support. Contact me to
>> learn how I can get you up and productive in Tapestry fast!
>>
>> (971) 678-5210
>> http://howardlewisship.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

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


Re: Form inside component isn't working as I expected (Fairly new to tapestry, help greatly appreciated!)

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
I second that.  That's how I learned tapestry and it was quick and easy.

On Aug 13, 2013, at 12:55 PM, Howard Lewis Ship wrote:

> I'd recomment Igor Drobiasko's book ... very up to date!
> 
> http://www.tapestry5book.com/
> 
> 
> On Tue, Aug 13, 2013 at 4:34 AM, Steve <st...@gmail.com> wrote:
> 
>> Hi,
>> 
>> Yes - Living and learning.
>> This project which I am doing is actually part of my PhD, I needed to
>> build something quick that would be reliable and easy to expand in
>> future (To allow me to start gathering some early results from users).
>> In my undergraduate studies in Computer Science the main language
>> taught is java, but no frameworks are really taught. When I ran
>> through the hi-low tutorial myself, I fell in love with tapestry. I
>> got the feeling of wow, I can create anything with this, and bought
>> Tapestry 5 book by Alexander Kolesnikov to learn some more. I started
>> the project in a little bit of a rush having not used Tapestry for a
>> project before and not quite finished reading the book which is why I
>> make these big mistakes. I just love how easy it is to refactor and
>> move things around withing it all falling to pieces.
>> 
>> I just wanted to let you know I came in today to work on my project,
>> and because of your help - things are actually working well - you have
>> made my week.
>> 
>> If there is anything I can give you a hand with (Although, I see I
>> can't help you with development!), such as user testing or anything,
>> please do let me know.
>> 
>> Thanks,
>> Steve
>> 
>> 
>> On 12 August 2013 19:10, Thiago H de Paula Figueiredo
>> <th...@gmail.com> wrote:
>>> On Mon, 12 Aug 2013 14:43:56 -0300, Steve <st...@gmail.com> wrote:
>>> 
>>>> Hi Thiago,
>>> 
>>> 
>>> Hi!
>>> 
>>> 
>>>> 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.
>>> 
>>> 
>>> Yay! Nice!
>>> 
>>> 
>>>> 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).
>>> 
>>> 
>>> You're not the first person to not be aware of this in the mailing list,
>> and
>>> you'll probably won't be the last. :)
>>> 
>>> 
>>>> I really appreciate your help.
>>> 
>>> 
>>> ;)
>>> 
>>> 
>>>> Steve (Still a tapestry noob, but ever so slightly less now).
>>> 
>>> 
>>> As we say here in my country, living and learning. :)
>>> 
>>> 
>>> --
>>> Thiago H. de Paula Figueiredo
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator of Apache Tapestry
> 
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
> 
> (971) 678-5210
> http://howardlewisship.com


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


Re: Form inside component isn't working as I expected (Fairly new to tapestry, help greatly appreciated!)

Posted by Howard Lewis Ship <hl...@gmail.com>.
I'd recomment Igor Drobiasko's book ... very up to date!

http://www.tapestry5book.com/


On Tue, Aug 13, 2013 at 4:34 AM, Steve <st...@gmail.com> wrote:

> Hi,
>
> Yes - Living and learning.
> This project which I am doing is actually part of my PhD, I needed to
> build something quick that would be reliable and easy to expand in
> future (To allow me to start gathering some early results from users).
> In my undergraduate studies in Computer Science the main language
> taught is java, but no frameworks are really taught. When I ran
> through the hi-low tutorial myself, I fell in love with tapestry. I
> got the feeling of wow, I can create anything with this, and bought
> Tapestry 5 book by Alexander Kolesnikov to learn some more. I started
> the project in a little bit of a rush having not used Tapestry for a
> project before and not quite finished reading the book which is why I
> make these big mistakes. I just love how easy it is to refactor and
> move things around withing it all falling to pieces.
>
> I just wanted to let you know I came in today to work on my project,
> and because of your help - things are actually working well - you have
> made my week.
>
> If there is anything I can give you a hand with (Although, I see I
> can't help you with development!), such as user testing or anything,
> please do let me know.
>
> Thanks,
> Steve
>
>
> On 12 August 2013 19:10, Thiago H de Paula Figueiredo
> <th...@gmail.com> wrote:
> > On Mon, 12 Aug 2013 14:43:56 -0300, Steve <st...@gmail.com> wrote:
> >
> >> Hi Thiago,
> >
> >
> > Hi!
> >
> >
> >> 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.
> >
> >
> > Yay! Nice!
> >
> >
> >> 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).
> >
> >
> > You're not the first person to not be aware of this in the mailing list,
> and
> > you'll probably won't be the last. :)
> >
> >
> >> I really appreciate your help.
> >
> >
> > ;)
> >
> >
> >> Steve (Still a tapestry noob, but ever so slightly less now).
> >
> >
> > As we say here in my country, living and learning. :)
> >
> >
> > --
> > Thiago H. de Paula Figueiredo
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

Re: Form inside component isn't working as I expected (Fairly new to tapestry, help greatly appreciated!)

Posted by Steve <st...@gmail.com>.
Hi,

Yes - Living and learning.
This project which I am doing is actually part of my PhD, I needed to
build something quick that would be reliable and easy to expand in
future (To allow me to start gathering some early results from users).
In my undergraduate studies in Computer Science the main language
taught is java, but no frameworks are really taught. When I ran
through the hi-low tutorial myself, I fell in love with tapestry. I
got the feeling of wow, I can create anything with this, and bought
Tapestry 5 book by Alexander Kolesnikov to learn some more. I started
the project in a little bit of a rush having not used Tapestry for a
project before and not quite finished reading the book which is why I
make these big mistakes. I just love how easy it is to refactor and
move things around withing it all falling to pieces.

I just wanted to let you know I came in today to work on my project,
and because of your help - things are actually working well - you have
made my week.

If there is anything I can give you a hand with (Although, I see I
can't help you with development!), such as user testing or anything,
please do let me know.

Thanks,
Steve


On 12 August 2013 19:10, Thiago H de Paula Figueiredo
<th...@gmail.com> wrote:
> On Mon, 12 Aug 2013 14:43:56 -0300, Steve <st...@gmail.com> wrote:
>
>> Hi Thiago,
>
>
> Hi!
>
>
>> 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.
>
>
> Yay! Nice!
>
>
>> 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).
>
>
> You're not the first person to not be aware of this in the mailing list, and
> you'll probably won't be the last. :)
>
>
>> I really appreciate your help.
>
>
> ;)
>
>
>> Steve (Still a tapestry noob, but ever so slightly less now).
>
>
> As we say here in my country, living and learning. :)
>
>
> --
> Thiago H. de Paula Figueiredo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

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


Re: Form inside component isn't working as I expected (Fairly new to tapestry, help greatly appreciated!)

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 12 Aug 2013 14:43:56 -0300, Steve <st...@gmail.com> wrote:

> Hi Thiago,

Hi!

> 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.

Yay! Nice!

> 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).

You're not the first person to not be aware of this in the mailing list,  
and you'll probably won't be the last. :)

> I really appreciate your help.

;)

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

As we say here in my country, living and learning. :)

-- 
Thiago H. de Paula Figueiredo

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


Re: Form inside component isn't working as I expected (Fairly new to tapestry, help greatly appreciated!)

Posted by Steve <st...@gmail.com>.
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
<th...@gmail.com> wrote:
> On Mon, 12 Aug 2013 07:27:07 -0300, Steve <st...@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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

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


Re: Form inside component isn't working as I expected (Fairly new to tapestry, help greatly appreciated!)

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 12 Aug 2013 07:27:07 -0300, Steve <st...@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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org