Pagelink with a zone

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Pagelink with a zone

SunnyPenguin
Is there a way I can direct the pagelink component to a zone. I tried using
eventlink and delegate to return the instance of an injected page. This
works but I have dynamic number of pages in a loop for a tab component. I
would just like to specify in the link where the page should be loading.

So ideally I want a pagelink with a target div.

Here is what I tried. Could you please point me in the right direction?

<t:loop source="tabList" value="label" index="tabNum">
        <li class="${active}">
            <t:eventlink context="label" class="no-text-decoration
tapestry-tab-select" zone="tabZone"
                         event="onTabClick">
                ${label}
            </t:eventlink>
        </li>
    </t:loop>
<div class="tab-content">
    <t:zone t:id="tabZone" id="tabZone">
        <t:delegate to="tabMarkup"/>
    </t:zone>
</div>

@InjectPage
private TestPage testPage;

@OnEvent(value = "onTabClick")
void onTabClick(String tabLabel) {
    if (request.isXHR()) {
        ajaxResponseRenderer.addRender(tabZone);
    }
}

public Object getTabMarkup() {
    testPage.onActivate("test");
    return testPage;
}

Thanks,
Charan
Reply | Threaded
Open this post in threaded view
|

Re: Pagelink with a zone

Thiago H de Paula Figueiredo
Hello!

I'm afraid I don't understand the desired scenario here. PageLink is for
full page requests, not for AJAX (including Zones). If you really want to
keep the webapp strucutred that way (i.e. each tab is a page), you'd be
better served with iframes.

On the other hand, my recommendation is having a component instead of a
page for each tab. Also, you could reuse these components in pages if you
need or want that.

On Mon, Apr 27, 2020 at 5:03 PM Charan Lingamgunta <[hidden email]>
wrote:

> Is there a way I can direct the pagelink component to a zone. I tried using
> eventlink and delegate to return the instance of an injected page. This
> works but I have dynamic number of pages in a loop for a tab component. I
> would just like to specify in the link where the page should be loading.
>
> So ideally I want a pagelink with a target div.
>
> Here is what I tried. Could you please point me in the right direction?
>
> <t:loop source="tabList" value="label" index="tabNum">
>         <li class="${active}">
>             <t:eventlink context="label" class="no-text-decoration
> tapestry-tab-select" zone="tabZone"
>                          event="onTabClick">
>                 ${label}
>             </t:eventlink>
>         </li>
>     </t:loop>
> <div class="tab-content">
>     <t:zone t:id="tabZone" id="tabZone">
>         <t:delegate to="tabMarkup"/>
>     </t:zone>
> </div>
>
> @InjectPage
> private TestPage testPage;
>
> @OnEvent(value = "onTabClick")
> void onTabClick(String tabLabel) {
>     if (request.isXHR()) {
>         ajaxResponseRenderer.addRender(tabZone);
>     }
> }
>
> public Object getTabMarkup() {
>     testPage.onActivate("test");
>     return testPage;
> }
>
> Thanks,
> Charan
>


--
Thiago
Reply | Threaded
Open this post in threaded view
|

Re: Pagelink with a zone

SunnyPenguin
> my recommendation is having a component instead of a
> page for each tab
>

That was my first solution for this. It just seemed a little odd to have
non-reusable pages in the components directory. But we can live with that.

Just so I'm not misunderstanding anything, there is no correct way to
render pages through AJAX. Or to put them in a block like we do components.
Out of curiosity, is there a reason for this? I guess I don't really
understand what the difference is in rendering components vs pages.

And thank you for the answer. I appreciate it.

Charan.

On Thu, Apr 30, 2020 at 6:18 PM Thiago H. de Paula Figueiredo <
[hidden email]> wrote:

> Hello!
>
> I'm afraid I don't understand the desired scenario here. PageLink is for
> full page requests, not for AJAX (including Zones). If you really want to
> keep the webapp strucutred that way (i.e. each tab is a page), you'd be
> better served with iframes.
>
> On the other hand, my recommendation is having a component instead of a
> page for each tab. Also, you could reuse these components in pages if you
> need or want that.
>
> On Mon, Apr 27, 2020 at 5:03 PM Charan Lingamgunta <[hidden email]>
> wrote:
>
> > Is there a way I can direct the pagelink component to a zone. I tried
> using
> > eventlink and delegate to return the instance of an injected page. This
> > works but I have dynamic number of pages in a loop for a tab component. I
> > would just like to specify in the link where the page should be loading.
> >
> > So ideally I want a pagelink with a target div.
> >
> > Here is what I tried. Could you please point me in the right direction?
> >
> > <t:loop source="tabList" value="label" index="tabNum">
> >         <li class="${active}">
> >             <t:eventlink context="label" class="no-text-decoration
> > tapestry-tab-select" zone="tabZone"
> >                          event="onTabClick">
> >                 ${label}
> >             </t:eventlink>
> >         </li>
> >     </t:loop>
> > <div class="tab-content">
> >     <t:zone t:id="tabZone" id="tabZone">
> >         <t:delegate to="tabMarkup"/>
> >     </t:zone>
> > </div>
> >
> > @InjectPage
> > private TestPage testPage;
> >
> > @OnEvent(value = "onTabClick")
> > void onTabClick(String tabLabel) {
> >     if (request.isXHR()) {
> >         ajaxResponseRenderer.addRender(tabZone);
> >     }
> > }
> >
> > public Object getTabMarkup() {
> >     testPage.onActivate("test");
> >     return testPage;
> > }
> >
> > Thanks,
> > Charan
> >
>
>
> --
> Thiago
>


