Fill textbox default with java

62 views
Skip to first unread message

Markus Axelsson

unread,
Aug 18, 2016, 8:11:05 AM8/18/16
to Jenkins Developers
This will probably my last question about this plugin.

I have what seems as a simple issue. I want to give a default value to a textbox in my PlotBuilder\config.jelly:

<?jelly escape-by-default='true'?>
<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>
   
<table width="100%">

...

     
<f:entry title="${%CSV filename *}" field="csvFileName" help="/plugin/plot-pipeline/help-csvfile.html">
       
<f:textbox name="csvFileName" value="${plot.csvFileName}" clazz="required" default="${it.csvFileName}"/>
     
</f:entry>

...

   
</table>
 
</f:entry>
</j:jelly>

See complete file here.

My PlotBuilder.java contains the following method:

public String getCsvFileName() {
   
return "plot-" + String.valueOf( (int)Math.round( Math.random() * 100000000 ) ) + ".csv";
}


See complete file here.

This resulted in nothing, the textbox in completely empty. 

I was able to do this in different jelly with a different java but not here. The other java implemented Action and StaplerProxy, and for the sake of it I tried to implement those in my PlotBuilder.java as well but without success.


Robert Sandell

unread,
Aug 18, 2016, 9:14:17 AM8/18/16
to jenkin...@googlegroups.com
The it reference is probably not referring to what you think it is, or probably null in case you are adding a new step (there is no instance of the step yet). So you probably need to add your helper method to the descriptor instead.

/B

--
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 jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/4242a0aa-dfa2-4501-a0ef-fdabfb3d82bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Robert Sandell
Software Engineer
CloudBees Inc.

Jesse Glick

unread,
Aug 18, 2016, 9:49:19 AM8/18/16
to Jenkins Dev
On Thu, Aug 18, 2016 at 9:14 AM, Robert Sandell <rsan...@cloudbees.com> wrote:
> add your helper method to the descriptor instead.

Thus `default="${descriptor.defaultCsvFileName}"` where
`DescriptorImpl` contains `public String getDefaultCsvFileName()`.

Markus Axelsson

unread,
Aug 18, 2016, 10:04:39 AM8/18/16
to Jenkins Developers
Great! Moving it into the 'DescriptorImp' sure did the trick!
Reply all
Reply to author
Forward
0 new messages