problem Repository (spring)

Dear sirs,
I am writing you since I am experiencing a few problems in developing a plugin for TeamCity. More precisely, I am not able to create a repository so that I can memorize and extract the data from one page to another.


To be clearer, when I implement in ConfigurationTabExtension the following code lines:

RepositoryPlugin repository;

ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/build-server-plugin-samplePlugin.xml");

My plugin breaks

I really do not understand why.

Moreover, I was willing to add:

repository = (RepositoryPlugin) context.getBean("sampleConfigTabFragment");

repository.setProva("prova");


The spring's file is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans default-autowire="constructor">

  <bean id="sampleRepositoryPlugin" />

  <bean id="sampleConfigTab"
        
        init-method="register">
    <property name="placeId" value="BUILD_RESULTS_TAB"/>
    <property name="tabTitle" value="Sample Build Result Tab"/>
    <property name="pluginName" value="samplePlugin"/>
    <property name="includeUrl" value="simplePage.jsp"/>
  </bean>

  <bean id="sampleBuildFragment"
      
      init-method="register">
      <property name="placeId" value="BUILD_RESULTS_FRAGMENT"/>
      <property name="pluginName" value="samplePlugin"/>
      <property name="includeUrl" value="simplePage.jsp"/>
  </bean>

  <bean id="sampleConfigTabFragment" >
      <property name="includeUrl" value="configurationTab.jsp"/>
      <property name="repository" ref="sampleRepositoryPlugin" />
  </bean>

  <bean id="helloController" init-method="register">
    <property name="repository" ref="sampleRepositoryPlugin" />
  </bean>
</beans>

I would be very pleased if you could be of some help TabExtension the following code lines:

3 comments
Comment actions Permalink

Hi Alessandro,

Could you please describe what id the original task you are tring to implement?

Why do you need "context.getBean("sampleConfigTabFragment");" ? You can request the bean in constructor (prividing the class of the bean is unique or use <property ... ref="XXX"/> to pass one bean into another.

If you need the context i the plugin, try adding ConfigurableApplicationContext parameter to one of your beans and will get it via autowiring.

0
Comment actions Permalink

Thanks Yegor
I've tried to put the bean in constructor and now everything works.
However, I have another small problem.
My plug-in is almost done, its goal is to download the tests' history and to list those which have worsened as regards the performance. The point is that I've developed the plug-in mainly on a CustomTab, and I've read that the " fillModel(Map, HttpServletRequest) method is called only if the tab is selected by the user". In fact, as I tried sending the parameters to the server via the form by "refreshing the page", the plug-in broke.  So, I was forced to do as follows:
In the jsp page of the CustomTab:
<form method="post" action="/trypage.html">
<p>Size?</p>
<input id="sizeChoose" name="size" type="text" value="${usedSize}"/>
<input type="submit" name="confirmSize" value="ok"/>
</form>

Afterwards, I had to create a class which refers to "trypage.html" and extends BaseController.
So, when the user clicks on the form, he is redirected to "trypage.html, the server modifies the dimension, and then the user has to click on the "back button" if he wishes to see the changes.
This process described above works correctly, however I would like to include the set of operations in one single step and I was wondering If you could give me any advice on how to do so.
I thank you in advance for your reply.

0
Comment actions Permalink

Alessandro,

> My plug-in is almost done, its goal is to download the tests' history and to list those which have worsened as regards the performance

Great! Do you plan to make it publicly available?


> In fact, as I tried sending the parameters to the server via the form by "refreshing the page", the plug-in broke.

Do you mean that you need a form on the page which will pass the value to the server and refresh the page using the submitted value?

Seems you have several optins for this:
- reload the page with new URl (and the modified value added into the URL) from the client (e.g. submit form to the same URL + additional parameters, use get method)
- submit form to a custom controller which will then redirect to the original page (return new ModelAndView(new RedirectView(ur"))) from doHandle method of the controller)
- use our utility functions to post the value and then refresh the page via AJAX (a sample can be seen in profiler plugin)

Hope this helps.

0

Please sign in to leave a comment.