yep, that can work. didnt think about it, good one.

-Igor


On 10/6/06, Juergen Donnerstag <[EMAIL PROTECTED]> wrote:

Page.getAutoIndex() provides a unique number within a page. Why not
just some prefix + autoIndex?

Juergen

On 10/6/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> yes, only this is much lighter
>
> -Igor
>
>
> On 10/6/06, Johan Compagner <[EMAIL PROTECTED]> wrote:
> >
> > ha! that looks partial to my URLCompressor solution.. (only that does
even
> > a
> > bit more)
> >
> > johan
> >
> >
> > On 10/6/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> > >
> > > ive been noticing more and more how rediculously long markup ids are
> > > getting
> > > in nontrivial pages. i mean a markupid of 50 characters? comon!
> > >
> > > here is my take on optimizing the length and still keeping it
reasonably
> > > readeable. once we have support for figuring out if we are in prod
or
> > dev
> > > mode we can optimize it even further by stripping component id.
> > >
> > > should this go into 1.2? or wait for 1.3? or this idea sucks
alltogether
> > > and
> > > should never see the light of svn?
> > >
> > > -Igor
> > >
> > >
> > > Index: D:/ws/wicket-1.x/src/java/wicket/Component.java
> > > ===================================================================
> > > --- D:/ws/wicket-1.x/src/java/wicket/Component.java    (revision
7558)
> > > +++ D:/ws/wicket-1.x/src/java/wicket/Component.java    (working
copy)
> > > @@ -915,26 +915,12 @@
> > >       */
> > >      public String getMarkupId()
> > >      {
> > > -        /*
> > > -         * TODO Post 1.2: Restore the code below after the
constructor
> > > refactor,
> > > -         * right now its causing too much pain for components
inside
> > > listviews
> > > -         * and borders.
> > > -         *
> > > -         * CODE:
> > > -         *
> > > -         * String id = getMarkupAttributes().getString("id"); if
(id ==
> > > null) {
> > > -         * id = getPageRelativePath(); } return id;
> > > -         *
> > > -         * JAVADOC:
> > > -         *
> > > -         * If the id attribute is present in the markup attributes
of
> > > this
> > > -         * component it will be used, otherwise the page-relative
path
> > of
> > > this
> > > -         * component will be used. <p>
> > > -         *
> > > -         *
> > > -         */
> > > -
> > > -        return getPageRelativePath().replace(':', '_');
> > > +        String markupId=(String)getMetaData(MARKUP_ID_KEY);
> > > +        if (markupId==null) {
> > > +            markupId=getId()+getPage().nextUniqueValue();
> > > +            setMetaData(MARKUP_ID_KEY, markupId);
> > > +        }
> > > +        return markupId;
> > >      }
> > >
> > >      /**
> > > @@ -1665,6 +1651,13 @@
> > >          // Call any tag handler
> > >          onComponentTag(tag);
> > >
> > > +        Iterator handlers =
> > > getApplicationSettings().getComponentTagHandlers().iterator();
> > > +        while (handlers.hasNext())
> > > +        {
> > >
> >
+            ((IComponentTagHandler)handlers.next()).onComponentTag(this,
> > > tag);
> > > +        }
> > > +
> > > +
> > >          // If we're an openclose tag
> > >          if (!tag.isOpenClose() && !tag.isOpen())
> > >          {
> > > @@ -3066,4 +3059,15 @@
> > >      {
> > >          setFlag(FLAG_HEAD_RENDERED, false);
> > >      }
> > > +
> > > +
> > > +    /**
> > > +     * Metadata key used to store/retrieve markup id
> > > +     */
> > > +    private static MetaDataKey MARKUP_ID_KEY = new MetaDataKey(
> > > String.class
> > > )
> > > +    {
> > > +
> > > +        private static final long serialVersionUID = 1L;
> > > +
> > > +    };
> > > }
> > > I
> > > Index: D:/ws/wicket-1.x/src/java/wicket/Page.java
> > > ===================================================================
> > > --- D:/ws/wicket-1.x/src/java/wicket/Page.java    (revision 7558)
> > > +++ D:/ws/wicket-1.x/src/java/wicket/Page.java    (working copy)
> > > @@ -183,6 +183,10 @@
> > >      /** Version manager for this page */
> > >      private IPageVersionManager versionManager;
> > >
> > > +
> > > +    /** Counter for generating unique values by calling # */
> > > +    private int counter;
> > > +
> > >      /**
> > >       * Constructor.
> > >       */
> > > @@ -240,6 +244,15 @@
> > >          init(pageMap);
> > >      }
> > >
> > > +
> > > +    /**
> > > +     * @return unique integer value within the scope of the page
> > > +     */
> > > +    public final int nextUniqueValue()
> > > +    {
> > > +        return counter++;
> > > +    }
> > > +
> > >
> > >
> >
> >
>
>

Reply via email to