Is there a way to debug jelly/Descriptor bindings?

630 views
Skip to first unread message

Ivo Bellin Salarin

unread,
Feb 9, 2015, 11:12:03 AM2/9/15
to jenkin...@googlegroups.com
Hi,

I can't figure out why my doFillXXXItems aren't being called.

Is there some way to log/debug jelly<-->Descriptor interactions?

Thanks in advance,
Ivo

Ulli Hafner

unread,
Feb 9, 2015, 2:00:04 PM2/9/15
to jenkin...@googlegroups.com
--
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-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPc4eF_3ZaTwMJWPK_--s1fLViFEm5YY0o8UfcfF%3D5YhmRRkNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Ivo Bellin Salarin

unread,
Feb 9, 2015, 3:55:03 PM2/9/15
to jenkin...@googlegroups.com

Thanks Ulli!

Yet I have to figure why the prototype.js is asking for null:
<html><body>
<h1>404 Not Found</h1>
<p>Stapler processed this HTTP request as follows, but couldn't find the resource to consume the request
<pre>
-> evaluate(&lt;hudson.model.Hudson@6a4edb79> :hudson.model.Hudson,"/MyRootAction/null")
-> evaluate(((StaplerProxy)&lt;hudson.model.Hudson@6a4edb79>).getTarget(),"/MyRootAction/null")
-> evaluate(&lt;hudson.model.Hudson@6a4edb79>.getDynamic("MyRootAction",...),"/null")
-> evaluate(&lt;org.jenkinsci.plugins.rootactionexampleplugin.MyRootAction@974f250> :org.jenkinsci.plugins.rootactionexampleplugin.MyRootAction,"/null")
<font color=red>-&gt; No matching rule was found on &lt;org.jenkinsci.plugins.rootactionexampleplugin.MyRootAction@974f250&gt; for "/null"</font>
</pre>
<p>&lt;org.jenkinsci.plugins.rootactionexampleplugin.MyRootAction@974f250&gt; has the following URL mappings, in the order of preference:<ol>
<li>
TOKEN.groovy for url=/TOKEN
<li>
VIEW.jelly for url=/VIEW
<li>
org.jenkinsci.plugins.rootactionexampleplugin.MyRootAction.getDescriptor() for url=/descriptor/...
<li>
org.jenkinsci.plugins.rootactionexampleplugin.MyRootAction.getDisplayName() for url=/displayName/...
<li>
org.jenkinsci.plugins.rootactionexampleplugin.MyRootAction.getIconFileName() for url=/iconFileName/...
<li>
org.jenkinsci.plugins.rootactionexampleplugin.MyRootAction.getUrlName() for url=/urlName/...
<li>
org.jenkinsci.plugins.rootactionexampleplugin.MyRootAction.getBuildGoals() for url=/buildGoals/...
<li>
java.lang.Object.getClass() for url=/class/...
</ol>
</body></html>

The code which generates this request is on github (https://github.com/nilleb/jenkins-plugins/tree/master/rootaction-example-plugin).

Tomorrow, maybe.

Thanks, have a good evening.

Il giorno lun 9 feb 2015 20:00 Ulli Hafner <ullrich...@gmail.com> ha scritto:
Hi,

I can't figure out why my doFillXXXItems aren't being called.

Is there some way to log/debug jelly<-->Descriptor interactions?

Thanks in advance,
Ivo

--
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.

--
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/1F5EA278-2094-4225-AB32-3A575D9BD61E%40gmail.com.

Ulli Hafner

unread,
Feb 10, 2015, 6:03:48 AM2/10/15
to jenkin...@googlegroups.com
You should not create a new descriptor on every call to getDescriptor, this is done by Jenkins! So no need to override getDescriptor(). 

Best thing is to extend from AbstractDescribableImpl.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPc4eF-bZx%3Dn78N3QzrXO5-DiPM4Hh08A5srFnVBCB-MgGxT5Q%40mail.gmail.com.
signature.asc

Ivo Bellin Salarin

unread,
Feb 10, 2015, 8:06:50 AM2/10/15
to jenkin...@googlegroups.com
Thanks again, Ulli.

I've reworked my code, and its rather essential right now. My class (MyRootAction) extends AbstractDescribableImpl and it show a nested static public class implementing Descriptor<MyRootAction>. This nested class has been decorated with @Extension, as MyRootAction is. (https://github.com/nilleb/jenkins-plugins/blob/master/rootaction-example-plugin/src/main/java/org/jenkinsci/plugins/rootactionexampleplugin/MyRootAction.java
)

