Jelly Repeatable produces Javascript error

301 views
Skip to first unread message

konrad

unread,
Mar 4, 2016, 2:21:12 PM3/4/16
to Jenkins Developers
I am trying to use a repeatable inside a config.jelly of my jenkins plugin:

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:s="/lib/samples" xmlns:f="/lib/form" xmlns:l="/lib/layout">
 
<f:entry title="Some Title">
   
<f:checkbox title="Enable plugin" field="isMyPluginProject"/>
 
</f:entry>
 
<f:block>
   
<f:repeatable var="item" name="items" items="${instance.items}" noAddButton="true" minimum="0">
 
<fieldset>
   
<f:entry title="My Title" description="Project desc." field="pattern">
     
<f:textbox value="${item.pattern}" default="" />
   
</f:entry>
 
</fieldset>
 
<f:repeatableDeleteButton />
 
</f:repeatable>
 
</f:block>
</j:jelly>

This produces the following javascript error:
Uncaught TypeError: Cannot read property 'hasClassName' of undefined
(anonymous function) @ repeatable.js:112
(anonymous function) @ behavior.js:111
(anonymous function) @ behavior.js:107
Behaviour.applySubtree @ behavior.js:93
Behaviour.apply @ behavior.js:76
(anonymous function) @ behavior.js:71
window
.onload @ behavior.js:125
window
.onload @ behavior.js:125




The failing codeine is in repeatable.js line 112. It tries to find a div with class 'repeatable-insertion-point'.
// do the ones that extract innerHTML so that they can get their original HTML before
// other behavior rules change them (like YUI buttons.)
Behaviour.specify("DIV.repeated-container", 'repeatable', -100, function(e) {
       
if(isInsideRemovable(e))    return;

       
// compute the insertion point
       
var ip = $(e.lastChild);
       
while (!ip.hasClassName("repeatable-insertion-point"))
            ip
= ip.previous();
       
// set up the logic
       
object(repeatableSupport).init(e, e.firstChild, ip);
});

What am I doing wrong?

Kanstantsin Shautsou

unread,
Mar 4, 2016, 3:23:14 PM3/4/16
to Jenkins Developers
What core version do you use? 1.609.X? It broken, try 1.625.3 at least.

konrad

unread,
Mar 5, 2016, 8:23:07 AM3/5/16
to Jenkins Developers
Thanks for your answer. I am using 1.580.1 :D I'll try 625

konrad

unread,
Mar 5, 2016, 9:05:04 AM3/5/16
to Jenkins Developers
I am on 1.625.3 now and the problem is the same. Any other ideas? :)

Kanstantsin Shautsou

unread,
Mar 5, 2016, 9:05:35 AM3/5/16
to jenkin...@googlegroups.com
Try 1.580.3 firstly, some versions had bug but i don’t exactly remember what.

-- 
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/NBRtnkAfDbU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/34db963b-1304-4e1c-8890-5dfd9b916e0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Kanstantsin Shautsou

unread,
Mar 5, 2016, 9:07:29 AM3/5/16
to jenkin...@googlegroups.com
Did you make `mnv clean` after switching to new version?
If it wouldn’t work, then issue is somewhere else.
signature.asc

konrad

unread,
Mar 5, 2016, 9:14:14 AM3/5/16
to Jenkins Developers
It neither works with 1.580.3. Do you have any other idea where the issue could be? Did I forget something in the jelly file?

I always do a mvn clean, thats developer cargo cult isn't it :D

Kanstantsin Shautsou

unread,
Mar 5, 2016, 9:15:54 AM3/5/16
to jenkin...@googlegroups.com
Well, if you do something custom then you need to place stapler-bag or stapler-class. Would keep this magic description to somebody else :)

signature.asc

konrad

unread,
Mar 5, 2016, 9:41:44 AM3/5/16
to Jenkins Developers
I tried to extend the xml with this: xmlns:st="jelly:stapler"

But it doesn't help :(

I am stuck in this view:


konrad

unread,
Mar 5, 2016, 11:05:04 AM3/5/16
to Jenkins Developers
Okay, I have the solution. You can't use f:entry inside a f:repeatable. If you do it, that will destroy the generated HTML and jenkins repeatable.js (line 112) can't find the div with class 'repeatable-insertion-point' as it is outside of 'repeated-container' div.

Kanstantsin, how can I access my JobProperty instance from the config.jelly?

This is my property class:

public class MyJobProperty extends JobProperty<AbstractProject<?, ?>>
{
   
private boolean isMyProject;

   
public String getTest()
   
{
       
return "test";
   
}

   
@Extension
    public static class DescriptorImpl extends JobPropertyDescriptor
   
{
       
@Override
        public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException
       
{
           
return super.newInstance(req, formData);
       
}

       
@Override
        public String getDisplayName()
       
{
           
return "...";
       
}

       
public String getTest()
       
{
           
return "ttest";
       
}
   
}
}

In my config.jelly I know I can do a ${descriptor.test} and I get "ttest". But I would like to do something like ${jobProperty.test}.

Kanstantsin Shautsou

unread,
Mar 5, 2016, 11:09:23 AM3/5/16
to jenkin...@googlegroups.com
Ah right! I also had issues with embedding one forms into other forms.
Note, JobProperty shouldn’t be available for all jobs by default, so you would need some tricks (you may search for existing plugins) or require to some latest core where Jesse implemented OptionalJobProperty that doesn’t render body by default.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/NBRtnkAfDbU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
signature.asc

Konrad Jurk

unread,
Mar 5, 2016, 11:19:50 AM3/5/16
to jenkin...@googlegroups.com
Alright, good to know :) What happens if I just use JobProperty instead of OptionalProperty? Does it blow up existing jobs?

Could you take a look at my other question above? :) (how to access my JobProperty instance from config.jelly)

Jesse Glick

unread,
Mar 7, 2016, 11:04:48 AM3/7/16
to Jenkins Dev
On Fri, Mar 4, 2016 at 2:21 PM, 'konrad' via Jenkins Developers
<jenkin...@googlegroups.com> wrote:
> I am trying to use a repeatable inside a config.jelly of my jenkins plugin:

Unless you really know what you are doing, I recommend staying away
from low-level tags like this. Use `f:repeatableProperty` with a
separate `Describable` subtype. See the `ui-samples` plugin.
Reply all
Reply to author
Forward
0 new messages