I simply parse the component id. Being an iterating component - Tridindad adds a progressive index while stamping out subcomponents:

    public void navigation(ActionEvent event) {
        FacesContext fc = FacesContext.getCurrentInstance();
        UIComponent actionItem = event.getComponent();
        String id = actionItem.getClientId(fc);
        int i = id.lastIndexOf(NamingContainer.SEPARATOR_CHAR);
        if (i >= 0) {
            id = id.substring(0, i);
            i = id.lastIndexOf(NamingContainer.SEPARATOR_CHAR);
            id = id.substring(i + 1);
            int newSelected = Integer.parseInt(id);
       .....

This should work well for all Trinidad iterating components, provided that stamping includesTrinidad components only. Otherwise, the index can be easily forgotten by Trinidad (then duplicated id warnings), don't ask me why.

-- Renzo

Francisco Passos wrote:
Thank you, your example is great.

However, how do you know what tab has been clicked, so you can act accordingly on the actionListener?


On 7/2/07, Renzo Tomaselli <[EMAIL PROTECTED]> wrote:
Francisco,
    component tr:navigationPane is an iterating component by itself - no need for an explicit loop. I do it like this (using Facelets):

<ui:component>
    <c:if test="#{bean.visible}">
        <t:saveState id="selected" value="#{bean.selected}"/>
        <t:saveState id="tabs" value="#{bean.tabs}"/>
        <tr:navigationPane id="tabber" hint="tabs" value="#{bean.tabModel}" var="tab" styleClass="navigator">
            <f:facet name="nodeStamp">
                <tr:commandNavigationItem text="#{tab.label}" actionListener="#{bean.navigation}"
                        id="tab" selected="#{cx:isSelected(bean, tab)}" icon="#{tab.icon}"/>
            </f:facet>
        </tr:navigationPane>
        <cx:include src="" bean="#{bean.componentBean}" container="#{container}tabby:"/>
    </c:if>
</ui:component>

Here everythings - from the tab list to the child component to appear below the tabs - is dynamically taken from a bean.
Tab list and current selection are made persistent across requests by means of saveState (my beans are only request-scoped).
Hope it helps.

-- Renzo




Francisco Passos wrote:
By the way, I'm trying to populate dinamically either a panelTabbed or a navigationPane.

When using ui:repeat, panelTabbed renders incorrectly (no content appears) and this is shown on the logs:
WARNING: Only tr:showDetailItem is allowed as child of tr:panelTabbed.

When using ui:repeat and navigationPane, an exception is thrown:
SEVERE: Warning: illegal component hierarchy detected, expected UIXCommand but found another type of component instead.
java.lang.ClassCastException : com.sun.facelets.component.UIRepeat

I'm going to try my luck with JSTL now, nevertheless if you know of a solution, do tell :)

--Francisco

On 7/2/07, Francisco Passos <[EMAIL PROTECTED]> wrote:
Simon and Matthias,

thank you for clearing my doubt. By the way, if I may leave the suggestion, it would be cool if panelTabbed had alternative ways for presentation, much like navigationPage.

As far as the wiki, I've added the missing entry to the page for completeness, although obviously it may still be incomplete.

--Francisco


On 7/2/07, Matthias Wessendorf < [EMAIL PROTECTED]> wrote:
Francisco,

we started a wiki, containing infos like this, in the past,
but never updated it.

feel free to join ;-)

-M

On 7/2/07, Simon Lessard < [EMAIL PROTECTED]> wrote:
> Hello Francisco,
>
> No, menuTabs was replaced by navigationPane with hint attribute set to tabs.
>
>
> Regards,
>
> ~ Simon
>
>
> On 7/2/07, Francisco Passos <[EMAIL PROTECTED]> wrote:
> > Thank you.
> >
> > The correspondence I couldn't find in the wiki was for the component
> af:menuTabs, but probably panelTabbed also replaces it.
> >
> >
> >
> > On 6/29/07, Adam Winer < [EMAIL PROTECTED]> wrote:
> > > Actually, the Wiki page shows the renaming:
> > > panelTabbed was formerly called showOneTabs.
> > >
> > > There's an example in trinidad-demo.
> > >
> > > -- Adam
> > >
> > >
> > > On 6/29/07, Francisco Passos < [EMAIL PROTECTED] > wrote:
> > > > Hello there.
> > > >
> > > > I'm evaluating the usage of a panelTabbed. Are there any working
> examples of
> > > > this component?
> > > >
> > > > The only example I have is from an ADF Faces app, which uses
> af:menuTabs,
> > > > but http://wiki.apache.org/myfaces/Trinidad_renaming
> does
> > > > not mention any changes to this component.
> > > >
> > > > Thanks,
> > > > Francisco
> > > >
> > >
> >
> >
>
>


--
Matthias Wessendorf

further stuff:
blog: http://matthiaswessendorf.wordpress.com/
mail: matzew-at-apache-dot-org



Reply via email to