The constructor of your portlet is only invoked when you create the portlet in 
the configuration of the view. Once you restart Jenkins, the portlet is created 
using the XML deserialization. So if you need anything to restore (e.g. 
transient fields) you need to write a readResolve method. 

Example:

    public AbstractWarningsGraphPortlet(final String name, final String width, 
final String height, final String dayCountString) {
        super(name);

        this.width = width;
        this.height = height;
        this.dayCountString = dayCountString;

        configureGraph(new NullGraph());
    }

    /**
     * Restores the configuration after deserialization.
     *
     * @return this instance
     */
    private Object readResolve() {
        configureGraph(getGraphType());

        return this;
    }


Ulli
 
  
Am 10.04.2013 um 07:52 schrieb Kris Kurasz <[email protected]>:

> I'm writing my own Dashboard plugin that extends the DashboardPortlet class 
> from the Dashboard Plugin.  My jelly UI is working great and I can databind 
> to my Java model via the getFoo() convention.  At initialization / 
> construction time I'd like to load an XML file to populate a few public 
> properties, however my DataBoundConstructor is not being called and I don't 
> see what I'm doing wrong.  Here should be the relevant code snippets (less 
> imports, etc):
> 
> public class Dashboard extends DashboardPortlet {
> 
>     // This constructor does not appear to be called
>     @DataBoundConstructor
>     public Dashboard(final String name) {
>         super(name);
> 
>         // Ideally I'd like to load the xml file here
>         // LoadXmlFileAndPopulatePublicProperties("myfile");
>     }
> 
>     // This getter function is successfully called from my jelly script
>     public String getFooName() {
>         return "Foo";
>     }
> 
>     // In case it matters, I'm also defining a descriptor
>     @Extension(optional = true)
>     public static class MyDashboardDescriptor extends 
> Descriptor<DashboardPortlet> {
>         @Override
>         public String getDisplayName() {
>             return "MyDashboardDescriptor";
>         }   
>     }
> }
> 
> My Jelly script is effectively just displaying Foo :
> 
> <j:jelly trim="false" xmlns:j="jelly:core" xmlns:x="jelly:xml" 
> xmlns:html="jelly:html">
>     <html>
>           // contents of public getters is display in an html table here
>     </html>
> </j:jelly>
> 
> I'm developing on Windows 7 using NetBeans 7.2.1 and debugging the java 
> plugin through the built in NetBeans debugger.  Any suggestions as to what 
> I'm doing wrong would be appreciated.
> 
> Thanks,
> 
> -Kris
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to