cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <Ralph.Go...@dslextreme.com>
Subject Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/
Date Mon, 13 Feb 2006 05:43:49 GMT
I'm having a hard time understanding this.  populate seems to go through 
and figure out what all the page labels should be, but it doesn't do 
anything with them.  I assume this is part of the discussion we've been 
having? As I said there I'm not even sure this is necessary. When Castor 
builds the layout each named item should be able to create its page 
label by doing:

Item item = getParent().getParent();
if (item == null || !(item instanceof NamedItem)) {
    this.label = this.name;
} else {
    this.label = item.getLabel() + "." + this.name;
}

cziegeler@apache.org wrote:
>
> Added: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java
> URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java?rev=377171&view=auto
> ==============================================================================
> --- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java
(added)
> +++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java
Sun Feb 12 05:09:54 2006
> @@ -0,0 +1,59 @@
> +/*
> + * Copyright 2006 The Apache Software Foundation.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.apache.cocoon.portal.profile.impl;
> +
> +import org.apache.avalon.framework.thread.ThreadSafe;
> +import org.apache.cocoon.portal.layout.CompositeLayout;
> +import org.apache.cocoon.portal.layout.Item;
> +import org.apache.cocoon.portal.layout.Layout;
> +import org.apache.cocoon.portal.layout.NamedItem;
> +import org.apache.cocoon.portal.profile.ProfileManagerAspect;
> +import org.apache.cocoon.portal.profile.ProfileManagerAspectContext;
> +import org.apache.cocoon.portal.scratchpad.Profile;
> +
> +/**
> + * $Id$
> + */
> +public class PageLabelProfileManagerAspect
> +    implements ProfileManagerAspect, ThreadSafe {
> +
> +    /**
> +     * @see org.apache.cocoon.portal.profile.ProfileManagerAspect#prepare(org.apache.cocoon.portal.profile.ProfileManagerAspectContext,
org.apache.cocoon.portal.scratchpad.Profile)
> +     */
> +    public void prepare(ProfileManagerAspectContext context, Profile profile) {
> +        final Layout rootLayout = profile.getRootLayout();
> +        if ( rootLayout instanceof CompositeLayout ) {
> +            this.populate((CompositeLayout)rootLayout, "");
> +        }
> +        context.invokeNext();
> +    }
> +
> +    private void populate(CompositeLayout layout, String name) {
> +        for (int j = 0; j < layout.getSize(); j++) {
> +            final Item tab = layout.getItem(j);
> +            final StringBuffer label = new StringBuffer(name);
> +            if (label.length() > 0) {
> +                label.append(".");
> +            }
> +            label.append((tab instanceof NamedItem) ? ((NamedItem) tab).getName()
> +                                                    : Integer.toString(j));
> +            final Layout child = tab.getLayout();
> +            if (child != null && child instanceof CompositeLayout) {
> +                this.populate((CompositeLayout) child, label.toString());
> +            }
> +        }
> +    }
> +}
>
>
>   

Mime
View raw message