I have added @DataBoundConstructor annotation to the constructor too!

On Tuesday, 8 July 2014 10:04:07 UTC-7, Karthik V S wrote:
>
> Hi,
>
> I have a custom form in my Application and I would like to load values to 
> its fields.
>
> For this purpose I have a class that extends from ItemListener and have 
> overriden the onUpdated method to read the updated config file and set 
> values to the text box fields by creating an Action object,adding that 
> action object to the project  and saving the project. For some reason this 
> does not work. The code snippet is below!
>
> *Action Class:*
>
> public class MyAction<T extends AbstractItem> implements Action {
>
>     final private T item;
>     private String gitRepo;
>     private String gitBranch;
>     private String mavenGoals;
>     private String mavenPOM;
>     private String eMailRecipient;
>
>     public MyAction(T item, String gitRepo, String gitBranch, String 
> mavenGoals, String mavenPOM, String eMailRecipient) {
>         this.item = item;
>         this.gitRepo = gitRepo;
>         this.gitBranch = gitBranch;
>         this.mavenGoals = mavenGoals;
>         this.mavenPOM = mavenPOM;
>         this.eMailRecipient = eMailRecipient;
>     }
>
>     public String getGitRepo() {
>         return gitRepo;
>     }
>
>     public String getGitBranch() {
>         return gitBranch;
>     }
>
>     public String getMavenGoals() {
>         return mavenGoals;
>     }
>
>     public String getMavenPOM() {
>         return mavenPOM;
>     }
>
>     public String geteMailRecipient() {
>         return eMailRecipient;
>     }
>     
>    public MyAction(T item) {
>         this.item = item;
>     }
>
>     public T getItem() {
>         return item;
>     }
>
>
> *ItemListener Class*
>
> @Extension
> public class MyActionListener extends ItemListener{
>     
>     @Override
>     public void onUpdated(Item item){
>         if(item instanceof AbstractItem)
>         {
>             for(Action action : Jenkins.getInstance().getActions())
>                 if(action.getClass()==MyAction.class)
>                 {
>                     AbstractProject proj=(AbstractProject) item;
>                     XmlFile projConfig=proj.getConfigFile();
>                     String config=projConfig.toString();
>                     String 
> gitRepo=config.substring(config.indexOf("<url>")+5, 
> config.indexOf("</url>"));
>                     String 
> branch=config.substring(config.indexOf("<name>")+6,config.indexOf("</name>"));
>                     String 
> mavengoals=config.substring(config.indexOf("<target>")+8,config.indexOf("<target>"));
>                     String 
> mavenPom=config.substring(config.indexOf("<pom>")+5,config.indexOf("</pom>"));
>                     String 
> eMailReceipient=config.substring(config.indexOf("<recipientList>")+15,config.indexOf("<recipientList>"));
>                     Action newAction=new MyAction((AbstractItem) 
> item,gitRepo,branch,mavengoals,mavenPom,eMailReceipient);
>                     proj.addAction(newAction);
>                 try {
>                     proj.save();
>                 } catch (IOException ex) {
>                     
> Logger.getLogger(MyActionListener.class.getName()).log(Level.SEVERE, null, 
> ex);
>                 }
>                 }
>         }
>     }
> }
>
> *Jelly File:*
>
> <f:form method="post" name="config" action="configSubmit">
>       <f:block>
>         <f:section title="${%Job Configuration}">
>             <f:entry title="${%Job name}">
>     <f:textbox id="name" name="name" default="${it.ItemName}"/>
>             </f:entry>
>        </f:section>
>        <f:section title="${%Source Code Management}">
>            <f:entry title="${%Git Repo}">
>                <f:textbox id="repo" name="repo" 
> default="[email protected]:{Enter your git repo here}" 
> value="${it.GitRepo}"/>
>            </f:entry>
>            <f:entry title="${%Branch}">
>                <f:textbox id="branch" name="branch" default="master" 
> value="${it.GitBranch}"/>
>            </f:entry>
>        </f:section>
>            <f:section title="${%Maven Targets}">
>            <f:entry title="${%Goals}">
>                <f:textbox id="goals" name="goals" default="-U clean 
> install" value="${it.MavenGoals}"/>
>            </f:entry>
>            <f:entry title="${%POM}">
>                <f:textbox id="pom" name="pom" default="pom.xml" 
> value="${it.MavenPOM}"/>
>            </f:entry>
>        </f:section>
>        <f:section title="${%E-Mail Notification}">
>            <f:entry title="${%Recipient}">
>                <f:textbox id="emailrecipient" name="emailrecipient" 
> default="QE DL For Notifying" value="${it.eMailRecipient}"/>
>            </f:entry>
>        </f:section>
>        <f:section title="${%Assembler Postbuild}">
>             <f:entry title="${%Assembler Target POM.xml{relative path}}">
>                 <f:textbox id="assemblerpom" name="assemblerpom"/>
>             </f:entry>
>        </f:section>
>        </f:block>
>         <f:bottomButtonBar>
>         <f:submit value="${%Save}" />
> </f:bottomButtonBar>
>     </f:form>
>
>
> What am i doing wrong here??
>

-- 
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/d/optout.

Reply via email to