You should create PolarionAlmProjectProperty instance with the parameters
in newInstance method.
On Friday, September 28, 2012 4:05:29 PM UTC+10, roland ye wrote:
>
> Hi everyone,
>
> I am a newbie of jenkins plugin development. I developed a class
> PolarionAlmProjectProperty extends JobProperty and deployed it to jenkins,
> when I typed any text in polarionalm.regex and polarionalm.baseUrl
> editboxes in configuration form of a jenkins job, saved it, and then
> reopened configuration UI, both these two editboxes remain blank, no text
> has been saved. what wrong with source code ?
>
> Best Regards,
>
> roland ye
> 2012-9-28
>
> source code of PolarionALMProjectProperty.java
> =======================================
>
> package hudson.plugins.polarionalm;
>
> import net.sf.json.JSONObject;
>
> import org.kohsuke.stapler.StaplerRequest;
>
> import hudson.Extension;
> import hudson.model.AbstractProject;
> import hudson.model.Job;
> import hudson.model.JobProperty;
> import hudson.model.JobPropertyDescriptor;
>
> public class PolarionAlmProjectProperty extends
> JobProperty<AbstractProject<?,?>> {
>
> @Extension
> public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
>
> public static final class DescriptorImpl extends JobPropertyDescriptor
> {
> private String regex;
> private String baseUrl;
>
> public DescriptorImpl() {
> super(PolarionAlmProjectProperty.class);
> load();
> }
>
> @Override
> public boolean configure(StaplerRequest req, JSONObject json)
> throws FormException {
> regex = req.getParameter("polarionalm.regex");
> baseUrl = req.getParameter("polarionalm.base");
> System.out.println("polarionalm regx:" + regex);
> System.out.println("polarionalm baseUrl:" + baseUrl);
>
> save();
> return true;
> }
>
> @Override
> public boolean isApplicable(Class<? extends Job> jobType) {
> //return false;
> return true;
> }
>
> @Override
> public PolarionAlmProjectProperty newInstance(StaplerRequest req,
> JSONObject formData) throws FormException {
> return new PolarionAlmProjectProperty();
> }
>
>
> @Override
> public String getDisplayName() {
> return "polarionalm";
> }
>
> public String getRegex() {
> if(regex == null) return "HUDSON-[0-9]*";
> return regex;
> }
>
> public String getBaseUrl() {
> if(baseUrl == null) return "http://localhost/polarion";
> return baseUrl;
> }
> }
> }
>
> content of config.jelly
> ================
>
> <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
> <f:entry title="polarionalm.regex" field="regex">
> <f:textbox/>
> </f:entry>
> <f:entry title="polarionalm.baseUrl" field="baseUrl">
> <f:textbox/>
> </f:entry>
> </j:jelly>
>
>
>
>