Default selection in jelly with cookies

10 views
Skip to first unread message

Michael Carter

unread,
May 22, 2023, 10:36:17 AM5/22/23
to Jenkins Developers
Got a page with some <f:select> with filldependson set.   Trying to use cookies to remember the last selection.

So few questions.  Is there an example of this I can follow in some plugin somewhere?  

 I can use jquery to select using 

jQuery('#object').val(cookie.select1)
              .trigger("change")

It selects the object but can't seem to get it to trigger the dependant fill for the next object.  What event is it listening triggering on?

Ullrich Hafner

unread,
May 22, 2023, 10:57:18 AM5/22/23
to JenkinsCI Developers
Why do you want to use cookies? This is better implemented by storing the value in the browser's local storage.


 

--
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/67cb3eb3-f2bb-49a4-959d-57683083a3den%40googlegroups.com.

Michael Carter

unread,
May 22, 2023, 11:03:25 AM5/22/23
to Jenkins Developers
Turns out I was thinking way to complicated:

  <j:set scope="parent" var="defaultProject" value="${h.getCookie(request,'project').getValue()}" />
  <j:set scope="parent" var="defaultRepo" value="${h.getCookie(request,'repo').getValue()}" />
  <j:set scope="parent" var="defaultBranch" value="${h.getCookie(request,'branch').getValue()}" />

Then on the object:
  <f:select  default="${defaultProject}" />

So on the local storage front.   Is there a h. function equivalent?  How would I change the set?

Ullrich Hafner

unread,
May 22, 2023, 3:30:21 PM5/22/23
to JenkinsCI Developers
Ah, you want to use it on the server side. Sorry, then there is no equivalent available.

Reply all
Reply to author
Forward
0 new messages