Custom Plugin Form Handling

99 views
Skip to first unread message

David Payt

unread,
Jan 5, 2016, 6:12:06 PM1/5/16
to Jenkins Developers
I have written a custom Jenkins plugin that provides build-steps and a few Jelly pages. I now need to implement some administration functions that can manipulate my plugin's state and also trigger jobs.

I assume that between Jelly and Stapler, that Jenkins already has From-data-binding and AJAX-calling well-established; but I can't seem to figure out how to pull it off in my own stand-alone Jelly file.

I am trying to use the "Validation Button" approach by employing the form tag library (xmlns:f="/lib/form") in a Jelly file (e.g. http://localhost:8000/jenkins/plugin/myPlugin/administration) but my browser fails to find the Javascript method called "validateButton()". I tracked this method to the hudson-behavior.js which itself depends on other javascript objects.

What is the best way to create a form and form-handling in stand-alone Jelly files (e.g. not embedded Jelly files like config.jelly)Preferably with automated data-binding and via AJAX calls?

Thanks
- David Payt

Daniel Beck

unread,
Jan 5, 2016, 7:42:08 PM1/5/16
to jenkin...@googlegroups.com
Are you using l:layout?
> --
> 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/68d6add6-288f-4a03-b92d-200f5d21ff88%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

David Payt

unread,
Jan 6, 2016, 11:00:50 AM1/6/16
to Jenkins Developers, m...@beckweb.net
I was not using l:layout and had gotten by using jelly:core, HTML, and ${it} to render pages. This is my first foray into forms.

I just wrapped my content into layout tags:

<l:layout title="Node Details">
<l:header>
        ...
    </l:header>
<l:main-panel>
        ...
    </l:main-panel>
</l:layout>

And the validateButton function error has gone away but been replaced by:

prototype.js:5878: Uncaught TypeError: element.dispatchEvent is not a function
breadcrumbs.js:256: Uncaught TypeError: $(...).addClassName is not a function

at load-time and:

hudson-behavior.js:2865: Uncaught TypeError: $(...).up is not a function

at button click time.

I will continue to learn more about the layout tags on my own, but can you recommend a good resource for learning about this?

Thanks
- David Payt

David Payt

unread,
Jan 6, 2016, 11:41:58 AM1/6/16
to Jenkins Developers, m...@beckweb.net
My problem was I had a jquery script that conflicted with prototype. Ok. No more errors, but now I need to learn how to data-bind the form submission.

- David
Reply all
Reply to author
Forward
0 new messages