Announcement Announcement Module
No announcement yet.
Spring Batch Admin - Home Menu Breaks When Using A ServletMapping Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Batch Admin - Home Menu Breaks When Using A ServletMapping

    I'm trying to find a way around this issue at this point and think it should be fixed in the next release.

    Currently the HomeMenu registers itself with the URL "" as seen below:

    	public HomeMenu() {
    		super("", "Home", Integer.MIN_VALUE);
    This works fine if you are mapping the dispatcher servlet to root "/"; however, if you follow the guidelines for changing the default mapping (to lets say "/batch") which involves updating the web.xml servlet-mapping
    		<servlet-name>Batch Servlet</servlet-name>
    and then overriding the resourceService
    	<bean id="resourceService" class="org.springframework.batch.admin.web.resources.DefaultResourceService">	
    		<property name="servletPath" value="/batch"/>
    the Home link stops working because the code will concat the prefix and url resulting in "/batch". If I change the servletPath in resource service to "/batch/" the Home link works again but the rest break because you end up with urls like "/batch//jobs".

    Long story short, HomeMenu should really pass "/" to BaseMenu or more accurately "/home".

    Finally, to my question. Is there an easy way to override the HomeMenu bean to use "/home" instead until the code is updated? It doesn't have an id defined for it in the manager-context.xml so I'm not sure how

    	<bean class="org.springframework.batch.admin.web.HomeMenu" parent="baseMenu"/>
    	<bean class="org.springframework.batch.admin.web.JobsMenu" parent="baseMenu"/>
    	<bean class="org.springframework.batch.admin.web.ExecutionsMenu" parent="baseMenu"/>
    	<bean class="org.springframework.batch.admin.web.FilesMenu" parent="baseMenu"/>
    I've thought about overriding the menuManager itself and manually grabbing the HomeMenu after its been injected but hate hacks like that. If anyone has another idea, please let me know. Thanks!

  • #2
    I've seen this as well. Does anyone have any suggestions on the best workaround?


    • #3
      I did a work around for this. Drop the following code in WEB-INF/web/layouts/html/navigation.ftl

      <#assign home_url><@spring.url relativeUrl="${servletPath}/"/></#assign>
      <#assign company_url><@spring.messageText code="company.url" text=companyUrl!""/></#assign>
      <#assign company_name><@spring.messageText code="" text=companyName!"SpringSource"/></#assign>
      <#assign product_url><@spring.messageText code="product.url" text=productUrl!""/></#assign>
      <#assign product_name><@spring.messageText code="" text=productName!"Spring Batch"/></#assign>
      <div id="primary-navigation">
      	<div id="primary-left">
      			<#list menuManager.menus as menu>
      			<#assign menu_url><@spring.url relativeUrl="${menu.url}"/></#assign>
      			<#if menu.label == "Home">
      				<li><a href="${menu_url}/home">${menu.label}</a></li>
      				<li><a href="${menu_url}">${menu.label}</a></li>
      	<div id="primary-right">
      			<li><a href="${company_url}">${company_name}</a></li>
      			<li><a href="${product_url}">${product_name}</a></li>
      </div><!-- /primary-navigation -->


      • #4
        I like it! Will have to do until the source is fixed. Thanks!