[
https://issues.apache.org/jira/browse/WICKET-5577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14013375#comment-14013375
]
Tobias Soloschenko edited comment on WICKET-5577 at 5/30/14 7:22 AM:
---------------------------------------------------------------------
Ok, I tested within wicket 6.16.0-SNAPSHOT and it is working like expected. I
overwrite the method in the application this way:
@Override
public IMarkupIdGenerator getMarkupIdGenerator() {
return new DefaultMarkupIdGenerator(){
@Override
public String generateMarkupId(Component component,
boolean createIfDoesNotExist) {
return
"MyCustomNamespace_"+super.generateMarkupId(component, createIfDoesNotExist);
}
};
}
Every component which sets "setOutputMarkupId(true)" were using the
MyCustomNamespace_ prefix.
But there is one little change which might be usefull. Maybe we could put the
initialisation of the DefaultMarkupIdGenerator into the internalInit() method
and make a class attribute out of it and additionally provide a method like
setMarkupIdGenerator(IMarkupIdGenerator markupIdGenerator) to the
org.apache.wicket.Application.By this way of configuration I would be able to
configure the MarkupIdGenerator the same way I can do with the
RequestCycleProvider in the WicketFilter / PortletFilter (have a look into the
init-Method in the WicketFilter):
@Override
public void init(boolean isServlet, FilterConfig filterConfig) throws
ServletException {
super.init(isServlet, filterConfig);
this.application.getRequestCycleSettings().setRenderStrategy(RenderStrategy.REDIRECT_TO_RENDER);
this.application.setMarkupIdGenerator(new
DefaultMarkupIdGenerator()); // Change here for custom markup id rendering
....
}
Thanks a lot!
was (Author: klopfdreh):
Ok, I tested within wicket 6.16.0-SNAPSHOT and it is working like expected. I
overwrite the method in the application this way:
@Override
public IMarkupIdGenerator getMarkupIdGenerator() {
return new DefaultMarkupIdGenerator(){
@Override
public String generateMarkupId(Component component,
boolean createIfDoesNotExist) {
return
"MyCustomNamespace_"+super.generateMarkupId(component, createIfDoesNotExist);
}
};
}
Every component which sets "setOutputMarkupId(true)" were using the
MyCustomNamespace_ prefix.
But there is one little change which might be usefull. Maybe we could put the
initialisation of the DefaultMarkupIdGenerator into the internalInit() method
and make a class attribute out of it and additionally provide a method like
setMarkupIdGenerator(IMarkupIdGenerator markupIdGenerator) to the
org.apache.wicket.Application. With this way of configuration I would be able
to configure the MarkupIdGenerator the same way I can do with the
RequestCycleProvider in the WicketFilter / PortletFilter (have a look into the
init-Method in the WicketFilter):
@Override
public void init(boolean isServlet, FilterConfig filterConfig) throws
ServletException {
super.init(isServlet, filterConfig);
this.application.getRequestCycleSettings().setRenderStrategy(RenderStrategy.REDIRECT_TO_RENDER);
this.application.setMarkupIdGenerator(new
DefaultMarkupIdGenerator()); // Change here for custom markup id rendering
....
}
Thanks a lot!
> Generation of wicket ids with prefix / suffix
> ---------------------------------------------
>
> Key: WICKET-5577
> URL: https://issues.apache.org/jira/browse/WICKET-5577
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 6.13.0
> Environment: -
> Reporter: Tobias Soloschenko
> Assignee: Martin Grigorov
> Priority: Minor
> Fix For: 6.16.0, 7.0.0-M2
>
>
> As mentioned in the following post of the users mailing list:
> http://wicket-users.markmail.org/message/54lo4i4qwoqtmuqv?q=tobias+soloschenko
> It would be great to be able to change the way wicket ids are generated so
> that it is possible to define a custom prefix / suffix.
> Example:
> Without prefix
> <div id="menuItem32">...</div>
> With prefix
> <div id=" ns_Z7_0G8AH001I8CJD0AKTUU2F21004__menuItem32">...</div>
> "ns_Z7_0G8AH001I8CJD0AKTUU2F21004__" would be the prefix.
--
This message was sent by Atlassian JIRA
(v6.2#6252)