--
Charan
Reply | Threaded
Open this post in threaded view
|

Re: Pagelink with a zone

Thiago H de Paula Figueiredo
On Mon, May 4, 2020 at 11:18 AM Charan Lingamgunta <[hidden email]>
wrote:

> > my recommendation is having a component instead of a
> > page for each tab
> >
>
> That was my first solution for this. It just seemed a little odd to have
> non-reusable pages in the components directory. But we can live with that.
>

In this case, the component doesn't render a full page (i.e. with <html>,
<head> and <body> elements), so it's not really a page at all in my humble
opinion. It's actually one section of a page. Also, even if you just use
one component in one place, it's still better than having huge components
or pages. Basically, think of components as you think of functions/methods
in programming: when they get too large, it's time to break them down in
smaller pieces.


> Just so I'm not misunderstanding anything, there is no correct way to
> render pages through AJAX.


I wouldn't use that words. I'd say you cannot use PageLink with AJAX.


> Or to put them in a block like we do components.
> Out of curiosity, is there a reason for this?


Because pages are meant to render full documents, and you cannot put a full
HTML document inside another unless you're using iframes, and that doesn't
seem to be the case here.


> I guess I don't really
> understand what the difference is in rendering components vs pages.
>

Pages have URLs, have page activation context, don't have @Parameter and
are expected to render a full HTML document (if you're rendering HTML. Of
course, you can also use pages to return resources like images and other
files).

Components don't have URLs nor page activation context, they
have @Parameter and they're *not* expected to render a full HTML document.


> And thank you for the answer. I appreciate it.
>

My pleasure to help. :)


>
> Charan.
>
> On Thu, Apr 30, 2020 at 6:18 PM Thiago H. de Paula Figueiredo <
> [hidden email]> wrote:
>
> > Hello!
> >
> > I'm afraid I don't understand the desired scenario here. PageLink is for
> > full page requests, not for AJAX (including Zones). If you really want to
> > keep the webapp strucutred that way (i.e. each tab is a page), you'd be
> > better served with iframes.
> >
> > On the other hand, my recommendation is having a component instead of a
> > page for each tab. Also, you could reuse these components in pages if you
> > need or want that.
> >
> > On Mon, Apr 27, 2020 at 5:03 PM Charan Lingamgunta <
> [hidden email]>
> > wrote:
> >
> > > Is there a way I can direct the pagelink component to a zone. I tried
> > using
> > > eventlink and delegate to return the instance of an injected page. This
> > > works but I have dynamic number of pages in a loop for a tab
> component. I
> > > would just like to specify in the link where the page should be
> loading.
> > >
> > > So ideally I want a pagelink with a target div.
> > >
> > > Here is what I tried. Could you please point me in the right direction?
> > >
> > > <t:loop source="tabList" value="label" index="tabNum">
> > >         <li class="${active}">
> > >             <t:eventlink context="label" class="no-text-decoration
> > > tapestry-tab-select" zone="tabZone"
> > >                          event="onTabClick">
> > >                 ${label}
> > >             </t:eventlink>
> > >         </li>
> > >     </t:loop>
> > > <div class="tab-content">
> > >     <t:zone t:id="tabZone" id="tabZone">
> > >         <t:delegate to="tabMarkup"/>
> > >     </t:zone>
> > > </div>
> > >
> > > @InjectPage
> > > private TestPage testPage;
> > >
> > > @OnEvent(value = "onTabClick")
> > > void onTabClick(String tabLabel) {
> > >     if (request.isXHR()) {
> > >         ajaxResponseRenderer.addRender(tabZone);
> > >     }
> > > }
> > >
> > > public Object getTabMarkup() {
> > >     testPage.onActivate("test");
> > >     return testPage;
> > > }
> > >
> > > Thanks,
> > > Charan
> > >
> >
> >
> > --
> > Thiago
> >
>
>
> --
> Charan
>


--
Thiago