> Why ModifiableMarkup has to be mutable ?
> Do you expect that the markup will change at runtime in some conditions ?
> I think what you need is a new impl of MarkupElement for the expressions.
> So org.apache.wicket.markup.Markup#markupElements will have more elements.
> Then when rendering starts each element will render itself as appropriate.
> But the list itself won't change once created.
>
Yes markup will change at runtime.  It is primarily because of
RawMarkup.  It is a final class and there are several examples of: if
(element instanceof RawMarkup) do something;  in wicket so when
resolving the EL expressions in the markup the only 'safe' way to do it
and stay completely transparent to wicket is to replace the original
RawMarkup with a new one... e.g.

in the EL component:
public void onRender() {
    modifiableMarkup.resolve(some params);
    super.onRender();
}

What it looks like inside MarkupModifier.resolve() is something like this:

original RawMarkup.toString: "<span>${myProperty}</span>"
resolved = new RawMarkup("<span>my property value</span>");
modifiableMarkup.replace(rawMarkupIndex, resolved);

(actually it's not really relevant to this discussion but the original
RawMarkup contains a marker token instead of the original expression to
ensure it's XML legal before it's passed to the markup parser... in this
case it would be '${#[expressionIndex]}'   )

here's a link to ModifiableMarkup
https://bitbucket.org/shadders/wicket-el/src/917bb51f19ddd6e631d8ce537c90915eb21fb01f/src/main/java/org/apache/wicket/markup/ModifiableMarkup.java?at=default

So I can't call makeImmutable() on ModifiableMarkup or it will throw an
exception whenever replace(index, markupElement) is called.  However the
length of the element list will never change and each element in the
list will always be the same type.

>If the developer changes the markup then the whole Markup instance is
>replaced with a new one. As now.

That's the entire purpose of this approach... To avoid that.  The
overhead from continually recreating Markups was enormous.

>So far no one needed to add custom MarkupElements and that's why it is not
>very easy.
>You can fork Wicket and create a branch where you can make modifications to
>make it easier and
>later we can review the needed changes and probably apply them back in
>Wicket.

I may give that a go.  This has been an interesting exercise that's
forced to spend a lot of time under the hood in wicket getting to know
the markup sourcing and rendering aspects of it.  I must confess I was a
little concerned the wicket team might not like this project much given
that it's fairly hefty divergence from the wicket way of doing
things...  Wonderful to hear you are open to considering some minor
changes to accomodate it.





---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to