So I have Java class: PublishingAction:
public class PublishingAction implements Action, ProminentProjectAction {
...
@JavaScriptMethod
public void lockMismatch(int hashCode){
for(MismatchesContainer mc: allMismatches){
for(Mismatch msm: mc.getMismatchesList()){
if(msm.hashCode()==hashCode){
msm.lock("Claimer", "reason");
}
}
}
}
And in jelly:
<script>
var myAction= <st:bind value="${it}" />
function lockMismatch(mismatchHash) {
myAction.lockMismatch(mismatchHash);
}
</script>
...
<img src="/plugin/PluginForJenkins/images/claim.png" onClick="javascript:
lockMismatch(${instanceSecond.hashCode})"/>
Now I'm getting error (visible through GoogleChrome):
1. POST
http://localhost:8080/$stapler/bound/c1678e1a-fc77-44d9-b212-2d73bc6e7b80/lockMismatch
413 (FULL head) prototype.js:1585
1. Ajax.Request.Class.create.requestprototype.js:1585
2. Ajax.Request.Class.create.initializeprototype.js:1550
3. (anonymous function)prototype.js:452
4. klassprototype.js:101
5. proxy.(anonymous function)bind.js:51
6. lockMismatch(index):107
7. onclick
There seems to be 2 reasons:
-somehow I'm passing too much data (how?!)
- more possible: I'm doing something wrong ;-(
Could you aid me, please?
W dniu piątek, 8 sierpnia 2014 22:23:49 UTC+2 użytkownik Robert Sandell
napisał:
>
> Roughly like so:
>
> In YourBackendClass.java
>
> @JavaScriptMethod
> public void setOwner(String owner) {
> this.owner = owner;
> }
>
> In the.jelly
>
> <st:bind var="${theInstanceOfYourBackendClass}" var="backend"/>
> <script>
> function setOwner(owner) {
> backend.setOwner(owner, function(t) {
> //Handle the response
> });
> }
> </script>
> ....
> <img src="/plugin/PluginForJenkins/images/claim.png"
> onClick="setOwner('theOwner')"/>
>
>
> See https://wiki.jenkins-ci.org/display/JENKINS/AJAX+with+JavaScript+proxy
>
> /B
>
>
> 2014-08-08 15:18 GMT+02:00 Tomasz Szandała <[email protected]
> <javascript:>>:
>
>>
>>
>> W dniu piątek, 8 sierpnia 2014 14:51:08 UTC+2 użytkownik Stephen Connolly
>> napisał:
>>>
>>> wrap it in a <a> or add a javascript onclick event handler
>>>
>>> Thank you, but could you, please, give me an example of using <a> tag? I
>>> need to pass a string argument to it.
>>>
>> Spent whole day today working on it, but... failed in it
>>
>>
>>
>>> On 8 August 2014 07:51, Tomasz Szandała <[email protected]> wrote:
>>>
>>>> Greetings,
>>>> I'm working on jenkins plugin nad now encountered a problem:
>>>> I've inserted a picture to my GUI (using jelly) and now I want to
>>>> invoke method on click.
>>>> Best would be if I can pass an argument to it, for example:
>>>> my method:
>>>> public void setOwner(String owner)
>>>> and I have picture:
>>>>
>>>> <img src="/plugin/PluginForJenkins/images/claim.png"/>
>>>> how can I make this picture clickable?
>>>>
>>>> --
>>>> 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.
>>>>
>>>
>>> --
>> 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] <javascript:>.
>> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.