You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stefan <st...@wammel.com> on 2009/07/22 18:57:16 UTC
Component Event Context, ValueEncoder & Lifecycle
Hi,
i'm currently writing my first component, which should work like this
one : http://wiki.apache.org/tapestry/Tapestry5HowToCreateASimpleGraphComponent
Everything works fine so far, but:
I have to pass some complex data structures (encapsulated in objects)
to the component,
doing so:
In the page template:
<t:myComp context="myDataStructure" />
In the components beginRender method:
void beginRender(MarkupWriter writer) {
Link lnk = resources.createEventLink(EVENT_NAME, context);
// should render this: <embed type="image/svg+xml" src="..."
width="280"height="280">
writer.element("embed", "type", "image/svg+xml", "width",
width, "height", height, "src", lnk);
resources.renderInformalParameters(writer);
}
And at least, the corresponding action:
public StreamResponse onRenderGraph(Object... params) {
// the params object now should be the passed myDataStructure
//... rendering stuff
}
This works fine so far, but some things are too unclear to me:
the generated eventlink looks horrible:
"/somepage.component.action/org.localhost.something.package.MyStructure
$12345"
Is there a way to use a custom ValueEncode to generate a better url?
I do not want to provide my package structure to the client ;)
And, more important to me is to know something about the lifecycles.
How long and "where" life these "passed objects"?
Thanks,
Stefan
Re: Component Event Context, ValueEncoder & Lifecycle
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 22 Jul 2009 13:57:16 -0300, Stefan <st...@wammel.com> escreveu:
> Hi,
Hi!
> void beginRender(MarkupWriter writer) {
> Link lnk = resources.createEventLink(EVENT_NAME, context);
You should encode the event context before passing it to
createEventLink(). ;)
Then, in your event handler method, you decode the context.
> // should render this: <embed type="image/svg+xml" src="..."
> width="280"height="280">
> writer.element("embed", "type", "image/svg+xml", "width",
> width, "height", height, "src", lnk);
SVG! Cool! :)
> And, more important to me is to know something about the lifecycles.
> How long and "where" life these "passed objects"?
The passed objects are put in the link URL and not store anywhere else.
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org