|
JobProperty Questions: msg#00095java.hudson.user
I have a question on using custom JobProperties, I'm noticing some strange behavior. My plugin adds a custom JobDescriptor to the Jobs.PROPERTIES list and I've included a very basic config.jelly. in the correct resource path resources/hudson/plugins/MyJobProperty/global.jelly and a similar one for config.jelly. It contains a simple f:entry with some text fields to display some data, The first thing was that when I create a new Job and enter the Job Configuration page, I thought I would see some of what was in the config.jelly in the UI, but there is no addition. Also, there never was a call to isApplicable() or configure() so it would make sense that nothing gets added to the UI, but I'm not quire sure why this is. The next odd thing was that if I visit the Manage Hudson -> System Configuration page, I do see the additional fields on the UI for my custom property, but there isn't a call to configure() until after I hit save. And load() was never called, so I'm not sure where I have the chance to load the global settings for a custom property. // ------- package hudson.plugins; import hudson.model.AbstractProject; import hudson.model.Job; import hudson.model.JobProperty; import hudson.model.JobPropertyDescriptor; import hudson.tasks.BuildStep ; import org.kohsuke.stapler.StaplerRequest; public class MyJobProperty extends JobProperty<AbstractProject<?,?>> { public static final JobPropertyDescriptor DESCRIPTOR = new Descriptor(); public JobPropertyDescriptor getDescriptor() { return DESCRIPTOR; } private static class Descriptor extends JobPropertyDescriptor { Descriptor() { super(MyJobProperty.class ); } public boolean isApplicable(java.lang.Class<? extends Job> jobType) { System.out.println(jobType); return AbstractProject.class.isAssignableFrom(jobType); } // TODO: support per-project override to the system-wide setting public IvyJobProperty newInstance(StaplerRequest req) throws FormException { System.err.println("NEW INSTANCE!" + req); return new IvyJobProperty(); } public boolean configure(StaplerRequest req) throws FormException { System.err.println("CONFIG!" + req); return true; } public String getDisplayName() { return MyJobProperty.class.toString(); } } } // ----------- // Same for global.jelly & config.jelly <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> <f:entry title="MyProperties" help="${rootURL}/plugin/build-timeout/help-projectConfig.html"> <f:textbox name="myproperties.instance" value="${instance} default" /> <f:textbox name="myproperties.it" value="${it} default" /> </f:entry> </j:jelly> -- - Eri
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Jelly Errors / Debug Advice?, Eric Crahen |
|---|---|
| Next by Date: | Re: JobProperty Questions, Kohsuke Kawaguchi |
| Previous by Thread: | Jelly Errors / Debug Advice?, Eric Crahen |
| Next by Thread: | Re: JobProperty Questions, Kohsuke Kawaguchi |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |