You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Rich M <ri...@moremagic.com> on 2010/12/20 23:10:06 UTC
MarkupWriter and TML together?
Hi,
is it possible to use the MarkupWriter in the page class in a render
stage in addition to a template?
The page I'm trying to write needs to feed a component into a delegate
from the Layout.tml it belongs to. As far as I can figure out I can only
write Tapestry components in the TML file and not with the MarkupWriter.
That is to say, my attempts to do so have failed and searching various
ends online hasn't shown me otherwise.
On the other hand, I want to use the MarkupWriter to build a dynamic set
of HTML elements. Specifically, to build a collapsing/expanding
hierarchy of Categories built into a form that I will process.
By doing the HTML elements in the page class, I figured I could keep
track of the elements and their attributes/etc with the least pain so I
can process them properly on a form submission.
This is 5.1.0.5 by the way.
Thanks,
Rich
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by Rich M <ri...@moremagic.com>.
Oh, okay, that works great. Guess I got my mindset too narrow to see
that, thanks.
One more thing, the FormEventLink that is generated doesn't always play
nice.
Two scenarios (the Component with the FormEventLink will be called
EventComponent):
1. A Page class contains reference to the EventComponent in the TML.
The EventLink generated in the HTML builds a proper URI for this page
class and everything works.
2. A main Page class delegates a section of its TML to another Page
class, which is dynamic. This delegated Page class contains reference to
the EventComponent in the TML. The EventLink generated in the HTML
builds an incorrect URI for this page class. It builds one referencing
the Main Page, while the EventComponent is only known to and a part of
the Delegate Page.
To solve #2 temporarily, I was able to re-write the URI from the
generated EventLink to reference the correct component. First I got it
working using new LinkImpl, but since that is an internal class, I opted
for a Javascript rewrite instead. I couldn't find any other way of
regenerating the link though... Not sure if there is one?
Thanks,
Rich
On 12/22/2010 02:42 PM, Thiago H. de Paula Figueiredo wrote:
> On Wed, 22 Dec 2010 17:05:22 -0200, Rich M <ri...@moremagic.com> wrote:
>
>> I suppose this is where I am confused. I currently use JavaScript to
>> write the query parameter into the activation context of the EventLink.
>
> What I'm suggesting you is to *not* use the context as the way of
> passing information to your event handler method. You'd use a query
> parameter added through JavaScript instead. Example: your generated
> link is /page.event. When the field value is changed, you change the
> URL to /page.event?value=<field value>.
>
>> My logic was that the EventLink triggers the Event Handler method,
>> while the form submission puts the hidden input into the Request
>> parameters.
>
> This isn't needed nor guaranteed to work in order.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 22 Dec 2010 17:05:22 -0200, Rich M <ri...@moremagic.com> wrote:
> I suppose this is where I am confused. I currently use JavaScript to
> write the query parameter into the activation context of the EventLink.
What I'm suggesting you is to *not* use the context as the way of passing
information to your event handler method. You'd use a query parameter
added through JavaScript instead. Example: your generated link is
/page.event. When the field value is changed, you change the URL to
/page.event?value=<field value>.
> My logic was that the EventLink triggers the Event Handler method, while
> the form submission puts the hidden input into the Request parameters.
This isn't needed nor guaranteed to work in order.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by Rich M <ri...@moremagic.com>.
On 12/22/2010 01:44 PM, Thiago H. de Paula Figueiredo wrote:
> On Wed, 22 Dec 2010 16:05:15 -0200, Rich M <ri...@moremagic.com> wrote:
>
>> Hmm, I'd tried that several ways, every time the ParameterNames()
>> list was empty and I couldn't fetch the parameter I was looking for.
>> I tried peeking the Request parameters in the Event method as well as
>> @SetupRender.
>
> Are you sure you added the query parameters to the URL generated by
> ComponentResources.create*EventLink() using JavaScript? Or at least
> you added this values as hidden fields?
>
I suppose this is where I am confused. I currently use JavaScript to
write the query parameter into the activation context of the EventLink.
This is what is very messy as described before. The query parameter is
pulled from the hidden input field in the enclosing form. The javascript
method setupSubmit takes care of converting the value of the hidden
input field into the activation context of the URL for the EventLink.
The one with the "productsList" id will have the query parameter in its
value attribute.
>> There was an additional complication with submitting the HTML form
>> and the EventLink at the same time.
>
> Why would you do both at the same time?
>
My logic was that the EventLink triggers the Event Handler method, while
the form submission puts the hidden input into the Request parameters.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 22 Dec 2010 16:05:15 -0200, Rich M <ri...@moremagic.com> wrote:
> Hmm, I'd tried that several ways, every time the ParameterNames() list
> was empty and I couldn't fetch the parameter I was looking for. I tried
> peeking the Request parameters in the Event method as well as
> @SetupRender.
Are you sure you added the query parameters to the URL generated by
ComponentResources.create*EventLink() using JavaScript? Or at least you
added this values as hidden fields?
> There was an additional complication with submitting the HTML form and
> the EventLink at the same time.
Why would you do both at the same time?
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by Rich M <ri...@moremagic.com>.
Hmm, I'd tried that several ways, every time the ParameterNames() list
was empty and I couldn't fetch the parameter I was looking for. I tried
peeking the Request parameters in the Event method as well as @SetupRender.
There was an additional complication with submitting the HTML form and
the EventLink at the same time. I had thought wrapping the HTML form
submit inside the EventLink might work, but this submits the event twice
it seems.
Here's some code relating to the form and EventLink that might
illuminate things:
w.element("form", "id", "prefForm", "method", "post");
w.element("center");
w.element("input", "type", "hidden", "id", "productsList", "value", ""); //This is the field to pass to Event Handler
w.end();
Link formEvent = cr.createFormEventLink("SavePreferences", new Object[]{});
w.element("a","href",formEvent,"id","submitPrefs","onclick","javascript:setupSubmit(this);");
w.element("input", "type", "submit", "value", ms.get("save-rewards-preferences"));
w.end(); //submit
w.end(); //formEventLink
w.end(); //center
w.end(); //form
On 12/22/2010 12:55 PM, Thiago H. de Paula Figueiredo wrote:
> On Wed, 22 Dec 2010 15:42:21 -0200, Rich M <ri...@moremagic.com> wrote:
>
>> I don't have the option of using 5.2 at this point, so that seems to
>> leave out @RequestParameter and @ActivationRequestParameter. What
>> might my other options be for passing back the value attribute from
>> an HTML tag to the Component Event method?
>
> Just @Inject Request and use it's getParameter() method. The above
> annotations are just shortcuts for this.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 22 Dec 2010 15:42:21 -0200, Rich M <ri...@moremagic.com> wrote:
> I don't have the option of using 5.2 at this point, so that seems to
> leave out @RequestParameter and @ActivationRequestParameter. What might
> my other options be for passing back the value attribute from an HTML
> tag to the Component Event method?
Just @Inject Request and use it's getParameter() method. The above
annotations are just shortcuts for this.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by Rich M <ri...@moremagic.com>.
Whoops, spoke to soon on that Element / Persist strategy. Didn't stop to
think that the Element object was completely class side and only would
be as up-to-date as it was at declaration. Any changes in the DOM by
Javascript don't translate so that doesn't quite work. Wanted to make
sure no one ended up trying the same and failing.
I don't have the option of using 5.2 at this point, so that seems to
leave out @RequestParameter and @ActivationRequestParameter. What might
my other options be for passing back the value attribute from an HTML
tag to the Component Event method?
I've tried using Javascript to manipulate the EventLink's context, but
this is really messy. My input value is a comma-separated list and the
context complains on nearly any special character I'd like to separate
the values with. I ended up getting working functionality by replacing
spaces with 'BlAnK' and separating the list with 'SePaRaToR' instead of
','. These two strings look so weird as to avoid any chance someone
might actually match them. Feels like a terrible hack to me though, but
deadlines are deadlines and it works.
Is there anything more elegant that this? I'd surely want to refactor
this code ASAP after my deadline. Would an upgrade to 5.2 and using
@RequestParameter be the best refactor I could do, or is there another
solution, possibly 5.1 compatible?
Thanks,
Rich
On 12/22/2010 11:07 AM, Thiago H. de Paula Figueiredo wrote:
> On Wed, 22 Dec 2010 13:57:38 -0200, Rich M <ri...@moremagic.com> wrote:
>
>> Thanks for the clarifications, Thiago. Helpful as always.
>
> You're welcome!
>
>> At first I didn't see a nice way of actually feeding the values from
>> the HTML form back into the event method for the EventLink though.
>> creatEventLink seems to assume I know my context from the Component
>> class, but the context is only ever known to an HTML element after
>> some Javascript has its way. But then I realized I can save the form
>> input Element I made during rendering with the MarkupWriter (last
>> concept you mentioned) with Persist. Then in the event method read
>> the value attribute back.
>
> Another option is to add request parameters instead of using the
> activation context, something that was made even easier with the new
> @RequestParameter and @ActivationRequestParameter annotations in
> Tapestry 5.2.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 22 Dec 2010 13:57:38 -0200, Rich M <ri...@moremagic.com> wrote:
> Thanks for the clarifications, Thiago. Helpful as always.
You're welcome!
> At first I didn't see a nice way of actually feeding the values from the
> HTML form back into the event method for the EventLink though.
> creatEventLink seems to assume I know my context from the Component
> class, but the context is only ever known to an HTML element after some
> Javascript has its way. But then I realized I can save the form input
> Element I made during rendering with the MarkupWriter (last concept you
> mentioned) with Persist. Then in the event method read the value
> attribute back.
Another option is to add request parameters instead of using the
activation context, something that was made even easier with the new
@RequestParameter and @ActivationRequestParameter annotations in Tapestry
5.2.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by Rich M <ri...@moremagic.com>.
Thanks for the clarifications, Thiago. Helpful as always.
I didn't realize that event methods automatically bubbled up if void,
false, or null were returned from a child component. As far as I can
tell, this means I wouldn't need to use triggerEvent. I wrote an <a>
with the href loading the URL from ComponentResources.createEventLink().
At first I didn't see a nice way of actually feeding the values from the
HTML form back into the event method for the EventLink though.
creatEventLink seems to assume I know my context from the Component
class, but the context is only ever known to an HTML element after some
Javascript has its way. But then I realized I can save the form input
Element I made during rendering with the MarkupWriter (last concept you
mentioned) with Persist. Then in the event method read the value
attribute back.
Another corner turned, Tapestry keeps getting better.
Thanks again,
Rich
On 12/21/2010 07:26 PM, Thiago H. de Paula Figueiredo wrote:
> On Tue, 21 Dec 2010 21:36:54 -0200, Rich M <ri...@moremagic.com> wrote:
>
>> writing it as a Component works. Not sure what the problem with the
>> Page class was.
>
> Most probably your div was generated before the HTML tag. Your
> scenario really needed to be implemented as a component.
>
>> Seem to have hit an additional complication. Since this component is
>> generating everything with the MarkupWriter, I'm struggling to
>> understand how I can feed values back to the Component into an Event
>> method. Mailing list searches and documentation searching haven't
>> turned up anything too promosing for me yet.
>
> See method triggerEvent(String eventType, Object[] contextValues,
> ComponentEventCallback callback) in ComponentResources (inherited from
> ComponentResourcesCommon. Searching the mailing lists and JumpStart
> will probably give you some hints.
>
>> I haven't seen a way to write a Tapestry component like Form with the
>> MarkupWriter, so I don't think I can use a Tapestry Form.
>
> There's no way of doing it. You need to declare components (at least
> their t:id) in a template.
>
>> I'm not clear on how a plain HTML form can trigger a Component method,
>
> Just use an URL created from ComponentResources.createEventLink() as
> the action.
>
>> is there a Tapestry Javascript method to leverage this?
>
> No need of JavaScript for that (but you can use it if you want)
>
>> Alternately, is there a way to feed MarkupWriter content into a TML
>> template, as in to write out HTML elements inside a <t:form> element?
>
> MarkupWriter.element() inside a component render event method. You can
> also change what was already written manipulating the Element
> instances got from MarkupWriter.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 21 Dec 2010 21:36:54 -0200, Rich M <ri...@moremagic.com> wrote:
> writing it as a Component works. Not sure what the problem with the Page
> class was.
Most probably your div was generated before the HTML tag. Your scenario
really needed to be implemented as a component.
> Seem to have hit an additional complication. Since this component is
> generating everything with the MarkupWriter, I'm struggling to
> understand how I can feed values back to the Component into an Event
> method. Mailing list searches and documentation searching haven't turned
> up anything too promosing for me yet.
See method triggerEvent(String eventType, Object[] contextValues,
ComponentEventCallback callback) in ComponentResources (inherited from
ComponentResourcesCommon. Searching the mailing lists and JumpStart will
probably give you some hints.
> I haven't seen a way to write a Tapestry component like Form with the
> MarkupWriter, so I don't think I can use a Tapestry Form.
There's no way of doing it. You need to declare components (at least their
t:id) in a template.
> I'm not clear on how a plain HTML form can trigger a Component method,
Just use an URL created from ComponentResources.createEventLink() as the
action.
> is there a Tapestry Javascript method to leverage this?
No need of JavaScript for that (but you can use it if you want)
> Alternately, is there a way to feed MarkupWriter content into a TML
> template, as in to write out HTML elements inside a <t:form> element?
MarkupWriter.element() inside a component render event method. You can
also change what was already written manipulating the Element instances
got from MarkupWriter.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by Rich M <ri...@moremagic.com>.
To follow up,
writing it as a Component works. Not sure what the problem with the Page
class was.
Seem to have hit an additional complication. Since this component is
generating everything with the MarkupWriter, I'm struggling to
understand how I can feed values back to the Component into an Event
method. Mailing list searches and documentation searching haven't turned
up anything too promosing for me yet.
I haven't seen a way to write a Tapestry component like Form with the
MarkupWriter, so I don't think I can use a Tapestry Form. I'm not clear
on how a plain HTML form can trigger a Component method, is there a
Tapestry Javascript method to leverage this? Alternately, is there a way
to feed MarkupWriter content into a TML template, as in to write out
HTML elements inside a <t:form> element?
Thanks,
Rich
On 12/21/2010 05:08 PM, Rich M wrote:
> A quick check, yes the @BeforeRenderTemplate method does get called. A
> log message displays, but the html elements don't render anywhere
> according to inspecting of the page source.
>
> I have not tried in a component yet for this. I am in the process. I
> actually think a component will be a better idea anyway, because I
> will need to re-use a chunk of the logic for this page and it is
> pretty intense both on the rendering and javascript sides.
>
> Essentially the component in this case needs to update some DB
> entities, and then the page needs to handle redirection/additional
> logic based on the results of the component form.
>
> If I use " @OnEvent(value = EventConstants.SUCCESS) " in the page
> class, will I be able to capture the firing of a form in the component
> class? If so that would allow me to trigger logic in the page class,
> and then to access information from the component (private fields with
> getter methods) I could use @InjectComponent to have a reference to
> the component in the Page class?
>
> Let me know if my assumptions there are in line with the truth.
>
> Thanks,
> Rich
>
> On 12/21/2010 04:56 PM, Josh Canfield wrote:
>> Does your event handler get called? Have you tried the same thing in a
>> page and a component?
>>
>> On Tue, Dec 21, 2010 at 7:59 AM, Rich M<ri...@moremagic.com> wrote:
>>> No luck, same result. No<div id="tabContent"> or<h2> elements in the
>>> generated HTML.
>>>
>>> On 12/20/2010 06:23 PM, Thiago H. de Paula Figueiredo wrote:
>>>> On Mon, 20 Dec 2010 20:48:39 -0200, Rich M<ri...@moremagic.com>
>>>> wrote:
>>>>
>>>>> So that seems to narrow it down to some issue in my approach then,
>>>>> as I
>>>>> am not able to see anything written from my MarkupWriter in the
>>>>> @BeginRender
>>>>> phase.
>>>> Try @BeforeRenderTemplate
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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: MarkupWriter and TML together?
Posted by Rich M <ri...@moremagic.com>.
A quick check, yes the @BeforeRenderTemplate method does get called. A
log message displays, but the html elements don't render anywhere
according to inspecting of the page source.
I have not tried in a component yet for this. I am in the process. I
actually think a component will be a better idea anyway, because I will
need to re-use a chunk of the logic for this page and it is pretty
intense both on the rendering and javascript sides.
Essentially the component in this case needs to update some DB entities,
and then the page needs to handle redirection/additional logic based on
the results of the component form.
If I use " @OnEvent(value = EventConstants.SUCCESS) " in the page
class, will I be able to capture the firing of a form in the component
class? If so that would allow me to trigger logic in the page class, and
then to access information from the component (private fields with
getter methods) I could use @InjectComponent to have a reference to the
component in the Page class?
Let me know if my assumptions there are in line with the truth.
Thanks,
Rich
On 12/21/2010 04:56 PM, Josh Canfield wrote:
> Does your event handler get called? Have you tried the same thing in a
> page and a component?
>
> On Tue, Dec 21, 2010 at 7:59 AM, Rich M<ri...@moremagic.com> wrote:
>
>> No luck, same result. No<div id="tabContent"> or<h2> elements in the
>> generated HTML.
>>
>> On 12/20/2010 06:23 PM, Thiago H. de Paula Figueiredo wrote:
>>
>>> On Mon, 20 Dec 2010 20:48:39 -0200, Rich M<ri...@moremagic.com> wrote:
>>>
>>>
>>>> So that seems to narrow it down to some issue in my approach then, as I
>>>> am not able to see anything written from my MarkupWriter in the @BeginRender
>>>> phase.
>>>>
>>> Try @BeforeRenderTemplate
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by Josh Canfield <jo...@gmail.com>.
Does your event handler get called? Have you tried the same thing in a
page and a component?
On Tue, Dec 21, 2010 at 7:59 AM, Rich M <ri...@moremagic.com> wrote:
> No luck, same result. No <div id="tabContent"> or <h2> elements in the
> generated HTML.
>
> On 12/20/2010 06:23 PM, Thiago H. de Paula Figueiredo wrote:
>>
>> On Mon, 20 Dec 2010 20:48:39 -0200, Rich M <ri...@moremagic.com> wrote:
>>
>>> So that seems to narrow it down to some issue in my approach then, as I
>>> am not able to see anything written from my MarkupWriter in the @BeginRender
>>> phase.
>>
>> Try @BeforeRenderTemplate
>>
>
>
> ---------------------------------------------------------------------
> 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: MarkupWriter and TML together?
Posted by Rich M <ri...@moremagic.com>.
No luck, same result. No <div id="tabContent"> or <h2> elements in the
generated HTML.
On 12/20/2010 06:23 PM, Thiago H. de Paula Figueiredo wrote:
> On Mon, 20 Dec 2010 20:48:39 -0200, Rich M <ri...@moremagic.com> wrote:
>
>> So that seems to narrow it down to some issue in my approach then, as
>> I am not able to see anything written from my MarkupWriter in the
>> @BeginRender phase.
>
> Try @BeforeRenderTemplate
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 20 Dec 2010 20:48:39 -0200, Rich M <ri...@moremagic.com> wrote:
> So that seems to narrow it down to some issue in my approach then, as I
> am not able to see anything written from my MarkupWriter in the
> @BeginRender phase.
Try @BeforeRenderTemplate
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: MarkupWriter and TML together?
Posted by Rich M <ri...@moremagic.com>.
Thanks, that's great to know.
So that seems to narrow it down to some issue in my approach then, as I
am not able to see anything written from my MarkupWriter in the
@BeginRender phase. I have components using just the MarkupWriter for
output working, so I know it works in general.
I'm trying to have the MarkupWriter begin it's rendering after the
content from the TML:
Page TML
<html t:type="customerlayout" title="Customer Interface"
t:sidebarTitle=" "
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
<p:contentInfo>
<t:CustomerInfo noedit="true" />
</p:contentInfo>
<!--*MarkupWriter Content goes here*-->
</html>
Layout TML (edited down for clarity)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>${title}</title>
</head>
<body>
<div class="header" />
<div class="mainNav" />
<div class="page-container">
<div class="content">
<div class="contentInfo">
<t:if test="contentInfo">
<t:delegate to="contentInfo" />
</t:if>
</div>
*<t:body /> <!-- this is where I'd expect the markup content to occur -->*
<br style="clear: both;"/>
<div class="footer" />
</div>
</div>
</body>
</html>
MarkupWriter method:
@BeginRender
public void getSelectedTab(MarkupWriter writer){
writer.element("div","id","tabContent");
writer.element("h2");
writer.write("Test");
writer.end();
writer.end();
}
Thanks,
Rich
On 12/20/2010 05:21 PM, Howard Lewis Ship wrote:
> Yes, absolutely. Behind the scenes, the templates are parsed into
> collections of objects that operate on MarkupWriter, so you can mix a
> template with render phase methods and many other tricks.
>
> On Mon, Dec 20, 2010 at 2:10 PM, Rich M<ri...@moremagic.com> wrote:
>
>
>> Hi,
>>
>> is it possible to use the MarkupWriter in the page class in a render stage
>> in addition to a template?
>>
>> The page I'm trying to write needs to feed a component into a delegate from
>> the Layout.tml it belongs to. As far as I can figure out I can only write
>> Tapestry components in the TML file and not with the MarkupWriter. That is
>> to say, my attempts to do so have failed and searching various ends online
>> hasn't shown me otherwise.
>>
>> On the other hand, I want to use the MarkupWriter to build a dynamic set of
>> HTML elements. Specifically, to build a collapsing/expanding hierarchy of
>> Categories built into a form that I will process.
>>
>> By doing the HTML elements in the page class, I figured I could keep track
>> of the elements and their attributes/etc with the least pain so I can
>> process them properly on a form submission.
>>
>> This is 5.1.0.5 by the way.
>>
>> Thanks,
>> Rich
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
>
Re: MarkupWriter and TML together?
Posted by Howard Lewis Ship <hl...@gmail.com>.
Yes, absolutely. Behind the scenes, the templates are parsed into
collections of objects that operate on MarkupWriter, so you can mix a
template with render phase methods and many other tricks.
On Mon, Dec 20, 2010 at 2:10 PM, Rich M <ri...@moremagic.com> wrote:
> Hi,
>
> is it possible to use the MarkupWriter in the page class in a render stage
> in addition to a template?
>
> The page I'm trying to write needs to feed a component into a delegate from
> the Layout.tml it belongs to. As far as I can figure out I can only write
> Tapestry components in the TML file and not with the MarkupWriter. That is
> to say, my attempts to do so have failed and searching various ends online
> hasn't shown me otherwise.
>
> On the other hand, I want to use the MarkupWriter to build a dynamic set of
> HTML elements. Specifically, to build a collapsing/expanding hierarchy of
> Categories built into a form that I will process.
>
> By doing the HTML elements in the page class, I figured I could keep track
> of the elements and their attributes/etc with the least pain so I can
> process them properly on a form submission.
>
> This is 5.1.0.5 by the way.
>
> Thanks,
> Rich
>
> ---------------------------------------------------------------------
> 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