[
https://issues.apache.org/jira/browse/WICKET-2881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12871051#action_12871051
]
bernard commented on WICKET-2881:
---------------------------------
Hi Juergen,
Thanks very much for your explanation. I think I don't understand all of it
well enough yet to achieve my goal. I want to change wicket behavior so that it
removes any "../" tokens that may exist in pages in custom resource folders for
better HTML editing support. I thought I could achieve that by adding very
little code in RelativePathPrefixHandler as follows:
/**
* Behavior that adds a prefix to src, href and background attributes
to make them
* context-relative
*/
public static final IBehavior RELATIVE_PATH_BEHAVIOR = new
AbstractBehavior()
{
private static final long serialVersionUID = 1L;
@Override
public void onComponentTag(Component component, ComponentTag
tag)
{
IRequestCodingStrategy coder = RequestCycle.get()
.getProcessor()
.getRequestCodingStrategy();
// Modify all relevant attributes
for (int i = 0; i < attributeNames.length; i++)
{
String attrName = attributeNames[i];
String attrValue =
tag.getAttributes().getString(attrName);
if ((attrValue != null) &&
(attrValue.startsWith("/") == false) &&
(attrValue.indexOf(":") < 0) &&
!(attrValue.startsWith("#")))
{
// Change start
// Remove any "../" tokens that may exist in pages in custom
// resource folders for better HTML editing.
int lastIndex = attrValue.lastIndexOf("../");
if (lastIndex >= 0)
{
attrValue = attrValue.substring(lastIndex + 3);
}
// Change end
tag.getAttributes().put(attrName,
coder.rewriteStaticRelativeUrl(attrValue));
}
}
}
};
How can I do this without changing Wicket source code?
Many thanks.
> Cannot substitute RelativePathPrefixHandler
> -------------------------------------------
>
> Key: WICKET-2881
> URL: https://issues.apache.org/jira/browse/WICKET-2881
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4.8
> Environment: All
> Reporter: bernard
>
> In IPageSettings
> Get the (modifiable) list of IComponentResolvers.
> List<IComponentResolver> getComponentResolvers();
> This looks very useful and easy indeed, and in Application.init() one can
> find and remove
> RelativePathPrefixHandler and replace it with a different
> AbstractMarkupFilter implementation e.g. XRelativePathPrefixHandler.
> But even while the List.remove(Object o) returns true, and the handler
> appears to be removed, it is still active.
> I don't know why and what holds on to it or what creates a new
> RelativePathPrefixHandler.
> If I add my XRelativePathPrefixHandler, it is not used.
> Consider
> public class MarkupParser
> public final void appendMarkupFilter(final IMarkupFilter filter)
> {
> appendMarkupFilter(filter, RelativePathPrefixHandler.class);
> }
> So RelativePathPrefixHandler seems to be something special and I am afraid of
> other potential complications in case replacement would work.
> Can Wicket be fixed to make a replacement as easy as it appears to be?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.