How to use EDIT_PROJECT_PAGE_TAB?

Hi all,

I'm rather new to Spring development as well as TC development, so sorry if this is trivial.

I'm trying to build a custom tab in the project view, I've already succeeded adding page extensions to other parts of TC.

Now, seemingly no matter what I do, I get an exception

Trace: java.lang.InstantiationException: bean currentProject not found within scope
     at org.apache.jsp.admin.editProject_jsp._jspService(editProject_jsp.java:111)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
     at jetbrains.spring.web.TeamCityJSPServletImpl.service(TeamCityJSPServletImpl.java:2)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     at jetbrains.spring.web.JspController.doHandle(JspController.java:7)
     at jetbrains.buildServer.controllers.BaseController.handleRequestInternal(BaseController.java:73)
     at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
     at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     at jetbrains.buildServer.rootDispatcher.TeamCityDispatcherServlet.service(TeamCityDispatcherServlet.java:543)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
     at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
     at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
     at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:236)
     at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:257)
     at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1183)
     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:902)
     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     at jetbrains.buildServer.rootDispatcher.TeamCityDispatcherServlet.service(TeamCityDispatcherServlet.java:543)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     at jetbrains.buildServer.web.DiagnosticFilter.runChainWithModifiedThreadName(DiagnosticFilter.java:13)
     at jetbrains.buildServer.web.DiagnosticFilter.doFilter(DiagnosticFilter.java:9)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     at jetbrains.buildServer.web.ResponseFragmentFilter.doFilter(ResponseFragmentFilter.java:10)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
     at java.lang.Thread.run(Thread.java:680)


What is the currentProject bean, and what do I need to do to make it available?

My current implementation creates a bean as follows

  <bean id="EditProjectTab"
        
        init-method="register">
    <property name="placeId" value="EDIT_PROJECT_PAGE_TAB"/>
    <property name="tabTitle" value="Debian Configuration"/>
    <property name="pluginName" value="Webextension"/>
    <property name="includeUrl" value="Webextension/editProject.jsp"/>
  </bean>



And the class is just a stub

public class EditProjectTab extends ProjectTab {
  protected EditProjectTab(PagePlaces pagePlaces, ProjectManager projectManager) {
    super("test","test", pagePlaces, projectManager);
  }

  @Override
  public boolean isAvailable(@NotNull final HttpServletRequest request) {
    /* Check if it is a debian project */
    return true;
  }

  
  @Override
  public void fillModel(java.util.Map model,
                                  javax.servlet.http.HttpServletRequest request,
                                  @NotNull
                                  SProject project,
                                  SUser user) {
  }
}


Any ideas? Any help is appreciated :)
/Johan
4 comments

Hello Gohan,


Seems like your JSP at Webextension/editProject.jsp refers "currentProject" bean which is not added to the model.

0

The contents of my .jsp file is


<%@ include file="/include.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


Or even empty gives the same result.

/Johan
*** Edit, this is on 6.5.4 (build 18046).

0

If you want to add new tab on edit project interface you should not extend ProjectTab, because it is for project page available from the overview when you click on the project name (view only).
Unfortunately for the moment there is no similar abstract class for edit project tab in open API, but there is one in closed API, it's called EditProjectTab.

If you do not want to use closed API, here is source code of the EditProjectTab which you can use as the base for your code:

public abstract class EditProjectTab extends SimpleCustomTab {
  private final ProjectManager myProjectManager;

  protected EditProjectTab(final PagePlaces pagePlaces, final String pluginName, final String includeUrl, final String title, final ProjectManager projectManager) {
    super(pagePlaces, PlaceId.EDIT_PROJECT_PAGE_TAB, pluginName, includeUrl, title);
    myProjectManager = projectManager;
    register();
  }

  public SProject getProject(@NotNull HttpServletRequest request) {
    String projectId = request.getParameter("projectId");
    if (projectId != null) {
      return myProjectManager.findProjectById(projectId);
    }
    return null;
  }

  public void fillModel(@NotNull final Map<String, Object> model, @NotNull final HttpServletRequest request) {
    super.fillModel(model, request);
    model.put("currentProject", getProject(request));
  }

  public boolean isAvailable(@NotNull final HttpServletRequest request) {
    return getProject(request) != null;
  }
}

0

Please sign in to leave a comment.