How to makes custom form that bind to my JobProperty class automatically?

14 views
Skip to first unread message

Cheng Bao

unread,
Aug 19, 2016, 8:56:39 PM8/19/16
to Jenkins Developers
Hi,

I created a MyJobPropery class which extends JobProperty.
I know I can use config.jelly to make my fields of MyJobProperty shown under /job/<job name>/configure page.
However, I want create a dedicate form for users to input fields of MyJobProperty besides default  /job/<job name>/configure,
i.e from an action that bind to url: /MyPlugin/configMyJobProperty/<job name>.
say I have a method
public class MyPlugin implementsRootAction {
   
public final void doConfigMyJobProperty(StaplerRequest req, StaplerResponse rsp) {
       
//... theory code
        MyJobProperty myProp = AbstractProject.findNearest(jobName);
        req.bindObject(myProp).getView(this, "../MyJobProperty/config.jelly").forward(req, rsp);
        //...
        
    }
}


I wonder what code I need that can make config.jelly bind to a MyJobProperty instance?

I know I can manually populate all values from MyProperty to config.jelly controls, and doing manual reverse population from form data to MyJobProperty.
I wonder if Jenksin provide a way that I can take advantage of Jenkins internal databind.

Thanks.
Reply all
Reply to author
Forward
0 new messages