Announcement Announcement Module
Collapse
No announcement yet.
Spring Batch Admin - Home Menu Breaks When Using A ServletMapping Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:

    Code:
    	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
    Code:
    	<servlet-mapping>
    		<servlet-name>Batch Servlet</servlet-name>
    		<url-pattern>/batch/*</url-pattern>
    	</servlet-mapping>
    and then overriding the resourceService
    Code:
    	<bean id="resourceService" class="org.springframework.batch.admin.web.resources.DefaultResourceService">	
    		<property name="servletPath" value="/batch"/>
    	</bean>
    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

    Code:
    	<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?

    Comment


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

      Code:
      <#assign home_url><@spring.url relativeUrl="${servletPath}/"/></#assign>
      <#assign company_url><@spring.messageText code="company.url" text=companyUrl!"http://www.springsource.com"/></#assign>
      <#assign company_name><@spring.messageText code="company.name" text=companyName!"SpringSource"/></#assign>
      <#assign product_url><@spring.messageText code="product.url" text=productUrl!"http://static.springframework.org/spring-batch"/></#assign>
      <#assign product_name><@spring.messageText code="product.name" text=productName!"Spring Batch"/></#assign>
      <div id="primary-navigation">
      	<div id="primary-left">
      		<ul>
      			<#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>
      			<#else>
      				<li><a href="${menu_url}">${menu.label}</a></li>
      			</#if>
      			</#list>
      		</ul>
      	</div>
      	<div id="primary-right">
      		<ul>
      			<li><a href="${company_url}">${company_name}</a></li>
      			<li><a href="${product_url}">${product_name}</a></li>
      		</ul>
      	</div>
      </div><!-- /primary-navigation -->

      Comment


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

        Comment

        Working...
        X