But, the combobox is still not filled with my values. The reason is always the same: my <select/> is as follows: <select name="_.goalType" class="setting-input  select " value=""></select> => the attribute @fillUrl is missing.

The ui-samples, at run-time, have a fillUrl for their <select/>:
<select fillurl="/jenkins/descriptorByName/jenkins.plugins.ui_samples.DynamicDropDownListBox/fillStateItems" filldependson="country" name="_.state" class="setting-input  select " value="USA:B"><option value="USA:A">State A in USA</option><option value="USA:B">State B in USA</option><option value="USA:C">State C in USA</option></select>

Q: How is the <select/> markup being generated?


Ivo Bellin Salarin

unread,
Feb 11, 2015, 1:10:15 AM2/11/15
to jenkin...@googlegroups.com

> Q: How is the <select/> markup being generated?
line 48 of https://github.com/jenkinsci/jenkins/blob/master/core/src/main/resources/lib/form/select.jelly:
${descriptor.calcFillSettings(field,attrs)} <!-- this figures out the 'fillUrl' and 'fillDependsOn' attribute -->

line 394 of https://github.com/jenkinsci/jenkins/blob/4e0af4319ce8d7efc2bf6af313d5e154066b6dee/core/src/main/java/hudson/model/Descriptor.java
public void calcFillSettings(String field, Map<String,Object> attributes)
[..]
if(method==null)
throw new IllegalStateException(String.format("%s doesn't have the %s method for filling a drop-down list", getClass(), methodName));

Q: is my descriptor known to the jenkins instance?
During the debug of one of the static methods, I can get one record for 
jenkins.model.Jenkins.getInstance().<MyRootAction,Descriptor<MyRootAction>>getDescriptorList(MyRootAction.class)
So, the descriptor should be visible to the instance.
The call to 
jenkins.model.Jenkins.getInstance().<MyRootAction,Descriptor<MyRootAction>>getDescriptorList(MyRootAction.class).get(MyRootAction.DescriptorImpl.class)
confirms that this instance is the one returned by my descriptor.

Q: where has my descriptor passed?



For more options, visit https://groups.google.com/d/optout.

--
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.

Ulli Hafner

unread,
Feb 11, 2015, 6:40:16 AM2/11/15
to jenkin...@googlegroups.com
Does it work if you remove the @extension from the action, it belongs to the descriptor…

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPc4eF_g1dW%2BAgyiJOfAFr7-S4S1Bm6J6UF7%3Dk8JhYvFLrujjA%40mail.gmail.com.
signature.asc

Ulli Hafner

unread,
Feb 11, 2015, 6:44:25 AM2/11/15
to jenkin...@googlegroups.com
And shouldn’t there a @DataBoundConstructor constructor for your action?


To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPc4eF_g1dW%2BAgyiJOfAFr7-S4S1Bm6J6UF7%3Dk8JhYvFLrujjA%40mail.gmail.com.
signature.asc

Ivo Bellin Salarin

unread,
Feb 12, 2015, 8:00:40 AM2/12/15
to jenkin...@googlegroups.com
Thanks Ulli,

I have followed your hints:
1) I've implemented a RootAction which has a @DataBoundConstructor and no @Extension
    1.1) this requires an explicit registration of the action in the jenkins instance actions: the @Extension attribute helps the automatic discovery of the root action

2) I've implemented a simple Action with the same characteristics of the RootAction in (1)

For both those actions, the listbox content is not filled. The @fillUrl attribute is simply missing. I am going to debug Jenkins.

Thanks for your attention.

Ivo Bellin Salarin

unread,
Feb 13, 2015, 4:18:01 AM2/13/15
to jenkin...@googlegroups.com
Problem solved: I've debugged Jenkins, and a breakpoint in ExpressionFactory2 has told me the truth. :-)

As I've stated previously, the select.jelly contains an instruction: ${descriptor.calcFillSettings(field,attrs)}

But this expression relies on the presence of a descriptor variable, which is not defined by the Jenkins environment itself. I've added the line
<j:set var="descriptor" value="${it.descriptor}" />
in my jelly files (before the select), and the dynamic listbox is now filled.




For more options, visit https://groups.google.com/d/optout.

--
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.
Reply all
Reply to author
Forward
0 new messages