hi erik,

GetContent.html is interpreted by T5 as: go to component "html" 
on page "GetContent".

if you know beforehand what your link looks like (eg. what component
and what page) you can use following code snippet to perform partial
page rendering:


@Component
private ActionLink UpdateLink;

// to retrieve page instances
@Inject private RequestPageCache _cache;
// returns markupwriter
@Inject private MarkupWriterFactory _mwf;
// sets the environment 
@Inject private PageRenderInitializer initializer;

public Object onActionFromUpdateLink {
     initializer.setup(markupWriter);
    Page page = _cache.get("anypage");
 
    ComponentPageElement element = 
        page.getRootElement().getEmbeddedElement("anyelement");
 
    RenderQueueImpl queue = 
        new RenderQueueImpl(page.getLog());
 
    element.queueRender(queue);

    queue.run(markupWriter); 
    markupWriter.end();
    initializer.cleanup(markupWriter);
 
    return new TextStreamResponse("text/html",markupWriter.toString());
}

it works but i don't know if it's the T5 way of doing it :)

g,
kris




"Erik Vullings" <[EMAIL PROTECTED]> 
12.06.2007 16:00
Bitte antworten an
"Tapestry users" <users@tapestry.apache.org>


An
"Tapestry users" <users@tapestry.apache.org>
Kopie

Thema
T5: Prototype's AJAX.updater question






Hi all,

Is it possible to use prototype's AJAX updater function to replace a div
with the output of a tapastry page or component?

I''ve tried the following:

I created a js function which should update the mainContent div
*function* showAJAX(index) {
*new* Ajax.Updater("mainContent", "GetContent.html", {
method : "post",
postBody : "index=" + index,
onSuccess : *function*(resp) {
},
onFailure : ajaxError
});
}

Whether GetContent.html is a valid T5 page or a component, in both cases I
get the following error (in the correct mainContent div, so that part 
works
:-):
 An unexpected application exception has occurred.

   - org.apache.tapestry.ioc.internal.util.TapestryException Component
   org.example.myapp.pages.GetContent does not contain an embedded
   component with id 'html'.

Stack trace

   -
 
org.apache.tapestry.internal.structure.ComponentPageElementImpl.getEmbeddedElement
   (ComponentPageElementImpl.java:831)
   -
 
org.apache.tapestry.internal.structure.PageImpl.getComponentElementByNestedId
   (PageImpl.java:83)
   - org.apache.tapestry.internal.services.ActionLinkHandlerImpl.handle(
   ActionLinkHandlerImpl.java:69)
   - ...

Any idea what I'm doing wrong?

Thanks
Erik

Reply via email to